mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-11 10:33:18 +08:00
Bundle qrcode SVG into lib/qrcode-bundled.cjs and drop the runtime dependency so Desktop field installs work without registry.npmjs.org. Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
972 B
JavaScript
35 lines
972 B
JavaScript
/**
|
|
* Bundle `qrcode` (SVG path) into lib/qrcode-bundled.cjs so Desktop tgz
|
|
* installs need no npm registry fetch for dependencies.
|
|
*
|
|
* Usage: bun run scripts/bundle-qrcode.mjs
|
|
*/
|
|
import { mkdirSync, writeFileSync } from 'node:fs'
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
const entry = join(root, 'scripts', 'qrcode-entry.cjs')
|
|
const out = join(root, 'lib', 'qrcode-bundled.cjs')
|
|
|
|
mkdirSync(dirname(out), { recursive: true })
|
|
|
|
const result = await Bun.build({
|
|
entrypoints: [entry],
|
|
outfile: out,
|
|
target: 'node',
|
|
format: 'cjs',
|
|
sourcemap: 'none',
|
|
minify: false,
|
|
})
|
|
|
|
if (!result.success) {
|
|
console.error(result.logs)
|
|
throw new Error('bundle qrcode failed')
|
|
}
|
|
|
|
// Bun may write via outfile; also ensure content if outputs differ.
|
|
if (result.outputs[0]) {
|
|
writeFileSync(out, await result.outputs[0].text(), 'utf8')
|
|
}
|
|
console.log(`wrote ${out}`)
|