@nimbus-sh/worker 0.12.0 → 0.13.1
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 +7 -5
- 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
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { PRE_BUNDLE_CONCURRENCY } from '@nimbus-sh/platform/limits.js';
|
|
2
|
-
function hasAssetsFetcher(env) {
|
|
3
|
-
if (typeof env !== 'object' || env === null)
|
|
4
|
-
return false;
|
|
5
|
-
const assets = Reflect.get(env, 'ASSETS');
|
|
6
|
-
return typeof assets === 'object' && assets !== null && typeof Reflect.get(assets, 'fetch') === 'function';
|
|
7
|
-
}
|
|
8
|
-
export class EsbuildBundlePool {
|
|
9
|
-
env;
|
|
10
|
-
ctx;
|
|
11
|
-
pool = null;
|
|
12
|
-
pending = null;
|
|
13
|
-
/** Bumped by dispose() so a construction it interrupted tears itself down. */
|
|
14
|
-
generation = 0;
|
|
15
|
-
constructor(env, ctx) {
|
|
16
|
-
this.env = env;
|
|
17
|
-
this.ctx = ctx;
|
|
18
|
-
}
|
|
19
|
-
acquire() {
|
|
20
|
-
if (this.pool)
|
|
21
|
-
return Promise.resolve(this.pool);
|
|
22
|
-
if (this.pending)
|
|
23
|
-
return this.pending;
|
|
24
|
-
const generation = this.generation;
|
|
25
|
-
const pending = this.construct().then((pool) => {
|
|
26
|
-
if (this.generation !== generation) {
|
|
27
|
-
// dispose() ran while the adapter was in flight.
|
|
28
|
-
try {
|
|
29
|
-
pool.dispose();
|
|
30
|
-
}
|
|
31
|
-
catch { /* best-effort */ }
|
|
32
|
-
throw new Error('EsbuildBundlePool: disposed during construction');
|
|
33
|
-
}
|
|
34
|
-
this.pool = pool;
|
|
35
|
-
return pool;
|
|
36
|
-
}).finally(() => {
|
|
37
|
-
if (this.pending === pending)
|
|
38
|
-
this.pending = null;
|
|
39
|
-
});
|
|
40
|
-
this.pending = pending;
|
|
41
|
-
return pending;
|
|
42
|
-
}
|
|
43
|
-
async construct() {
|
|
44
|
-
if (!hasAssetsFetcher(this.env)) {
|
|
45
|
-
throw new Error('EsbuildBundlePool: env.ASSETS binding missing — the esbuild JS adapter cannot be fetched');
|
|
46
|
-
}
|
|
47
|
-
const env = this.env;
|
|
48
|
-
const [{ IsolatePool }, { preBundlePreamble }, { fetchEsbuildJsFnBody }, { esbuildWasmModule }] = await Promise.all([
|
|
49
|
-
import('@nimbus-sh/fabric/isolate-pool.js'),
|
|
50
|
-
import('../loaders/pre-bundle-preamble.js'),
|
|
51
|
-
import('../runtime/esbuild-wasm-bytes.js'),
|
|
52
|
-
import('../runtime/host-wasm.js'),
|
|
53
|
-
]);
|
|
54
|
-
const [wasmModule, jsFnBody] = await Promise.all([esbuildWasmModule(), fetchEsbuildJsFnBody(env)]);
|
|
55
|
-
return new IsolatePool(env, this.ctx, {
|
|
56
|
-
concurrency: PRE_BUNDLE_CONCURRENCY,
|
|
57
|
-
timeoutMs: 60_000,
|
|
58
|
-
retries: 0,
|
|
59
|
-
tag: 'esbuild-bundle',
|
|
60
|
-
preamble: preBundlePreamble(jsFnBody),
|
|
61
|
-
wasmModules: { 'esbuild.wasm': wasmModule },
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Tear the pool down with its host. A later acquire() constructs a fresh
|
|
66
|
-
* pool, so a session that installs again after a teardown still bundles.
|
|
67
|
-
*/
|
|
68
|
-
dispose() {
|
|
69
|
-
this.generation++;
|
|
70
|
-
const pool = this.pool;
|
|
71
|
-
this.pool = null;
|
|
72
|
-
this.pending = null;
|
|
73
|
-
if (pool) {
|
|
74
|
-
try {
|
|
75
|
-
pool.dispose();
|
|
76
|
-
}
|
|
77
|
-
catch { /* best-effort */ }
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* pre-bundle-preamble.ts — preamble injected into IsolatePool isolates
|
|
3
|
-
* that run src/pre-bundle-facet.ts.
|
|
4
|
-
*
|
|
5
|
-
* IsolatePool serialises the user function via fn.toString() and runs
|
|
6
|
-
* it inside a dynamic worker built from inline modules. Names referenced
|
|
7
|
-
* by the function at the module-top-level scope are NOT in that worker's
|
|
8
|
-
* lexical scope at runtime — they must be re-declared in the preamble.
|
|
9
|
-
*
|
|
10
|
-
* Specifically prebundleOne references:
|
|
11
|
-
* - ESBUILD_WASM_JS_FN_BODY — function-body string (~117 KiB) that,
|
|
12
|
-
* when run via new Function(...)(), returns
|
|
13
|
-
* the esbuild namespace. Staged beside the
|
|
14
|
-
* wasm and fetched by the supervisor at
|
|
15
|
-
* pool construction (fetchEsbuildJsFnBody),
|
|
16
|
-
* then spliced in here.
|
|
17
|
-
* - resolvePackageEntry — the npm-resolver helper used by the
|
|
18
|
-
* bare-specifier resolver
|
|
19
|
-
*
|
|
20
|
-
* NOT in the preamble:
|
|
21
|
-
* - ESBUILD_WASM_BASE64 / wasm BYTES — the wasm Module is shipped via
|
|
22
|
-
* IsolatePool's `wasmModules` option (LOADER `modules` map
|
|
23
|
-
* entry shape `{ wasm: ArrayBuffer }`). Workerd compiles it at
|
|
24
|
-
* module-load (startup phase) and the pool's generated worker.js
|
|
25
|
-
* exposes the resulting WebAssembly.Module on
|
|
26
|
-
* globalThis.__NIMBUS_WASM['esbuild.wasm']. The pre-bundle facet
|
|
27
|
-
* reads it at request time and passes to esb.initialize().
|
|
28
|
-
*
|
|
29
|
-
* resolvePackageEntry is a pure-JS function from src/_shared/exports-resolver.ts;
|
|
30
|
-
* we inline its source here so the facet doesn't need to fault back
|
|
31
|
-
* to the supervisor for it.
|
|
32
|
-
*
|
|
33
|
-
* Preamble bytes are part of the loader-cache key for IsolatePool.
|
|
34
|
-
* Changing this file invalidates all warm slots in the pre-bundle pool;
|
|
35
|
-
* fine — esbuild boot is the dominant cost and re-paying it once on a
|
|
36
|
-
* deploy is acceptable.
|
|
37
|
-
*/
|
|
38
|
-
/**
|
|
39
|
-
* Preamble string injected ahead of the prebundleOne function in every
|
|
40
|
-
* pre-bundle facet isolate. Must be passed via IsolatePool's
|
|
41
|
-
* `preamble` option. `jsFnBody` is the staged esbuild adapter.
|
|
42
|
-
*/
|
|
43
|
-
export declare function preBundlePreamble(jsFnBody: string): string;
|
|
44
|
-
//# sourceMappingURL=pre-bundle-preamble.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pre-bundle-preamble.d.ts","sourceRoot":"","sources":["../../src/loaders/pre-bundle-preamble.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAsCH;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAuC1D"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* pre-bundle-preamble.ts — preamble injected into IsolatePool isolates
|
|
3
|
-
* that run src/pre-bundle-facet.ts.
|
|
4
|
-
*
|
|
5
|
-
* IsolatePool serialises the user function via fn.toString() and runs
|
|
6
|
-
* it inside a dynamic worker built from inline modules. Names referenced
|
|
7
|
-
* by the function at the module-top-level scope are NOT in that worker's
|
|
8
|
-
* lexical scope at runtime — they must be re-declared in the preamble.
|
|
9
|
-
*
|
|
10
|
-
* Specifically prebundleOne references:
|
|
11
|
-
* - ESBUILD_WASM_JS_FN_BODY — function-body string (~117 KiB) that,
|
|
12
|
-
* when run via new Function(...)(), returns
|
|
13
|
-
* the esbuild namespace. Staged beside the
|
|
14
|
-
* wasm and fetched by the supervisor at
|
|
15
|
-
* pool construction (fetchEsbuildJsFnBody),
|
|
16
|
-
* then spliced in here.
|
|
17
|
-
* - resolvePackageEntry — the npm-resolver helper used by the
|
|
18
|
-
* bare-specifier resolver
|
|
19
|
-
*
|
|
20
|
-
* NOT in the preamble:
|
|
21
|
-
* - ESBUILD_WASM_BASE64 / wasm BYTES — the wasm Module is shipped via
|
|
22
|
-
* IsolatePool's `wasmModules` option (LOADER `modules` map
|
|
23
|
-
* entry shape `{ wasm: ArrayBuffer }`). Workerd compiles it at
|
|
24
|
-
* module-load (startup phase) and the pool's generated worker.js
|
|
25
|
-
* exposes the resulting WebAssembly.Module on
|
|
26
|
-
* globalThis.__NIMBUS_WASM['esbuild.wasm']. The pre-bundle facet
|
|
27
|
-
* reads it at request time and passes to esb.initialize().
|
|
28
|
-
*
|
|
29
|
-
* resolvePackageEntry is a pure-JS function from src/_shared/exports-resolver.ts;
|
|
30
|
-
* we inline its source here so the facet doesn't need to fault back
|
|
31
|
-
* to the supervisor for it.
|
|
32
|
-
*
|
|
33
|
-
* Preamble bytes are part of the loader-cache key for IsolatePool.
|
|
34
|
-
* Changing this file invalidates all warm slots in the pre-bundle pool;
|
|
35
|
-
* fine — esbuild boot is the dominant cost and re-paying it once on a
|
|
36
|
-
* deploy is acceptable.
|
|
37
|
-
*/
|
|
38
|
-
import { ESBUILD_WASM_VERSION } from '../esbuild-wasm-bundle.generated.js';
|
|
39
|
-
import { getExportsResolverJS } from '@nimbus-sh/core/_shared/exports-resolver.js';
|
|
40
|
-
// NOTE: wasm BYTES deliberately NOT in this preamble. They live in
|
|
41
|
-
// env.ASSETS at /_assets/esbuild-<version>.wasm and are fetched by
|
|
42
|
-
// the supervisor at pool-construction time
|
|
43
|
-
// (src/esbuild-wasm-bytes.ts), then handed to IsolatePool's
|
|
44
|
-
// `wasmModules` option which registers them in the LOADER `modules`
|
|
45
|
-
// map as `{ wasm: ArrayBuffer }`. workerd compiles during the
|
|
46
|
-
// worker's module-load phase (where wasm code generation is
|
|
47
|
-
// permitted) and exposes the resulting WebAssembly.Module via the
|
|
48
|
-
// standard ESM import the pool prepends to worker.js.
|
|
49
|
-
//
|
|
50
|
-
// Earlier approaches that DIDN'T work (history kept for context):
|
|
51
|
-
// 1. Inline the ~16 MiB base64 in this preamble — workerd allocates
|
|
52
|
-
// a 16 MiB module-source string per pool.submit dispatch which
|
|
53
|
-
// combined with post-install supervisor heap state OOM-killed
|
|
54
|
-
// the DO on entry to the pre-bundle phase (verified on prod).
|
|
55
|
-
// 2. WebAssembly.compile() in the facet at request time — workerd's
|
|
56
|
-
// deployed config disallows wasm code generation at request time
|
|
57
|
-
// ("Wasm code generation disallowed by embedder").
|
|
58
|
-
// 3. RPC of a pre-compiled WebAssembly.Module from supervisor —
|
|
59
|
-
// workerd's structured-clone refuses Module transfer in this
|
|
60
|
-
// deploy ("Unable to deserialize cloned data").
|
|
61
|
-
//
|
|
62
|
-
// Phase 2 A'.5 also moved the bytes OUT of the supervisor module
|
|
63
|
-
// bundle (was a 16 MiB base64 string in the generated TS file → 21
|
|
64
|
-
// MiB UTF-16 in supervisor module scope). Now they only live where
|
|
65
|
-
// they're needed: in the LOADER cache after pool construction, and
|
|
66
|
-
// in env.ASSETS at rest.
|
|
67
|
-
/**
|
|
68
|
-
* Resolver helpers, sourced from src/_shared/exports-resolver.ts via
|
|
69
|
-
* getExportsResolverJS(). The pre-bundle facet uses `resolvePackageEntry`.
|
|
70
|
-
*/
|
|
71
|
-
const RESOLVER_HELPERS_SRC = getExportsResolverJS();
|
|
72
|
-
/**
|
|
73
|
-
* Preamble string injected ahead of the prebundleOne function in every
|
|
74
|
-
* pre-bundle facet isolate. Must be passed via IsolatePool's
|
|
75
|
-
* `preamble` option. `jsFnBody` is the staged esbuild adapter.
|
|
76
|
-
*/
|
|
77
|
-
export function preBundlePreamble(jsFnBody) {
|
|
78
|
-
return `
|
|
79
|
-
// ── pre-bundle facet preamble (auto-generated) ──────────────────────────
|
|
80
|
-
// Esbuild JS helpers (small ~117 KiB). The wasm BYTES are NOT here —
|
|
81
|
-
// they ride IsolatePool's wasmModules option to keep the per-dispatch
|
|
82
|
-
// worker module source under ~120 KiB instead of ~16 MiB. See this
|
|
83
|
-
// file's header for why.
|
|
84
|
-
const ESBUILD_WASM_VERSION = ${JSON.stringify(ESBUILD_WASM_VERSION)};
|
|
85
|
-
const ESBUILD_WASM_JS_FN_BODY = ${JSON.stringify(jsFnBody)};
|
|
86
|
-
|
|
87
|
-
// ── Materialise esbuild namespace at MODULE STARTUP ─────────────────────
|
|
88
|
-
// workerd's deployed config disallows \"Code generation from strings\" at
|
|
89
|
-
// request time inside dynamic workers (verified via prod repro: pre-bundle
|
|
90
|
-
// fn body called \`new Function(jsBody)()\` and got
|
|
91
|
-
// \"Code generation from strings disallowed for this context\" for every
|
|
92
|
-
// spec). The codebase already documents this constraint at
|
|
93
|
-
// src/runtime/node-shims.ts.
|
|
94
|
-
//
|
|
95
|
-
// Workaround: run \`new Function(...)()\` here in the preamble — preambles
|
|
96
|
-
// execute at module-load time (the worker's startup phase) where eval IS
|
|
97
|
-
// permitted. We capture the resulting esbuild namespace in a module-scope
|
|
98
|
-
// const that the user fn references at request time. Same pattern as
|
|
99
|
-
// src/facets/manager.ts (USER_CODE is compiled in the generated module
|
|
100
|
-
// scope, not inside the request handler).
|
|
101
|
-
//
|
|
102
|
-
// Fail-safe: if even startup-time eval is blocked, set the cache to a
|
|
103
|
-
// sentinel object that the user fn detects and surfaces as a loud error
|
|
104
|
-
// (rather than passing undefined and crashing on .initialize).
|
|
105
|
-
let __NIMBUS_ESBUILD_NS = null;
|
|
106
|
-
let __NIMBUS_ESBUILD_INIT_ERR = null;
|
|
107
|
-
try {
|
|
108
|
-
__NIMBUS_ESBUILD_NS = (new Function(ESBUILD_WASM_JS_FN_BODY))();
|
|
109
|
-
} catch (e) {
|
|
110
|
-
__NIMBUS_ESBUILD_INIT_ERR = String((e && e.message) || e);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
${RESOLVER_HELPERS_SRC}
|
|
114
|
-
// ── end pre-bundle facet preamble ───────────────────────────────────────
|
|
115
|
-
`;
|
|
116
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* esbuild's wasm, the module core's EsbuildService initializes from. Imported
|
|
3
|
-
* on first use, like core's own import of it: outside a wrangler bundle (bun,
|
|
4
|
-
* node) the specifier does not resolve to a module, and a static import would
|
|
5
|
-
* fail every importer there.
|
|
6
|
-
*/
|
|
7
|
-
export declare function esbuildWasmModule(): Promise<WebAssembly.Module>;
|
|
8
|
-
//# sourceMappingURL=host-wasm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host-wasm.d.ts","sourceRoot":"","sources":["../../src/runtime/host-wasm.ts"],"names":[],"mappings":"AAmBA;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAW/D"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* host-wasm.ts — the WebAssembly modules this Worker bundles, handed to
|
|
3
|
-
* dynamic workers compiled.
|
|
4
|
-
*
|
|
5
|
-
* wrangler bundles a `.wasm` import as a compiled module, and workerd
|
|
6
|
-
* compiles it once, at script startup, in every isolate of the script
|
|
7
|
-
* (https://developers.cloudflare.com/workers/wrangler/bundling/). A Worker
|
|
8
|
-
* Loader module map accepts that WebAssembly.Module as a member and the
|
|
9
|
-
* dynamic worker shares its compiled code (workerd src/workerd/api/
|
|
10
|
-
* worker-loader.c++, extractWasmModuleContent), so a facet built on it
|
|
11
|
-
* needs no second copy of the bytes, no fetch of them, and no compile.
|
|
12
|
-
* Each module is described (@nimbus-sh/fabric/host-wasm.js) with its wire
|
|
13
|
-
* size, which still counts toward the 64 MiB dynamic-worker code limit.
|
|
14
|
-
*/
|
|
15
|
-
import { describeHostWasm } from '@nimbus-sh/fabric/host-wasm.js';
|
|
16
|
-
import { ESBUILD_WASM_BYTES, ESBUILD_WASM_VERSION } from '../esbuild-wasm-bundle.generated.js';
|
|
17
|
-
let esbuild = null;
|
|
18
|
-
/**
|
|
19
|
-
* esbuild's wasm, the module core's EsbuildService initializes from. Imported
|
|
20
|
-
* on first use, like core's own import of it: outside a wrangler bundle (bun,
|
|
21
|
-
* node) the specifier does not resolve to a module, and a static import would
|
|
22
|
-
* fail every importer there.
|
|
23
|
-
*/
|
|
24
|
-
export function esbuildWasmModule() {
|
|
25
|
-
esbuild ??= import('esbuild-wasm/esbuild.wasm').then(({ default: module }) => {
|
|
26
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
27
|
-
throw new Error('esbuild-wasm/esbuild.wasm did not import as a WebAssembly.Module; '
|
|
28
|
-
+ 'the Worker must be bundled by wrangler, which compiles it at startup');
|
|
29
|
-
}
|
|
30
|
-
return describeHostWasm(module, { id: `esbuild-wasm@${ESBUILD_WASM_VERSION}`, bytes: ESBUILD_WASM_BYTES });
|
|
31
|
-
});
|
|
32
|
-
return esbuild;
|
|
33
|
-
}
|
/package/public/_assets/napi-wasm/loader/{99efae93dd1dcc2b → ab7e57fe9e8750c2}/wasi-trampoline.wasm
RENAMED
|
File without changes
|