@nimbus-sh/worker 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esbuild-cli-artifact.generated.d.ts +1 -1
- package/dist/esbuild-cli-artifact.generated.js +4 -4
- package/dist/esbuild-wasm-bundle.generated.d.ts +11 -10
- package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -1
- package/dist/esbuild-wasm-bundle.generated.js +11 -10
- package/dist/facets/build-facet.d.ts +53 -0
- package/dist/facets/build-facet.d.ts.map +1 -0
- package/dist/facets/build-facet.js +346 -0
- package/dist/facets/cirrus-real.d.ts +3 -0
- package/dist/facets/cirrus-real.d.ts.map +1 -1
- package/dist/facets/cirrus-real.js +1 -2
- package/dist/facets/compose.d.ts +1 -0
- package/dist/facets/compose.d.ts.map +1 -1
- package/dist/facets/compose.js +3 -0
- package/dist/facets/data-plan.d.ts +14 -30
- package/dist/facets/data-plan.d.ts.map +1 -1
- package/dist/facets/data-plan.js +153 -13
- package/dist/facets/dev-stylesheet.d.ts +27 -0
- package/dist/facets/dev-stylesheet.d.ts.map +1 -0
- package/dist/facets/dev-stylesheet.js +65 -0
- package/dist/facets/esbuild-transform.d.ts +23 -18
- package/dist/facets/esbuild-transform.d.ts.map +1 -1
- package/dist/facets/esbuild-transform.js +63 -109
- package/dist/facets/manager.d.ts +49 -9
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +238 -69
- package/dist/facets/oxc-transform.d.ts +29 -0
- package/dist/facets/oxc-transform.d.ts.map +1 -0
- package/dist/facets/oxc-transform.js +198 -0
- package/dist/facets/prebundle-pool.d.ts +23 -0
- package/dist/facets/prebundle-pool.d.ts.map +1 -0
- package/dist/facets/prebundle-pool.js +55 -0
- package/dist/facets/process.d.ts +13 -6
- package/dist/facets/process.d.ts.map +1 -1
- package/dist/facets/process.js +37 -31
- package/dist/facets/transform-store.d.ts +4 -4
- package/dist/facets/transform-store.js +4 -4
- package/dist/facets/vite-dev-server.d.ts +89 -12
- package/dist/facets/vite-dev-server.d.ts.map +1 -1
- package/dist/facets/vite-dev-server.js +66 -43
- package/dist/hosted/commands.d.ts.map +1 -1
- package/dist/hosted/commands.js +20 -4
- package/dist/hosted/runtime.d.ts.map +1 -1
- package/dist/hosted/runtime.js +7 -2
- package/dist/hosted/services.d.ts +3 -3
- package/dist/hosted/services.d.ts.map +1 -1
- package/dist/hosted/services.js +102 -95
- package/dist/hosted/session.d.ts +1 -0
- package/dist/hosted/session.d.ts.map +1 -1
- package/dist/loaders/generated-workers.d.ts +3 -0
- package/dist/loaders/generated-workers.d.ts.map +1 -1
- package/dist/loaders/generated-workers.js +3 -0
- package/dist/napi-wasm-artifacts.generated.js +2 -2
- package/dist/node-shims-artifact.generated.d.ts +14 -1
- package/dist/node-shims-artifact.generated.d.ts.map +1 -1
- package/dist/node-shims-artifact.generated.js +23 -10
- package/dist/npm/bin-links.d.ts +7 -4
- package/dist/npm/bin-links.d.ts.map +1 -1
- package/dist/npm/bin-links.js +14 -55
- package/dist/npm/cache.d.ts +6 -0
- package/dist/npm/cache.d.ts.map +1 -1
- package/dist/npm/cache.js +26 -4
- package/dist/npm/installer.d.ts +1 -1
- package/dist/npm/installer.d.ts.map +1 -1
- package/dist/npm/installer.js +26 -52
- package/dist/npm/pre-bundle-facet.d.ts +15 -117
- package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
- package/dist/npm/pre-bundle-facet.js +13 -511
- package/dist/oxc-facet-artifact.generated.d.ts +18 -0
- package/dist/oxc-facet-artifact.generated.d.ts.map +1 -0
- package/dist/oxc-facet-artifact.generated.js +17 -0
- package/dist/oxc-wasm-artifact.generated.d.ts +20 -0
- package/dist/oxc-wasm-artifact.generated.d.ts.map +1 -0
- package/dist/oxc-wasm-artifact.generated.js +19 -0
- package/dist/rolldown-facet-artifact.generated.d.ts +18 -0
- package/dist/rolldown-facet-artifact.generated.d.ts.map +1 -0
- package/dist/rolldown-facet-artifact.generated.js +17 -0
- package/dist/router/remote-api.d.ts.map +1 -1
- package/dist/router/remote-api.js +9 -0
- package/dist/runtime/bash-repl.d.ts.map +1 -1
- package/dist/runtime/bash-repl.js +1 -4
- package/dist/runtime/cpython-resident.d.ts.map +1 -1
- package/dist/runtime/cpython-resident.js +1 -0
- package/dist/runtime/esbuild-wasm-bytes.d.ts +25 -23
- package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -1
- package/dist/runtime/esbuild-wasm-bytes.js +30 -25
- package/dist/runtime/facet-loader-host.d.ts +5 -4
- package/dist/runtime/facet-loader-host.d.ts.map +1 -1
- package/dist/runtime/facet-loader-host.js +5 -4
- package/dist/runtime/node-runner.d.ts +2 -0
- package/dist/runtime/node-runner.d.ts.map +1 -1
- package/dist/runtime/node-runner.js +1 -0
- package/dist/runtime/node-shims-artifact.d.ts +8 -1
- package/dist/runtime/node-shims-artifact.d.ts.map +1 -1
- package/dist/runtime/node-shims-artifact.js +32 -4
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +145 -109
- package/dist/runtime/opencode-facet-runner.d.ts.map +1 -1
- package/dist/runtime/opencode-facet-runner.js +6 -2
- package/dist/runtime/oxc-wasm-bytes.d.ts +19 -0
- package/dist/runtime/oxc-wasm-bytes.d.ts.map +1 -0
- package/dist/runtime/oxc-wasm-bytes.js +39 -0
- package/dist/runtime/package-manager.js +1 -1
- package/dist/runtime/process-logs-api.d.ts.map +1 -1
- package/dist/runtime/process-logs-api.js +2 -0
- package/dist/runtime/project-fs.d.ts +8 -1
- package/dist/runtime/project-fs.d.ts.map +1 -1
- package/dist/runtime/project-fs.js +15 -1
- package/dist/runtime/python-repl.d.ts +40 -1
- package/dist/runtime/python-repl.d.ts.map +1 -1
- package/dist/runtime/python-repl.js +19 -11
- package/dist/runtime/ruby-repl.d.ts +38 -0
- package/dist/runtime/ruby-repl.d.ts.map +1 -1
- package/dist/runtime/ruby-repl.js +24 -5
- package/dist/runtime/ruby-resident.d.ts.map +1 -1
- package/dist/runtime/ruby-resident.js +2 -0
- package/dist/session/nimbus-session.d.ts +13 -8
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +11 -5
- package/dist/session/programmatic.d.ts +25 -30
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +65 -93
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +23 -7
- package/dist/session/rpc.d.ts +16 -6
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +53 -13
- package/dist/session/start-real-vite.d.ts +24 -9
- package/dist/session/start-real-vite.d.ts.map +1 -1
- package/dist/session/start-real-vite.js +40 -4
- package/dist/session/supervisor-op.d.ts +14 -0
- package/dist/session/supervisor-op.d.ts.map +1 -1
- package/dist/session/supervisor-op.js +49 -0
- package/dist/session/supervisor-rpc.d.ts +11 -0
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +18 -0
- package/dist/session/vite-command.d.ts.map +1 -1
- package/dist/session/vite-command.js +23 -19
- package/dist/session/ws-relay.d.ts.map +1 -1
- package/dist/session/ws-relay.js +13 -1
- package/dist/shell/npm-bin-entrypoints.d.ts +3 -1
- package/dist/shell/npm-bin-entrypoints.d.ts.map +1 -1
- package/dist/shell/npm-bin-entrypoints.js +53 -25
- package/dist/vfs/facet-resident-store.d.ts.map +1 -1
- package/dist/vfs/facet-resident-store.js +11 -5
- package/dist/wrangler/nimbus-wrangler.d.ts +8 -0
- package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -1
- package/dist/wrangler/nimbus-wrangler.js +54 -57
- package/package.json +6 -4
- package/public/_assets/esbuild-0.24.2.wasm +0 -0
- package/public/_assets/napi-wasm/loader/{99efae93dd1dcc2b → ab7e57fe9e8750c2}/napi-wasm-loader.mjs +4 -4
- package/public/_assets/napi-wasm/loader/{99efae93dd1dcc2b → ab7e57fe9e8750c2}/provenance.json +2 -2
- package/public/_assets/oxc/nimbus-oxc-1aa8c4c7057c6c28.provenance.json +72 -0
- package/public/_assets/oxc/nimbus-oxc-1aa8c4c7057c6c28.wasm +0 -0
- package/public/_assets/runtime/esbuild-cli-f13e6a112b03ac07.js +1143 -0
- package/public/_assets/runtime/js-interpreter-3c37c48024f0f651.js +23 -0
- package/public/_assets/runtime/js-interpreter-ops-2f4dfec6798e70fc.js +290 -0
- package/public/_assets/runtime/js-interpreter-primordials-e620a61b7e9800fa.js +1 -0
- package/public/_assets/runtime/{node-shims-f92f16c7d7c532e9.js → node-shims-e3adc4576da31e6e.js} +651 -103
- package/public/_assets/runtime/{esbuild-cli-b7aecffd4c6a36fe.js → oxc-facet-fd86fefcdf16bf9c.js} +217 -1047
- package/public/_assets/runtime/{resident-store-92386265e8b306dc.js → resident-store-009f39539ac989fc.js} +11 -5
- package/public/_assets/runtime/rolldown-facet-09983434e2dbe93e.js +15165 -0
- package/public/_assets/runtime/{vfs-write-ledger-d33ee0034446c3e0.js → vfs-write-ledger-9e9594591425a9b8.js} +4 -1
- package/scripts/acorn-primordials.mjs +637 -0
- package/scripts/bundle-esbuild-wasm.mjs +42 -50
- package/scripts/bundle-facet-workers.mjs +247 -18
- package/scripts/bundle-node-shims.mjs +29 -2
- package/scripts/bundle-oxc-wasm.mjs +105 -0
- package/scripts/interpreter-bundle.mjs +105 -0
- package/scripts/napi-wasm/build.mjs +4 -1
- package/scripts/napi-wasm/loader/napi-wasm-loader.ts +38 -3
- package/scripts/oxc-wasm/Cargo.lock +1246 -0
- package/scripts/oxc-wasm/Cargo.toml +30 -0
- package/scripts/oxc-wasm/build.mjs +249 -0
- package/scripts/oxc-wasm/examples/memory.rs +51 -0
- package/scripts/oxc-wasm/examples/transform.rs +20 -0
- package/scripts/oxc-wasm/inputs.mjs +32 -0
- package/scripts/oxc-wasm/rust-toolchain.toml +5 -0
- package/scripts/oxc-wasm/src/abi.rs +136 -0
- package/scripts/oxc-wasm/src/diagnostics.rs +49 -0
- package/scripts/oxc-wasm/src/helpers.rs +139 -0
- package/scripts/oxc-wasm/src/lib.rs +247 -0
- package/scripts/oxc-wasm/src/module.rs +978 -0
- package/scripts/oxc-wasm/src/names.rs +175 -0
- package/scripts/oxc-wasm/src/options.rs +154 -0
- package/scripts/parser-audit.mjs +492 -0
- package/scripts/rolldown-facet/entry.mjs +21 -0
- package/scripts/rolldown-facet/shims.mjs +64 -0
- package/dist/facets/esbuild-bundle-pool.d.ts +0 -43
- package/dist/facets/esbuild-bundle-pool.d.ts.map +0 -1
- package/dist/facets/esbuild-bundle-pool.js +0 -80
- package/dist/loaders/pre-bundle-preamble.d.ts +0 -44
- package/dist/loaders/pre-bundle-preamble.d.ts.map +0 -1
- package/dist/loaders/pre-bundle-preamble.js +0 -116
- package/dist/runtime/host-wasm.d.ts +0 -8
- package/dist/runtime/host-wasm.d.ts.map +0 -1
- package/dist/runtime/host-wasm.js +0 -33
- /package/public/_assets/napi-wasm/loader/{99efae93dd1dcc2b → ab7e57fe9e8750c2}/wasi-trampoline.wasm +0 -0
|
@@ -4,24 +4,21 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Why this exists
|
|
6
6
|
* ───────────────
|
|
7
|
-
*
|
|
8
|
-
* src/
|
|
9
|
-
* `esbuild
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* esbuild runs only in a Durable Object's esbuild facet
|
|
8
|
+
* (src/facets/esbuild-transform.ts), and only for what Nimbus's own engines
|
|
9
|
+
* do not do: the `esbuild` command, a module nested too deeply for Oxc's
|
|
10
|
+
* stack, and a build whose rolldown binding died. The facet needs two
|
|
11
|
+
* pieces of esbuild-wasm, both staged in the static-assets layer and
|
|
12
|
+
* fetched, digest-checked, only when the facet is loaded:
|
|
12
13
|
*
|
|
13
14
|
* 1. The JS adapter (`esbuild-wasm/esm/browser.js`, ~117 KiB), rewritten
|
|
14
|
-
* into a function body
|
|
15
|
-
* build as a module for its own transforms, so the adapter is staged
|
|
16
|
-
* in the static-assets layer rather than embedded a second time as a
|
|
17
|
-
* string.
|
|
15
|
+
* into a function body the facet compiles at startup.
|
|
18
16
|
*
|
|
19
|
-
* 2. The wasm binary (`esbuild.wasm
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* only records its size.
|
|
17
|
+
* 2. The wasm binary (`esbuild.wasm`, 11.4 MiB), a module of the facet's
|
|
18
|
+
* module map, compiled when the facet starts. The host Worker carries
|
|
19
|
+
* none of it: bundled, wrangler made it a compiled module of the
|
|
20
|
+
* Worker, which workerd compiled at startup in every isolate, whether
|
|
21
|
+
* or not the isolate ever ran esbuild.
|
|
25
22
|
*
|
|
26
23
|
* Pre-A'.5 design (this script's prior form) embedded the wasm bytes
|
|
27
24
|
* as a base64 string in src/esbuild-wasm-bundle.generated.ts. That
|
|
@@ -51,11 +48,15 @@
|
|
|
51
48
|
* src/esbuild-wasm-bundle.generated.ts
|
|
52
49
|
* export const ESBUILD_WASM_VERSION: string;
|
|
53
50
|
* export const ESBUILD_JS_ASSET_PATH: string; // /_assets/esbuild-<version>.js
|
|
54
|
-
* export const ESBUILD_WASM_BYTES: number; // bundled wasm size
|
|
55
51
|
* export const ESBUILD_JS_SHA256: string; // staged adapter digest
|
|
52
|
+
* export const ESBUILD_WASM_ASSET_PATH: string; // /_assets/esbuild-<version>.wasm
|
|
53
|
+
* export const ESBUILD_WASM_SHA256: string; // staged wasm digest
|
|
54
|
+
* export const ESBUILD_WASM_BYTES: number; // staged wasm size
|
|
56
55
|
*
|
|
57
56
|
* public/_assets/esbuild-<version>.js
|
|
58
57
|
* The adapter as a function body, picked up by the ASSETS binding.
|
|
58
|
+
* public/_assets/esbuild-<version>.wasm
|
|
59
|
+
* esbuild-wasm's esbuild.wasm, byte for byte.
|
|
59
60
|
*
|
|
60
61
|
* Run via:
|
|
61
62
|
* node scripts/bundle-esbuild-wasm.mjs
|
|
@@ -143,25 +144,19 @@ async function main() {
|
|
|
143
144
|
`[bundle-esbuild-wasm] rewrote ${exportBody.split(',').length} exports → object-return shape`,
|
|
144
145
|
);
|
|
145
146
|
|
|
146
|
-
// ── 2. The wasm:
|
|
147
|
-
//
|
|
148
|
-
//
|
|
149
|
-
//
|
|
150
|
-
// (src/runtime/host-wasm.ts) instead of fetching a second copy from
|
|
151
|
-
// ASSETS and compiling it again. The generated module records its size,
|
|
152
|
-
// which the 64 MiB dynamic-worker code budget counts: a compiled module's
|
|
153
|
-
// wire bytes still count toward it (workerd src/workerd/api/
|
|
154
|
-
// worker-loader.c++, extractWasmModuleContent), and JS cannot read that
|
|
155
|
-
// size off a Module.
|
|
147
|
+
// ── 2. The wasm: staged, byte for byte ──────────────────────────────
|
|
148
|
+
// The esbuild facet fetches it (digest-checked) when it is loaded and
|
|
149
|
+
// hands it to its module map, where workerd compiles it at the facet's
|
|
150
|
+
// startup; no other isolate holds it.
|
|
156
151
|
const wasmBytes = await fs.readFile(WASM_SRC);
|
|
152
|
+
await fs.mkdir(OUT_ASSETS_DIR, { recursive: true });
|
|
153
|
+
const wasmAssetName = `esbuild-${version}.wasm`;
|
|
154
|
+
await fs.writeFile(path.join(OUT_ASSETS_DIR, wasmAssetName), wasmBytes);
|
|
155
|
+
const wasmSha256 = createHash('sha256').update(wasmBytes).digest('hex');
|
|
157
156
|
console.log(
|
|
158
|
-
`[bundle-esbuild-wasm] esbuild.wasm
|
|
157
|
+
`[bundle-esbuild-wasm] staged esbuild.wasm → public/_assets/${wasmAssetName} (${(wasmBytes.length / (1024 * 1024)).toFixed(1)} MiB)`,
|
|
159
158
|
);
|
|
160
|
-
|
|
161
|
-
// The JS adapter is staged. Facets splice it into their source as a
|
|
162
|
-
// string; the supervisor imports esbuild-wasm as a module for its own
|
|
163
|
-
// transforms, so carrying the adapter inline as well shipped it twice in
|
|
164
|
-
// the Worker bundle.
|
|
159
|
+
// The JS adapter, staged beside it: the facet splices it into its source as a string.
|
|
165
160
|
const jsAssetName = `esbuild-${version}.js`;
|
|
166
161
|
const jsAssetOut = path.join(OUT_ASSETS_DIR, jsAssetName);
|
|
167
162
|
const jsBytes = Buffer.from(jsFn, 'utf8');
|
|
@@ -172,30 +167,26 @@ async function main() {
|
|
|
172
167
|
);
|
|
173
168
|
|
|
174
169
|
// ── 3. Clean up stale staged esbuild assets in public/_assets/ ──────
|
|
175
|
-
// Keeps the deploy lean: an old version's adapter
|
|
176
|
-
// (no longer staged at all), are removed.
|
|
170
|
+
// Keeps the deploy lean: an old version's adapter and wasm are removed.
|
|
177
171
|
for (const entry of await fs.readdir(OUT_ASSETS_DIR)) {
|
|
178
|
-
if (entry.startsWith('esbuild-') && (entry.endsWith('.wasm') || (entry.endsWith('.js') && entry !== jsAssetName))) {
|
|
172
|
+
if (entry.startsWith('esbuild-') && ((entry.endsWith('.wasm') && entry !== wasmAssetName) || (entry.endsWith('.js') && entry !== jsAssetName))) {
|
|
179
173
|
const stale = path.join(OUT_ASSETS_DIR, entry);
|
|
180
174
|
await fs.unlink(stale);
|
|
181
175
|
console.log(`[bundle-esbuild-wasm] removed stale asset: ${entry}`);
|
|
182
176
|
}
|
|
183
177
|
}
|
|
184
178
|
|
|
185
|
-
// ── 4. Emit the generated TS module:
|
|
186
|
-
// Nothing is inline
|
|
187
|
-
// supervisor module scope for the isolate's lifetime; the JS adapter
|
|
188
|
-
// followed the wasm to env.ASSETS so the bundle carries esbuild-wasm
|
|
189
|
-
// once, as the modules the supervisor imports.
|
|
179
|
+
// ── 4. Emit the generated TS module: paths, sizes and digests only ──
|
|
180
|
+
// Nothing is inline: the Worker bundle carries no part of esbuild-wasm.
|
|
190
181
|
const header = `/**
|
|
191
182
|
* esbuild-wasm-bundle.generated.ts — AUTO-GENERATED by scripts/bundle-esbuild-wasm.mjs
|
|
192
183
|
* DO NOT EDIT.
|
|
193
184
|
*
|
|
194
|
-
* The esbuild-wasm ${version} artifacts
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
185
|
+
* The esbuild-wasm ${version} artifacts the esbuild facet runs: the wasm,
|
|
186
|
+
* public/_assets/esbuild-${version}.wasm, and the JS adapter,
|
|
187
|
+
* public/_assets/esbuild-${version}.js, both in the static-assets layer,
|
|
188
|
+
* fetched when the facet is loaded and verified by
|
|
189
|
+
* src/runtime/esbuild-wasm-bytes.ts. The host Worker bundles neither.
|
|
199
190
|
*
|
|
200
191
|
* The JS adapter is node_modules/esbuild-wasm/esm/browser.js with the
|
|
201
192
|
* trailing \`export { ... }\` rewritten to \`return { ... };\`, so that
|
|
@@ -226,13 +217,14 @@ export const ESBUILD_WASM_VERSION: string = ${JSON.stringify(version)};
|
|
|
226
217
|
* check, which discovers asset paths by value in generated modules.
|
|
227
218
|
*/
|
|
228
219
|
export const ESBUILD_JS_ASSET_PATH: string = ${JSON.stringify('/_assets/' + jsAssetName)};
|
|
229
|
-
/**
|
|
230
|
-
* Bytes of the esbuild.wasm the host bundles: what a facet carrying the
|
|
231
|
-
* host's compiled module counts toward the dynamic-worker code budget.
|
|
232
|
-
*/
|
|
233
|
-
export const ESBUILD_WASM_BYTES: number = ${wasmBytes.length};
|
|
234
220
|
/** SHA-256 of the staged public/_assets/esbuild-${version}.js adapter, checked before it is evaluated. */
|
|
235
221
|
export const ESBUILD_JS_SHA256: string = ${JSON.stringify(jsSha256)};
|
|
222
|
+
/** Where esbuild.wasm lives inside env.ASSETS, version-named like the adapter. */
|
|
223
|
+
export const ESBUILD_WASM_ASSET_PATH: string = ${JSON.stringify('/_assets/' + wasmAssetName)};
|
|
224
|
+
/** SHA-256 of the staged esbuild.wasm, checked before the facet compiles it. */
|
|
225
|
+
export const ESBUILD_WASM_SHA256: string = ${JSON.stringify(wasmSha256)};
|
|
226
|
+
/** Bytes of the staged esbuild.wasm: what the facet's module map counts toward the dynamic-worker code budget. */
|
|
227
|
+
export const ESBUILD_WASM_BYTES: number = ${wasmBytes.length};
|
|
236
228
|
`;
|
|
237
229
|
await fs.writeFile(OUT_TS, header, 'utf8');
|
|
238
230
|
const stat = await fs.stat(OUT_TS);
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
* globalThis.__nimbusVirtualSockets — python-runner and ruby-runner
|
|
24
24
|
* splice it into their socket process worker module sources.
|
|
25
25
|
*
|
|
26
|
+
* The answering supervisor client (@nimbus-sh/core
|
|
27
|
+
* src/runtime/vfs-supervisor.ts answeringSupervisor) is an IIFE the same
|
|
28
|
+
* way, installing globalThis.__nimbusAnsweringSupervisor for the node
|
|
29
|
+
* bodies, which are generated text and splice it.
|
|
30
|
+
*
|
|
26
31
|
* The WASI shim (src/runtime/wasi/preamble.ts) is bundled as a flat ESM
|
|
27
32
|
* body, NOT an IIFE: runners and tests append `export { __wasiInitFS, … }`
|
|
28
33
|
* to the emitted string and wasi-threads.ts is concatenated after it into
|
|
@@ -35,6 +40,8 @@
|
|
|
35
40
|
* W7_FRAME_PREAMBLE: string (W7 — streaming bulk-write encoder)
|
|
36
41
|
* @nimbus-sh/core src/runtime/virtual-socket-kernel.generated.ts — exports
|
|
37
42
|
* VIRTUAL_SOCKET_KERNEL_SRC: string
|
|
43
|
+
* @nimbus-sh/core src/runtime/supervisor-answering.generated.ts — exports
|
|
44
|
+
* SUPERVISOR_ANSWERING_SRC: string
|
|
38
45
|
* @nimbus-sh/core src/runtime/wasi-instance.generated.ts — exports
|
|
39
46
|
* WASI_INSTANCE_BODY_SRC: string
|
|
40
47
|
* @nimbus-sh/core src/runtime/bash-runner.generated.ts — exports
|
|
@@ -44,6 +51,11 @@
|
|
|
44
51
|
* asset rather than a string in the Worker bundle, like the esbuild
|
|
45
52
|
* adapter and the node shims; src/esbuild-cli-artifact.generated.ts
|
|
46
53
|
* exports ESBUILD_CLI_ASSET_PATH, ESBUILD_CLI_BUILD_ID, ESBUILD_CLI_SHA256.
|
|
54
|
+
* public/_assets/runtime/oxc-facet-<buildId>.js — the transform facet's
|
|
55
|
+
* runtime (the Oxc wasm's driver, the dynamic-import rewrite and the
|
|
56
|
+
* top-level-await lowering), staged the same way;
|
|
57
|
+
* src/oxc-facet-artifact.generated.ts exports OXC_FACET_ASSET_PATH,
|
|
58
|
+
* OXC_FACET_BUILD_ID, OXC_FACET_SHA256.
|
|
47
59
|
*
|
|
48
60
|
* Runs as a postinstall + predev + predeploy step via package.json.
|
|
49
61
|
*/
|
|
@@ -164,6 +176,36 @@ async function bundleVirtualSocketKernel() {
|
|
|
164
176
|
return withoutComments(result.outputFiles[0].text);
|
|
165
177
|
}
|
|
166
178
|
|
|
179
|
+
/**
|
|
180
|
+
* The answering supervisor client as a self-contained IIFE that installs
|
|
181
|
+
* globalThis.__nimbusAnsweringSupervisor, so a facet body that is generated
|
|
182
|
+
* text runs the one implementation the bundled facets import.
|
|
183
|
+
*/
|
|
184
|
+
async function bundleAnsweringSupervisor() {
|
|
185
|
+
const result = await build({
|
|
186
|
+
stdin: {
|
|
187
|
+
contents: [
|
|
188
|
+
"import { installAnsweringSupervisor } from './src/runtime/vfs-supervisor.ts';",
|
|
189
|
+
'installAnsweringSupervisor();',
|
|
190
|
+
].join('\n'),
|
|
191
|
+
resolveDir: coreRoot,
|
|
192
|
+
loader: 'ts',
|
|
193
|
+
},
|
|
194
|
+
bundle: true,
|
|
195
|
+
format: 'iife',
|
|
196
|
+
target: 'esnext',
|
|
197
|
+
platform: 'neutral',
|
|
198
|
+
absWorkingDir: root,
|
|
199
|
+
write: false,
|
|
200
|
+
logLevel: 'warning',
|
|
201
|
+
legalComments: 'none',
|
|
202
|
+
});
|
|
203
|
+
if (!result.outputFiles || result.outputFiles.length === 0) {
|
|
204
|
+
throw new Error('[bundle-facet-workers/supervisor-answering] esbuild produced no output');
|
|
205
|
+
}
|
|
206
|
+
return withoutComments(result.outputFiles[0].text);
|
|
207
|
+
}
|
|
208
|
+
|
|
167
209
|
/**
|
|
168
210
|
* Symbols the emitted WASI body must declare at top level. Runners and tests
|
|
169
211
|
* append `export { … }` to the string and wasi-threads is concatenated into the
|
|
@@ -347,46 +389,187 @@ async function bundleEsbuildCli() {
|
|
|
347
389
|
}
|
|
348
390
|
|
|
349
391
|
/**
|
|
350
|
-
* Stage
|
|
351
|
-
* prefix of its own digest so no cache layer can serve another
|
|
352
|
-
* under its name, and pin it in src
|
|
392
|
+
* Stage a runtime script under public/_assets/runtime/<prefix>-<build id>.js,
|
|
393
|
+
* named by a prefix of its own digest so no cache layer can serve another
|
|
394
|
+
* build's bytes under its name, and pin it in src/<generated>: exports
|
|
395
|
+
* <constant>_ASSET_PATH, <constant>_BUILD_ID (the content-hash prefix) and
|
|
396
|
+
* <constant>_SHA256 (the digest every fetch is verified against).
|
|
353
397
|
*/
|
|
354
|
-
function
|
|
398
|
+
function stageRuntimeSource(src, { prefix, generated, constant, description }) {
|
|
355
399
|
const sha256 = createHash('sha256').update(src, 'utf8').digest('hex');
|
|
356
400
|
const buildId = sha256.slice(0, 16);
|
|
357
401
|
const assetDir = join(root, 'public', '_assets', 'runtime');
|
|
358
|
-
const assetName =
|
|
402
|
+
const assetName = `${prefix}-${buildId}.js`;
|
|
359
403
|
mkdirSync(assetDir, { recursive: true });
|
|
360
404
|
for (const entry of readdirSync(assetDir)) {
|
|
361
|
-
if (entry.startsWith(
|
|
405
|
+
if (entry.startsWith(`${prefix}-`) && entry !== assetName) unlinkSync(join(assetDir, entry));
|
|
362
406
|
}
|
|
363
407
|
writeFileSync(join(assetDir, assetName), src, 'utf8');
|
|
364
408
|
const assetPath = `/_assets/runtime/${assetName}`;
|
|
365
|
-
const generatedPath = join(root, 'src',
|
|
409
|
+
const generatedPath = join(root, 'src', generated);
|
|
366
410
|
writeFileSync(generatedPath, [
|
|
367
411
|
'/**',
|
|
368
|
-
|
|
412
|
+
` * ${generated} — AUTO-GENERATED by`,
|
|
369
413
|
' * scripts/bundle-facet-workers.mjs. DO NOT EDIT.',
|
|
370
414
|
' *',
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
' * src/runtime/esbuild-cli/preamble.ts as an IIFE. Only the session\'s esbuild',
|
|
374
|
-
' * facet evaluates it, so src/runtime/esbuild-wasm-bytes.ts fetches it from',
|
|
375
|
-
' * ASSETS when that facet is built, instead of the Worker bundle carrying it.',
|
|
376
|
-
' * ESBUILD_CLI_BUILD_ID is a content-hash prefix, ESBUILD_CLI_SHA256 the',
|
|
415
|
+
...description.map((line) => ` * ${line}`),
|
|
416
|
+
` * ${constant}_BUILD_ID is a content-hash prefix, ${constant}_SHA256 the`,
|
|
377
417
|
' * digest every fetch is verified against.',
|
|
378
418
|
' *',
|
|
379
419
|
` * Size: ${(src.length / 1024).toFixed(2)} KiB`,
|
|
380
420
|
' */',
|
|
381
421
|
'',
|
|
382
|
-
`export const
|
|
383
|
-
`export const
|
|
384
|
-
`export const
|
|
422
|
+
`export const ${constant}_ASSET_PATH: string = ${JSON.stringify(assetPath)};`,
|
|
423
|
+
`export const ${constant}_BUILD_ID: string = ${JSON.stringify(buildId)};`,
|
|
424
|
+
`export const ${constant}_SHA256: string = ${JSON.stringify(sha256)};`,
|
|
385
425
|
'',
|
|
386
426
|
].join('\n'));
|
|
387
427
|
return { assetPath, generatedPath };
|
|
388
428
|
}
|
|
389
429
|
|
|
430
|
+
/** The esbuild CLI runner, staged (stageRuntimeSource). */
|
|
431
|
+
function stageEsbuildCli(src) {
|
|
432
|
+
return stageRuntimeSource(src, {
|
|
433
|
+
prefix: 'esbuild-cli',
|
|
434
|
+
generated: 'esbuild-cli-artifact.generated.ts',
|
|
435
|
+
constant: 'ESBUILD_CLI',
|
|
436
|
+
description: [
|
|
437
|
+
'Pins the staged runner of the `esbuild` command: esbuild-wasm/wasm_exec.js',
|
|
438
|
+
'(Go js/wasm glue, as __esbuildGoRuntime) followed by @nimbus-sh/core',
|
|
439
|
+
'src/runtime/esbuild-cli/preamble.ts as an IIFE. Only the session\'s esbuild',
|
|
440
|
+
'facet evaluates it, so src/runtime/esbuild-wasm-bytes.ts fetches it from',
|
|
441
|
+
'ASSETS when that facet is built, instead of the Worker bundle carrying it.',
|
|
442
|
+
],
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* The transform facet's runtime (core src/runtime/oxc-facet/preamble.ts) as
|
|
448
|
+
* an IIFE: the Oxc wasm's driver, the dynamic-import rewrite and the
|
|
449
|
+
* top-level-await lowering, installed as globals the facet's class reads.
|
|
450
|
+
*/
|
|
451
|
+
async function bundleOxcFacet() {
|
|
452
|
+
const result = await build({
|
|
453
|
+
entryPoints: [join(coreRoot, 'src', 'runtime', 'oxc-facet', 'preamble.ts')],
|
|
454
|
+
bundle: true,
|
|
455
|
+
format: 'iife',
|
|
456
|
+
target: 'esnext',
|
|
457
|
+
platform: 'neutral',
|
|
458
|
+
absWorkingDir: root,
|
|
459
|
+
write: false,
|
|
460
|
+
logLevel: 'warning',
|
|
461
|
+
legalComments: 'none',
|
|
462
|
+
});
|
|
463
|
+
if (!result.outputFiles || result.outputFiles.length === 0) {
|
|
464
|
+
throw new Error('[bundle-facet-workers/oxc-facet] esbuild produced no output');
|
|
465
|
+
}
|
|
466
|
+
const runtime = withoutComments(result.outputFiles[0].text);
|
|
467
|
+
for (const global of ['__nimbusCreateOxcTransform', '__nimbusRewriteDynamicImports', '__nimbusLowerAsyncModule']) {
|
|
468
|
+
if (!runtime.includes(global)) {
|
|
469
|
+
throw new Error(`[bundle-facet-workers/oxc-facet] the bundle no longer installs globalThis.${global}`);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (/^\s*(?:import|export)\b/m.test(runtime)) {
|
|
473
|
+
throw new Error('[bundle-facet-workers/oxc-facet] an import/export survived bundling');
|
|
474
|
+
}
|
|
475
|
+
return runtime;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* The build facet's runtime (scripts/rolldown-facet/entry.mjs) as an ES
|
|
480
|
+
* module: rolldown's JavaScript API, pinned to the staged binding's version,
|
|
481
|
+
* and core's esbuild-contract adapter (runtime/rolldown-build.ts). The Node
|
|
482
|
+
* modules rolldown imports and a facet has no use for are shims.mjs; node:path
|
|
483
|
+
* is workerd's. rolldown finds its binding at globalThis.__nimbusRolldownBinding,
|
|
484
|
+
* which the facet installs before it imports this module.
|
|
485
|
+
*/
|
|
486
|
+
async function bundleRolldownFacet() {
|
|
487
|
+
const shims = join(root, 'scripts', 'rolldown-facet', 'shims.mjs');
|
|
488
|
+
const rolldownPkg = JSON.parse(readFileSync(join(root, 'node_modules', 'rolldown', 'package.json'), 'utf8'));
|
|
489
|
+
const artifacts = readFileSync(join(root, 'src', 'napi-wasm-artifacts.generated.ts'), 'utf8');
|
|
490
|
+
const stagedVersion = /"name": "rolldown",\s*"version": "([^"]+)"/.exec(artifacts)?.[1];
|
|
491
|
+
if (rolldownPkg.version !== stagedVersion) {
|
|
492
|
+
throw new Error(`[bundle-facet-workers/rolldown-facet] rolldown ${rolldownPkg.version} is installed; the staged binding is ${stagedVersion}`);
|
|
493
|
+
}
|
|
494
|
+
const result = await build({
|
|
495
|
+
entryPoints: [join(root, 'scripts', 'rolldown-facet', 'entry.mjs')],
|
|
496
|
+
bundle: true,
|
|
497
|
+
format: 'esm',
|
|
498
|
+
target: 'esnext',
|
|
499
|
+
platform: 'neutral',
|
|
500
|
+
mainFields: ['module', 'main'],
|
|
501
|
+
conditions: ['import', 'default'],
|
|
502
|
+
absWorkingDir: root,
|
|
503
|
+
write: false,
|
|
504
|
+
logLevel: 'warning',
|
|
505
|
+
legalComments: 'none',
|
|
506
|
+
plugins: [{
|
|
507
|
+
name: 'rolldown-facet-shims',
|
|
508
|
+
setup(b) {
|
|
509
|
+
b.onResolve({ filter: /^node:path$/ }, () => ({ path: 'node:path', external: true }));
|
|
510
|
+
b.onResolve({ filter: /^node:(worker_threads|tty|os|util|module|fs|fs\/promises|process|url|readline|child_process)$/ }, () => ({ path: shims }));
|
|
511
|
+
// rolldown's binding loader (createRequire, native shards, WASI fallbacks): the facet's binding instead.
|
|
512
|
+
b.onResolve({ filter: /\/binding-[A-Za-z0-9_-]+\.mjs$/ }, (args) => ({ path: args.path, namespace: 'rolldown-binding' }));
|
|
513
|
+
b.onLoad({ filter: /.*/, namespace: 'rolldown-binding' }, () => ({
|
|
514
|
+
contents: [
|
|
515
|
+
'export const t = () => {',
|
|
516
|
+
' const binding = globalThis.__nimbusRolldownBinding;',
|
|
517
|
+
' if (!binding) throw new Error("Nimbus: the build facet imported rolldown before installing its binding");',
|
|
518
|
+
' return binding;',
|
|
519
|
+
'};',
|
|
520
|
+
'export const n = (mod) => mod;',
|
|
521
|
+
].join('\n'),
|
|
522
|
+
loader: 'js',
|
|
523
|
+
}));
|
|
524
|
+
},
|
|
525
|
+
}],
|
|
526
|
+
});
|
|
527
|
+
if (!result.outputFiles || result.outputFiles.length === 0) {
|
|
528
|
+
throw new Error('[bundle-facet-workers/rolldown-facet] esbuild produced no output');
|
|
529
|
+
}
|
|
530
|
+
const runtime = result.outputFiles[0].text;
|
|
531
|
+
const imports = [...runtime.matchAll(/^import\b[^'"]*['"]([^'"]+)['"]/gm)].map((m) => m[1]);
|
|
532
|
+
if (imports.some((specifier) => specifier !== 'node:path')) {
|
|
533
|
+
throw new Error(`[bundle-facet-workers/rolldown-facet] the runtime imports ${imports.join(', ')}; only node:path is allowed`);
|
|
534
|
+
}
|
|
535
|
+
for (const name of ['build', 'prebundle']) {
|
|
536
|
+
if (!new RegExp(`export\\s*\\{[^}]*\\b${name}\\b`).test(runtime)) throw new Error(`[bundle-facet-workers/rolldown-facet] the runtime no longer exports ${name}`);
|
|
537
|
+
}
|
|
538
|
+
return runtime;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/** The build facet's runtime, staged (stageRuntimeSource). */
|
|
542
|
+
function stageRolldownFacet(src) {
|
|
543
|
+
return stageRuntimeSource(src, {
|
|
544
|
+
prefix: 'rolldown-facet',
|
|
545
|
+
generated: 'rolldown-facet-artifact.generated.ts',
|
|
546
|
+
constant: 'ROLLDOWN_FACET',
|
|
547
|
+
description: [
|
|
548
|
+
'Pins the staged runtime of the build facet: scripts/rolldown-facet/entry.mjs',
|
|
549
|
+
'as an ES module (rolldown\'s JavaScript API over the staged threadless',
|
|
550
|
+
'binding, and @nimbus-sh/core runtime/rolldown-build.ts). Only the build',
|
|
551
|
+
'facet imports it, so facets/build-facet.ts fetches it from ASSETS when',
|
|
552
|
+
'that facet is built.',
|
|
553
|
+
],
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/** The transform facet's runtime, staged (stageRuntimeSource). */
|
|
558
|
+
function stageOxcFacet(src) {
|
|
559
|
+
return stageRuntimeSource(src, {
|
|
560
|
+
prefix: 'oxc-facet',
|
|
561
|
+
generated: 'oxc-facet-artifact.generated.ts',
|
|
562
|
+
constant: 'OXC_FACET',
|
|
563
|
+
description: [
|
|
564
|
+
'Pins the staged runtime of the transform facet: @nimbus-sh/core',
|
|
565
|
+
'src/runtime/oxc-facet/preamble.ts as an IIFE (the Oxc wasm\'s driver, the',
|
|
566
|
+
'dynamic-import rewrite and the top-level-await lowering). Only the',
|
|
567
|
+
'transform facet evaluates it, so src/runtime/oxc-wasm-bytes.ts fetches it',
|
|
568
|
+
'from ASSETS when that facet is built.',
|
|
569
|
+
],
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
|
|
390
573
|
async function main() {
|
|
391
574
|
// 1. Tar-parser preamble (existing W2.5/W4 hot-path helpers).
|
|
392
575
|
const tarStripped = await bundleAsPreamble(
|
|
@@ -417,6 +600,16 @@ async function main() {
|
|
|
417
600
|
throw new Error('[bundle-facet-workers/esm-resolver] the bundle no longer declares function createEsmResolver');
|
|
418
601
|
}
|
|
419
602
|
|
|
603
|
+
// 4. node:http2, which the node shims embed as source, as the substrate's
|
|
604
|
+
// node-compat module map imports it: one module, both runtimes.
|
|
605
|
+
const http2Module = await bundleAsPreamble(
|
|
606
|
+
join(coreRoot, 'src', '_shared', 'http2-module.ts'),
|
|
607
|
+
'http2-module',
|
|
608
|
+
);
|
|
609
|
+
if (!/^function createHttp2Module\(/m.test(http2Module)) {
|
|
610
|
+
throw new Error('[bundle-facet-workers/http2-module] the bundle no longer declares function createHttp2Module');
|
|
611
|
+
}
|
|
612
|
+
|
|
420
613
|
const tarEncoded = JSON.stringify(tarStripped);
|
|
421
614
|
const w7Encoded = JSON.stringify(w7Stripped);
|
|
422
615
|
const outPath = join(root, 'src', 'loaders', 'generated-workers.ts');
|
|
@@ -429,6 +622,7 @@ async function main() {
|
|
|
429
622
|
' * - @nimbus-sh/core src/_shared/tarball-stream.ts (streaming tar primitives)',
|
|
430
623
|
' * - @nimbus-sh/platform src/w7-frame.ts (W7 streaming bulk-write encoder)',
|
|
431
624
|
' * - @nimbus-sh/core src/_shared/esm-resolver.ts (Node\'s ESM resolver, for the node shims)',
|
|
625
|
+
' * - @nimbus-sh/core src/_shared/http2-module.ts (node:http2, for the node shims)',
|
|
432
626
|
' *',
|
|
433
627
|
' * Consumed by fabric/isolate-pool.ts callers via the `preamble`',
|
|
434
628
|
' * option. The preamble is injected at the top of every generated',
|
|
@@ -451,6 +645,9 @@ async function main() {
|
|
|
451
645
|
'/** Declares `function createEsmResolver(host)`; the node shims call it. */',
|
|
452
646
|
`export const ESM_RESOLVER_PREAMBLE: string = ${JSON.stringify(esmResolver)};`,
|
|
453
647
|
'',
|
|
648
|
+
'/** Declares `function createHttp2Module(host)`; the node shims call it. */',
|
|
649
|
+
`export const HTTP2_MODULE_PREAMBLE: string = ${JSON.stringify(http2Module)};`,
|
|
650
|
+
'',
|
|
454
651
|
].join('\n');
|
|
455
652
|
|
|
456
653
|
mkdirSync(dirname(outPath), { recursive: true });
|
|
@@ -477,6 +674,26 @@ async function main() {
|
|
|
477
674
|
].join('\n');
|
|
478
675
|
writeFileSync(kernelOutPath, kernelWrapper);
|
|
479
676
|
|
|
677
|
+
const answeringSrc = await bundleAnsweringSupervisor();
|
|
678
|
+
const answeringOutPath = join(coreRoot, 'src', 'runtime', 'supervisor-answering.generated.ts');
|
|
679
|
+
writeFileSync(answeringOutPath, [
|
|
680
|
+
'/**',
|
|
681
|
+
' * supervisor-answering.generated.ts — AUTO-GENERATED. DO NOT EDIT.',
|
|
682
|
+
' *',
|
|
683
|
+
' * Produced by scripts/bundle-facet-workers.mjs from:',
|
|
684
|
+
' * - @nimbus-sh/core src/runtime/vfs-supervisor.ts (answeringSupervisor)',
|
|
685
|
+
' *',
|
|
686
|
+
' * Self-contained IIFE that installs globalThis.__nimbusAnsweringSupervisor.',
|
|
687
|
+
' * Spliced into the node facet bodies (worker facets/manager.ts) and the',
|
|
688
|
+
' * opencode runner, which wrap their SUPERVISOR binding with it.',
|
|
689
|
+
' *',
|
|
690
|
+
` * Size: ${(answeringSrc.length / 1024).toFixed(2)} KiB`,
|
|
691
|
+
' */',
|
|
692
|
+
'',
|
|
693
|
+
`export const SUPERVISOR_ANSWERING_SRC: string = ${JSON.stringify(answeringSrc)};`,
|
|
694
|
+
'',
|
|
695
|
+
].join('\n'));
|
|
696
|
+
|
|
480
697
|
console.log(
|
|
481
698
|
`[bundle-facet-workers] wrote ${outPath} ` +
|
|
482
699
|
`(tar=${(tarStripped.length / 1024).toFixed(2)} KiB, ` +
|
|
@@ -524,6 +741,10 @@ async function main() {
|
|
|
524
741
|
|
|
525
742
|
const esbuildCliSrc = await bundleEsbuildCli();
|
|
526
743
|
const esbuildCli = stageEsbuildCli(esbuildCliSrc);
|
|
744
|
+
const oxcFacetSrc = await bundleOxcFacet();
|
|
745
|
+
const oxcFacet = stageOxcFacet(oxcFacetSrc);
|
|
746
|
+
const rolldownFacetSrc = await bundleRolldownFacet();
|
|
747
|
+
const rolldownFacet = stageRolldownFacet(rolldownFacetSrc);
|
|
527
748
|
|
|
528
749
|
console.log(
|
|
529
750
|
`[bundle-facet-workers] wrote ${kernelOutPath} ` +
|
|
@@ -541,13 +762,21 @@ async function main() {
|
|
|
541
762
|
`[bundle-facet-workers] staged ${esbuildCli.assetPath} and wrote ${esbuildCli.generatedPath} ` +
|
|
542
763
|
`(esbuild-cli=${(esbuildCliSrc.length / 1024).toFixed(2)} KiB)`,
|
|
543
764
|
);
|
|
765
|
+
console.log(
|
|
766
|
+
`[bundle-facet-workers] staged ${oxcFacet.assetPath} and wrote ${oxcFacet.generatedPath} ` +
|
|
767
|
+
`(oxc-facet=${(oxcFacetSrc.length / 1024).toFixed(2)} KiB)`,
|
|
768
|
+
);
|
|
769
|
+
console.log(
|
|
770
|
+
`[bundle-facet-workers] staged ${rolldownFacet.assetPath} and wrote ${rolldownFacet.generatedPath} ` +
|
|
771
|
+
`(rolldown-facet=${(rolldownFacetSrc.length / 1024).toFixed(2)} KiB)`,
|
|
772
|
+
);
|
|
544
773
|
}
|
|
545
774
|
|
|
546
775
|
// The bundle functions are exported so the parity test can re-derive the
|
|
547
776
|
// generated files from source and compare, rather than restating the esbuild
|
|
548
777
|
// settings — a second copy of those settings is exactly the drift such a test
|
|
549
778
|
// exists to catch. main() therefore runs only when this file is the entry point.
|
|
550
|
-
export { bundleWasiInstance, bundleBashRunner, bundleEsbuildCli };
|
|
779
|
+
export { bundleWasiInstance, bundleBashRunner, bundleEsbuildCli, bundleOxcFacet, bundleAnsweringSupervisor };
|
|
551
780
|
|
|
552
781
|
if (process.argv[1] && pathToFileURL(process.argv[1]).href === import.meta.url) {
|
|
553
782
|
main().catch((e) => {
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
* the write ledger the shims' filesystem writes go through;
|
|
13
13
|
* - `FACET_RESIDENT_STORE_SOURCE` (src/vfs/facet-resident-store.ts), a
|
|
14
14
|
* resident facet's SQLite-backed resident set the shims read from.
|
|
15
|
+
* and carries two more as modules of its map: the runtime-code interpreter
|
|
16
|
+
* and its host module (scripts/interpreter-bundle.mjs), which a launch
|
|
17
|
+
* compiles only when its program first produces code no launch staged.
|
|
15
18
|
* Keeping them inside the worker bundle pushed the main bundle over its size
|
|
16
19
|
* gate (tests/behavioral/assets-fetch/new/worker-bundle-size.mjs), whose
|
|
17
20
|
* intended fix is exactly this promote: large facet-runner source strings
|
|
@@ -28,6 +31,8 @@
|
|
|
28
31
|
* public/_assets/runtime/node-shims-<buildId>.js
|
|
29
32
|
* public/_assets/runtime/vfs-write-ledger-<buildId>.js
|
|
30
33
|
* public/_assets/runtime/resident-store-<buildId>.js
|
|
34
|
+
* public/_assets/runtime/js-interpreter-<buildId>.js
|
|
35
|
+
* public/_assets/runtime/js-interpreter-ops-<buildId>.js
|
|
31
36
|
* src/node-shims-artifact.generated.ts, per source:
|
|
32
37
|
* export const <NAME>_ENTRY: string; // asset path
|
|
33
38
|
* export const <NAME>_BUILD_ID: string; // content-hash prefix
|
|
@@ -51,6 +56,8 @@ const ROOT = path.resolve(__dirname, '..');
|
|
|
51
56
|
const { generateShimsCode } = await import(path.join(ROOT, 'dist/runtime/node-shims.js'));
|
|
52
57
|
const { FACET_RESIDENT_STORE_SOURCE } = await import(path.join(ROOT, 'dist/vfs/facet-resident-store.js'));
|
|
53
58
|
const { VFS_WRITE_LEDGER_SOURCE } = await import('@nimbus-sh/core/_shared/vfs-write-ledger.js');
|
|
59
|
+
const { bundleInterpreter } = await import('./interpreter-bundle.mjs');
|
|
60
|
+
const interpreter = await bundleInterpreter({ start: ROOT });
|
|
54
61
|
|
|
55
62
|
const shims = generateShimsCode();
|
|
56
63
|
if (typeof shims !== 'string' || shims.length < 100_000) {
|
|
@@ -75,6 +82,24 @@ const SOURCES = [
|
|
|
75
82
|
source: FACET_RESIDENT_STORE_SOURCE,
|
|
76
83
|
from: 'dist/vfs/facet-resident-store.js FACET_RESIDENT_STORE_SOURCE',
|
|
77
84
|
},
|
|
85
|
+
{
|
|
86
|
+
name: 'JS_INTERPRETER_PRIMORDIALS',
|
|
87
|
+
family: 'js-interpreter-primordials',
|
|
88
|
+
source: interpreter.primordials,
|
|
89
|
+
from: '@nimbus-sh/core src/interpreter/primordials.ts, bundled by scripts/interpreter-bundle.mjs',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'JS_INTERPRETER',
|
|
93
|
+
family: 'js-interpreter',
|
|
94
|
+
source: interpreter.interpreter,
|
|
95
|
+
from: '@nimbus-sh/core src/interpreter, bundled by scripts/interpreter-bundle.mjs',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'JS_INTERPRETER_OPS',
|
|
99
|
+
family: 'js-interpreter-ops',
|
|
100
|
+
source: interpreter.ops,
|
|
101
|
+
from: '@nimbus-sh/core src/interpreter/host-ops.ts HOST_OPS_SOURCE',
|
|
102
|
+
},
|
|
78
103
|
];
|
|
79
104
|
|
|
80
105
|
const assetDir = path.join(ROOT, 'public/_assets/runtime');
|
|
@@ -90,8 +115,9 @@ for (const { name, family, source, from } of SOURCES) {
|
|
|
90
115
|
const assetName = `${family}-${buildId}.js`;
|
|
91
116
|
// Remove stale same-family assets so the directory carries exactly one blob
|
|
92
117
|
// per family (the entry constant pins which one a deploy serves).
|
|
118
|
+
const isFamily = (f) => /^[0-9a-f]{16}\.js$/.test(f.slice(family.length + 1)) && f.startsWith(`${family}-`);
|
|
93
119
|
for (const f of existing) {
|
|
94
|
-
if (f
|
|
120
|
+
if (isFamily(f) && f !== assetName) await fs.unlink(path.join(assetDir, f));
|
|
95
121
|
}
|
|
96
122
|
await fs.writeFile(path.join(assetDir, assetName), source, 'utf8');
|
|
97
123
|
pins.push(
|
|
@@ -109,7 +135,8 @@ const generated = `/**
|
|
|
109
135
|
* scripts/bundle-node-shims.mjs. DO NOT EDIT.
|
|
110
136
|
*
|
|
111
137
|
* Pins the staged sources of the node-compat layer, promoted out of the worker
|
|
112
|
-
* bundle: the shims, the VFS write ledger
|
|
138
|
+
* bundle: the shims, the VFS write ledger, the resident store, and the
|
|
139
|
+
* runtime-code interpreter with its host module. Each
|
|
113
140
|
* <NAME>_BUILD_ID is a content-hash prefix so cache layers never serve stale
|
|
114
141
|
* bytes after a rebuild; <NAME>_SHA256 is the full digest verified at fetch time.
|
|
115
142
|
*/
|