From 721053935bdefc74644f0514ba71f6adf1e978b0 Mon Sep 17 00:00:00 2001 From: Ralph Torres Date: Fri, 12 Jun 2026 14:43:34 +0000 Subject: [PATCH 1/2] add --no-compile flag and build:bundle script allows building a plain js bundle without embedding the bun runtime, useful for distribution packaging where bun is a system dependency --- js/cli/package.json | 1 + js/cli/scripts/build-cli.mjs | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/js/cli/package.json b/js/cli/package.json index b06dc573..4ce7901c 100644 --- a/js/cli/package.json +++ b/js/cli/package.json @@ -6,6 +6,7 @@ "scripts": { "build": "bun ./scripts/build-cli.mjs main", "build:internal": "bun ./scripts/build-cli.mjs internal", + "build:bundle": "bun ./scripts/build-cli.mjs main bun --no-compile", "check-types": "tsc --noEmit", "generate-types": "bunx openapi-typescript ../../api/openapi-core.json -o ./src/api/api-core-types.ts && bunx openapi-typescript ../../api/openapi-auth.json -o ./src/api/api-auth-types.ts", "generate-metric-schemas": "bun ./scripts/generate-metric-schemas.ts", diff --git a/js/cli/scripts/build-cli.mjs b/js/cli/scripts/build-cli.mjs index 68107e11..087433dd 100644 --- a/js/cli/scripts/build-cli.mjs +++ b/js/cli/scripts/build-cli.mjs @@ -8,20 +8,24 @@ const GIT_ROOT = path.resolve(import.meta.dir, '../../..'); const mode = process.argv[2] === 'internal' ? 'internal' : 'main'; const target = process.argv[3] || 'bun'; +const noCompile = process.argv.includes('--no-compile'); let outfileArchitecture = ''; if (target.startsWith('bun-')) { outfileArchitecture = '/' + target.slice(4); } const entry = mode === 'internal' ? 'src/internal-cli/proton-drive-internal.ts' : 'src/proton-drive.ts'; -const outfile = mode === 'internal' ? `release${outfileArchitecture}/proton-drive-internal` : `release${outfileArchitecture}/proton-drive`; +const outfileName = mode === 'internal' ? 'proton-drive-internal' : 'proton-drive'; +const outfile = `release${outfileArchitecture}/${outfileName}${noCompile ? '.js' : ''}`; const args = [ 'build', - '--compile', + ...(!noCompile ? [ + '--compile', + // Slower compile, bigger bundle size, faster execution. + '--bytecode', + ] : []), `--target=${target}`, - // Slower compile, bigger bundle size, faster execution. - '--bytecode', // Use modern ESM format to allow await syntax in the entry file. '--format=esm', // Reduce bundle size (not much, the biggest part is the embedded Bun itself). From 1ce0d158b8af59d34636c4e9c729134f492dd612 Mon Sep 17 00:00:00 2001 From: Ralph Torres Date: Fri, 12 Jun 2026 14:45:28 +0000 Subject: [PATCH 2/2] docs: document build:bundle in readme --- js/cli/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/js/cli/README.md b/js/cli/README.md index 50a4c34c..a13cec69 100644 --- a/js/cli/README.md +++ b/js/cli/README.md @@ -28,6 +28,15 @@ bun run build This produces a standalone executable at **`release/proton-drive`** with embedded Bun. Add that directory to your `PATH`, or invoke it with a full path. +To build a plain JS bundle using a system-installed Bun instead: + +```bash +cd ../sdk && bun install +cd ../cli && bun run build:bundle +``` + +This produces `release/proton-drive.js`. You are responsible for providing a wrapper to invoke it, e.g. `exec bun /path/to/proton-drive.js "$@"`. + ## Authentication Sign-in uses the browser (no password on the command line):