@@ -2,7 +2,7 @@ import { cp, mkdir, rm, writeFile, chmod } from "node:fs/promises";
22import { existsSync } from "node:fs" ;
33import { createRequire } from "node:module" ;
44import { resolve , join , dirname } from "node:path" ;
5- import { fileURLToPath , pathToFileURL } from "node:url" ;
5+ import { fileURLToPath } from "node:url" ;
66import { parseArgs } from "node:util" ;
77import { $ } from "bun" ;
88
@@ -11,8 +11,6 @@ const cliRoot = resolve(repoRoot, "apps/cli");
1111const webRoot = resolve ( repoRoot , "apps/local" ) ;
1212const distDir = resolve ( cliRoot , "dist" ) ;
1313const ONEPASSWORD_CORE_WASM_FILENAME = "onepassword-core_bg.wasm" ;
14- const WORKERD_VERSION = "1.20260708.1" ;
15- const WORKER_BUNDLER_DIRNAME = "worker-bundler" ;
1614
1715const resolveQuickJsWasmPath = ( ) : string => {
1816 const req = createRequire ( join ( repoRoot , "packages/kernel/runtime-quickjs/package.json" ) ) ;
@@ -35,34 +33,6 @@ const resolveOnePasswordCoreWasmPath = (): string => {
3533 return wasmPath ;
3634} ;
3735
38- const resolveWorkerBundlerDistPath = ( ) : string => {
39- const req = createRequire ( join ( repoRoot , "packages/plugins/apps/package.json" ) ) ;
40- const pkgJson = req . resolve ( "@cloudflare/worker-bundler/package.json" ) ;
41- const distPath = join ( dirname ( pkgJson ) , "dist" ) ;
42- if ( ! existsSync ( join ( distPath , "index.js" ) ) || ! existsSync ( join ( distPath , "esbuild.wasm" ) ) ) {
43- throw new Error ( `@cloudflare/worker-bundler dist files not found at ${ distPath } ` ) ;
44- }
45- return distPath ;
46- } ;
47-
48- const createPackedWorkerBundlerSource = async ( distPath : string ) : Promise < string > => {
49- const esbuildPath = join ( repoRoot , "node_modules/.bun/node_modules/esbuild/lib/main.js" ) ;
50- if ( ! existsSync ( esbuildPath ) ) throw new Error ( `esbuild not found at ${ esbuildPath } ` ) ;
51- const { build } = await import ( pathToFileURL ( esbuildPath ) . href ) ;
52- const result = await build ( {
53- entryPoints : [ join ( distPath , "index.js" ) ] ,
54- bundle : true ,
55- format : "esm" ,
56- platform : "browser" ,
57- external : [ "./esbuild.wasm" ] ,
58- logLevel : "silent" ,
59- write : false ,
60- } ) ;
61- const source = result . outputFiles [ 0 ] ?. text ;
62- if ( source === undefined ) throw new Error ( "failed to bundle @cloudflare/worker-bundler" ) ;
63- return source ;
64- } ;
65-
6636// ---------------------------------------------------------------------------
6737// Metadata
6838// ---------------------------------------------------------------------------
@@ -149,7 +119,6 @@ const bunTarget = (t: Target): Bun.Build.CompileTarget => {
149119} ;
150120
151121const binaryName = ( t : Target ) => ( t . os === "win32" ? "executor.exe" : "executor" ) ;
152- const workerdBinaryName = ( t : Target ) => ( t . os === "win32" ? "workerd.exe" : "workerd" ) ;
153122
154123const isCurrentPlatform = ( t : Target ) =>
155124 t . os === process . platform && t . arch === process . arch && ! t . abi ;
@@ -242,41 +211,6 @@ const resolveLibsqlNative = (t: Target): string | null => {
242211 }
243212} ;
244213
245- const resolveWorkerdBinary = ( t : Target ) : string | null => {
246- const platformMap : Record < string , string > = {
247- "darwin-arm64" : "@cloudflare/workerd-darwin-arm64" ,
248- "darwin-x64" : "@cloudflare/workerd-darwin-64" ,
249- "linux-arm64" : "@cloudflare/workerd-linux-arm64" ,
250- "linux-x64" : "@cloudflare/workerd-linux-64" ,
251- "win32-x64" : "@cloudflare/workerd-windows-64" ,
252- } ;
253- const key = [ t . os , t . arch , t . abi ] . filter ( Boolean ) . join ( "-" ) ;
254- const pkg = platformMap [ key ] ;
255- if ( ! pkg ) return null ;
256- const binary = workerdBinaryName ( t ) ;
257- try {
258- const req = createRequire (
259- join ( repoRoot , "packages/kernel/runtime-workerd-subprocess/package.json" ) ,
260- ) ;
261- const pkgJson = req . resolve ( `${ pkg } /package.json` ) ;
262- for ( const candidate of [
263- join ( dirname ( pkgJson ) , "bin" , binary ) ,
264- join ( dirname ( pkgJson ) , binary ) ,
265- ] ) {
266- if ( existsSync ( candidate ) ) return candidate ;
267- }
268- } catch {
269- const packageRoot = join (
270- repoRoot ,
271- `node_modules/.bun/${ pkg . replace ( "/" , "+" ) } @${ WORKERD_VERSION } /node_modules/${ pkg } ` ,
272- ) ;
273- for ( const candidate of [ join ( packageRoot , "bin" , binary ) , join ( packageRoot , binary ) ] ) {
274- if ( existsSync ( candidate ) ) return candidate ;
275- }
276- }
277- return null ;
278- } ;
279-
280214// ---------------------------------------------------------------------------
281215// Build mode
282216// ---------------------------------------------------------------------------
@@ -399,8 +333,6 @@ const buildBinaries = async (targets: Target[], mode: BuildMode) => {
399333
400334 const quickJsWasmPath = resolveQuickJsWasmPath ( ) ;
401335 const onePasswordCoreWasmPath = resolveOnePasswordCoreWasmPath ( ) ;
402- const workerBundlerDistPath = resolveWorkerBundlerDistPath ( ) ;
403- const packedWorkerBundlerSource = await createPackedWorkerBundlerSource ( workerBundlerDistPath ) ;
404336
405337 try {
406338 for ( const target of targets ) {
@@ -443,35 +375,12 @@ const buildBinaries = async (targets: Target[], mode: BuildMode) => {
443375 await cp ( libsqlNative , join ( binDir , "libsql.node" ) ) ;
444376 }
445377
446- const workerdBinary = resolveWorkerdBinary ( target ) ;
447- if ( workerdBinary && existsSync ( workerdBinary ) ) {
448- await cp ( workerdBinary , join ( binDir , workerdBinaryName ( target ) ) ) ;
449- if ( target . os !== "win32" ) await chmod ( join ( binDir , workerdBinaryName ( target ) ) , 0o755 ) ;
450- }
451-
452- await cp ( workerBundlerDistPath , join ( binDir , WORKER_BUNDLER_DIRNAME , "dist" ) , {
453- recursive : true ,
454- } ) ;
455- await writeFile (
456- join ( binDir , WORKER_BUNDLER_DIRNAME , "dist" , "index.bundled.js" ) ,
457- packedWorkerBundlerSource ,
458- ) ;
459-
460378 // Smoke test on current platform
461379 if ( isCurrentPlatform ( target ) ) {
462380 const bin = join ( binDir , binaryName ( target ) ) ;
463381 console . log ( ` Smoke test: ${ bin } --version` ) ;
464382 const version = await $ `${ bin } --version` . text ( ) ;
465383 console . log ( ` OK: ${ version . trim ( ) } ` ) ;
466- console . log ( ` Smoke test: packed apps source sync and invoke` ) ;
467- const smoke = Bun . spawn (
468- [ "bun" , "run" , join ( cliRoot , "scripts/smoke-packed-apps.ts" ) , bin ] ,
469- {
470- cwd : repoRoot ,
471- stdio : [ "ignore" , "inherit" , "inherit" ] ,
472- } ,
473- ) ;
474- if ( ( await smoke . exited ) !== 0 ) throw new Error ( "packed apps smoke failed" ) ;
475384 }
476385
477386 // Variant package.json. All variants publish to the SAME npm package
0 commit comments