@nubjs/nub-win32-arm64 0.0.13 → 0.0.15
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/bin/nub.exe +0 -0
- package/package.json +1 -1
- package/runtime/addons/nub-native.node +0 -0
- package/runtime/polyfills.cjs +178 -0
- package/runtime/preload-async-hooks.mjs +5 -6
- package/runtime/preload-common.cjs +548 -0
- package/runtime/preload.cjs +277 -0
- package/runtime/preload.mjs +22 -11
- package/runtime/transform-core.mjs +98 -199
- package/runtime/version.mjs +1 -1
- package/runtime/worker-polyfill.mjs +15 -2
- package/runtime/node_modules/@oxc-parser/binding-win32-arm64-msvc/README.md +0 -3
- package/runtime/node_modules/@oxc-parser/binding-win32-arm64-msvc/package.json +0 -39
- package/runtime/node_modules/@oxc-parser/binding-win32-arm64-msvc/parser.win32-arm64-msvc.node +0 -0
- package/runtime/node_modules/@oxc-parser/binding-win32-x64-msvc/README.md +0 -3
- package/runtime/node_modules/@oxc-parser/binding-win32-x64-msvc/package.json +0 -39
- package/runtime/node_modules/@oxc-parser/binding-win32-x64-msvc/parser.win32-x64-msvc.node +0 -0
- package/runtime/node_modules/@oxc-project/types/LICENSE +0 -22
- package/runtime/node_modules/@oxc-project/types/README.md +0 -3
- package/runtime/node_modules/@oxc-project/types/package.json +0 -26
- package/runtime/node_modules/@oxc-project/types/types.d.ts +0 -1912
- package/runtime/node_modules/@oxc-transform/binding-win32-arm64-msvc/README.md +0 -3
- package/runtime/node_modules/@oxc-transform/binding-win32-arm64-msvc/package.json +0 -41
- package/runtime/node_modules/@oxc-transform/binding-win32-arm64-msvc/transform.win32-arm64-msvc.node +0 -0
- package/runtime/node_modules/@oxc-transform/binding-win32-x64-msvc/README.md +0 -3
- package/runtime/node_modules/@oxc-transform/binding-win32-x64-msvc/package.json +0 -41
- package/runtime/node_modules/@oxc-transform/binding-win32-x64-msvc/transform.win32-x64-msvc.node +0 -0
- package/runtime/node_modules/oxc-parser/LICENSE +0 -22
- package/runtime/node_modules/oxc-parser/README.md +0 -167
- package/runtime/node_modules/oxc-parser/package.json +0 -153
- package/runtime/node_modules/oxc-parser/src-js/bindings.js +0 -601
- package/runtime/node_modules/oxc-parser/src-js/generated/constants.js +0 -105
- package/runtime/node_modules/oxc-parser/src-js/generated/deserialize/js.js +0 -5862
- package/runtime/node_modules/oxc-parser/src-js/generated/deserialize/js_range.js +0 -6403
- package/runtime/node_modules/oxc-parser/src-js/generated/deserialize/ts.js +0 -6154
- package/runtime/node_modules/oxc-parser/src-js/generated/deserialize/ts_range.js +0 -6723
- package/runtime/node_modules/oxc-parser/src-js/generated/lazy/constructors.js +0 -13875
- package/runtime/node_modules/oxc-parser/src-js/generated/lazy/type_ids.js +0 -191
- package/runtime/node_modules/oxc-parser/src-js/generated/lazy/walk.js +0 -5810
- package/runtime/node_modules/oxc-parser/src-js/generated/visit/keys.js +0 -220
- package/runtime/node_modules/oxc-parser/src-js/generated/visit/type_ids.js +0 -177
- package/runtime/node_modules/oxc-parser/src-js/generated/visit/visitor.d.ts +0 -387
- package/runtime/node_modules/oxc-parser/src-js/generated/visit/walk.js +0 -2455
- package/runtime/node_modules/oxc-parser/src-js/index.d.ts +0 -312
- package/runtime/node_modules/oxc-parser/src-js/index.js +0 -108
- package/runtime/node_modules/oxc-parser/src-js/raw-transfer/common.js +0 -301
- package/runtime/node_modules/oxc-parser/src-js/raw-transfer/eager.js +0 -255
- package/runtime/node_modules/oxc-parser/src-js/raw-transfer/lazy-common.js +0 -11
- package/runtime/node_modules/oxc-parser/src-js/raw-transfer/lazy.js +0 -162
- package/runtime/node_modules/oxc-parser/src-js/raw-transfer/node-array.js +0 -365
- package/runtime/node_modules/oxc-parser/src-js/raw-transfer/supported.js +0 -52
- package/runtime/node_modules/oxc-parser/src-js/raw-transfer/visitor.js +0 -127
- package/runtime/node_modules/oxc-parser/src-js/visit/index.js +0 -41
- package/runtime/node_modules/oxc-parser/src-js/visit/visitor.js +0 -405
- package/runtime/node_modules/oxc-parser/src-js/wasm.js +0 -13
- package/runtime/node_modules/oxc-parser/src-js/webcontainer-fallback.cjs +0 -21
- package/runtime/node_modules/oxc-parser/src-js/wrap.js +0 -57
- package/runtime/node_modules/oxc-transform/LICENSE +0 -22
- package/runtime/node_modules/oxc-transform/README.md +0 -84
- package/runtime/node_modules/oxc-transform/browser.js +0 -1
- package/runtime/node_modules/oxc-transform/index.d.ts +0 -658
- package/runtime/node_modules/oxc-transform/index.js +0 -598
- package/runtime/node_modules/oxc-transform/package.json +0 -114
- package/runtime/node_modules/oxc-transform/webcontainer-fallback.cjs +0 -21
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// Nub fast-tier preload — Node 22.15+, injected via `--require` (CommonJS).
|
|
2
|
+
//
|
|
3
|
+
// WHY CJS / `--require` (not the `.mjs` `--import` the compat tier uses): the mere
|
|
4
|
+
// presence of `--import` forces Node to eagerly initialize the ESM loader, which
|
|
5
|
+
// then routes EVEN A CJS ENTRY POINT through the async ESM module-job
|
|
6
|
+
// (`ModuleJob.run`) instead of the synchronous `Module.runMain` CJS path. That one
|
|
7
|
+
// change is the root cause of a whole regression cluster (R1): top-level
|
|
8
|
+
// `executionAsyncId()===0` (Node: 1), extra PROMISE async-hook events, a top-level
|
|
9
|
+
// sync `throw` surfacing as `unhandledRejection` instead of `uncaughtException`,
|
|
10
|
+
// `require.main.id` `'.'`→abspath, `module.parent` `null`→`undefined`, and a
|
|
11
|
+
// missing-entry `ERR_MODULE_NOT_FOUND` instead of `MODULE_NOT_FOUND`. Loading this
|
|
12
|
+
// preload via `--require` (CJS) keeps Node on the synchronous CJS entry path and
|
|
13
|
+
// restores all of them, while STILL supporting `module.registerHooks` + TS
|
|
14
|
+
// transpile (both work from a `--require` CJS module on Node 22.15+).
|
|
15
|
+
//
|
|
16
|
+
// HARD CONSTRAINT: this file and everything it pulls in synchronously must be
|
|
17
|
+
// TLA-free. `require(esm)` (which loads transform-core.mjs / the polyfill ESM
|
|
18
|
+
// modules) rejects any module with top-level await (ERR_REQUIRE_ASYNC_MODULE), so
|
|
19
|
+
// transform-core.mjs, polyfills.cjs, worker-polyfill.mjs and navigator-locks.mjs
|
|
20
|
+
// are all TLA-free by construction. The compat tier (< 22.15), where require(esm)
|
|
21
|
+
// is unreliable, keeps its async `--import` preload.mjs path UNCHANGED.
|
|
22
|
+
//
|
|
23
|
+
// ROBUSTNESS TO `--no-experimental-require-module` (the require-module cluster):
|
|
24
|
+
// a user may set `--no-experimental-require-module` (e.g. to assert the legacy
|
|
25
|
+
// require(esm)→ERR_REQUIRE_ESM contract for THEIR code). That flag globally
|
|
26
|
+
// disables require(esm) — including for THIS `--require` CJS preload's own
|
|
27
|
+
// `require("./transform-core.mjs")`, which would otherwise crash the process at
|
|
28
|
+
// startup (ERR_REQUIRE_ESM) before any user code runs. nub's preload must survive
|
|
29
|
+
// that. The fix: detect when sync require(esm) is unavailable and fall back to the
|
|
30
|
+
// compat tier's async loader-worker hooks (`module.register("./preload-async-
|
|
31
|
+
// hooks.mjs")`), which loads transform-core.mjs as a STATIC ESM import inside the
|
|
32
|
+
// worker — a path the flag does not gate. User code still gets Node's own
|
|
33
|
+
// ERR_REQUIRE_ESM for ITS require(esm), exactly as the flag promises; only nub's
|
|
34
|
+
// preload is made robust. (See the require-module corpus cluster:
|
|
35
|
+
// test-cjs-esm-warn, test-disable-require-module-with-detection,
|
|
36
|
+
// test-esm-type-field-errors-2, parallel/test-require-mjs.)
|
|
37
|
+
|
|
38
|
+
const { createRequire } = require("node:module");
|
|
39
|
+
const module_ = require("node:module");
|
|
40
|
+
|
|
41
|
+
const __require = createRequire(__filename);
|
|
42
|
+
|
|
43
|
+
// Load preload-common FIRST so we can restore NODE_COMPILE_CACHE (R8) BEFORE
|
|
44
|
+
// transform-core.mjs is required: spawn.rs stripped that env var to keep nub's
|
|
45
|
+
// preload chain out of the user's V8 compile cache, and transform-core reads
|
|
46
|
+
// `NODE_COMPILE_CACHE === "0"` as its transpile-cache disable signal — so the
|
|
47
|
+
// value must be back in process.env before transform-core's module body runs.
|
|
48
|
+
// Restoring it in JS does NOT re-enable Node's bootstrap compile cache (already
|
|
49
|
+
// configured from the stripped env), so the chain below stays uncached.
|
|
50
|
+
const common = __require("./preload-common.cjs");
|
|
51
|
+
common.restoreCompileCacheEnv();
|
|
52
|
+
|
|
53
|
+
// `--no-experimental-require-module` disables require(esm) globally, so the
|
|
54
|
+
// transform-core require below (and the worker/locks ESM side-effect modules)
|
|
55
|
+
// would throw ERR_REQUIRE_ESM and abort the process before user code. Detect that
|
|
56
|
+
// and load via the async-register fallback instead. We probe by attempting the
|
|
57
|
+
// require and catching ERR_REQUIRE_ESM — robust regardless of how the flag arrived
|
|
58
|
+
// (CLI, NODE_OPTIONS, or a config file), and a no-op cost on the common path where
|
|
59
|
+
// require(esm) works.
|
|
60
|
+
let core = null;
|
|
61
|
+
let requireEsmDisabled = false;
|
|
62
|
+
try {
|
|
63
|
+
// The transform core is the single source of truth for resolution + transpile,
|
|
64
|
+
// shared verbatim with the compat tier. It's an ES module with no top-level
|
|
65
|
+
// await, so `require(esm)` loads it synchronously here on Node 22.15+.
|
|
66
|
+
core = __require("./transform-core.mjs");
|
|
67
|
+
} catch (err) {
|
|
68
|
+
if (err && err.code === "ERR_REQUIRE_ESM") {
|
|
69
|
+
requireEsmDisabled = true;
|
|
70
|
+
} else {
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const { installSyncPolyfills } = __require("./polyfills.cjs");
|
|
76
|
+
|
|
77
|
+
if (!requireEsmDisabled) {
|
|
78
|
+
// ── Fast tier (sync require(esm) available) ───────────────────────
|
|
79
|
+
|
|
80
|
+
// ── Watch-mode dependency reporting + hooks ───────────────────────
|
|
81
|
+
const watchReporting = common.installWatchReporting(core);
|
|
82
|
+
|
|
83
|
+
// Best-effort bounded-cache eviction (main thread only; the core guards on it).
|
|
84
|
+
// DEFERRED to setImmediate: maybeSweepCache probes `worker_threads.isMainThread`
|
|
85
|
+
// and dynamic-imports cache-evict.mjs, which would otherwise pull worker_threads
|
|
86
|
+
// (and its streams/worker-io transitive set) into the BOOTSTRAP module-load list
|
|
87
|
+
// on every startup — a cold-start regression (test-bootstrap-modules snapshots
|
|
88
|
+
// process.moduleLoadList at user code's first line). Running it one turn later
|
|
89
|
+
// keeps those out of the bootstrap snapshot while preserving the once-a-day sweep.
|
|
90
|
+
// unref so a purely-synchronous program still exits promptly without waiting on it.
|
|
91
|
+
setImmediate(() => {
|
|
92
|
+
try { core.maybeSweepCache(); } catch {}
|
|
93
|
+
}).unref();
|
|
94
|
+
|
|
95
|
+
// ── Pre-load clobbered polyfill packages BEFORE hooks register ────
|
|
96
|
+
// Packages in the core's CLOBBER_MAP can't be imported after hooks register (the
|
|
97
|
+
// resolve hook returns a synthetic module instead of the real package), so
|
|
98
|
+
// require them now via the not-yet-hooked CJS require and stash them for the
|
|
99
|
+
// polyfill installer. Temporal is deferred entirely to a lazy global (below).
|
|
100
|
+
const __preloadedPolyfills = common.preloadPolyfillPackages(__require);
|
|
101
|
+
|
|
102
|
+
// ── Hook registration (fast tier: sync, in-thread) ────────────────
|
|
103
|
+
// Same realm as user code; covers `import` and (Node 24+) `require`.
|
|
104
|
+
// registerHooks' require RESOLUTION is incomplete on 22.15–24, so also install
|
|
105
|
+
// the main-thread CJS resolve shim (its _resolveFilename half, always on). We do
|
|
106
|
+
// NOT install the classic require.extensions transpile shim on the fast tier: the
|
|
107
|
+
// sync registerHooks LOAD hook already transpiles require()'d `.ts` (CJS content,
|
|
108
|
+
// tsconfig paths, .tsx, extensionless — all verified), and native require(esm)
|
|
109
|
+
// (>= 22.12, always present at the 22.15+ fast floor) loads ES-module `.ts`. The
|
|
110
|
+
// classic require.extensions['.ts'] hook would SHADOW that native require(esm) and
|
|
111
|
+
// throw a bogus ERR_REQUIRE_ESM on every ESM `.ts` entry on 22.15–22.17 (where
|
|
112
|
+
// process.features.typescript is still false) — so it must stay off here. On
|
|
113
|
+
// 22.18+/24+ this was already the behavior (native-TS → false); now it's uniform.
|
|
114
|
+
const { resolve, load } = common.makeHooks(core, watchReporting);
|
|
115
|
+
module_.registerHooks({ resolve, load });
|
|
116
|
+
common.installCjsRequireHooks(core, false);
|
|
117
|
+
|
|
118
|
+
// ── Sync polyfills + lazy ESM-side-effect polyfills ───────────────
|
|
119
|
+
installSyncPolyfills(__preloadedPolyfills);
|
|
120
|
+
installLazyEsmPolyfills();
|
|
121
|
+
|
|
122
|
+
// ── Temporal: lazy global (A37) ───────────────────────────────────
|
|
123
|
+
common.installTemporalLazyGlobal(__require);
|
|
124
|
+
|
|
125
|
+
// ── Compile-cache: re-enable for the USER's modules (R8) ──────────
|
|
126
|
+
common.reenableUserCompileCache();
|
|
127
|
+
} else {
|
|
128
|
+
// ── Fallback tier (`--no-experimental-require-module`): async hooks ─
|
|
129
|
+
// The user disabled require(esm), so the in-thread sync `module.registerHooks`
|
|
130
|
+
// core can't be loaded here. Register the SAME hooks the compat tier uses, run
|
|
131
|
+
// in a dedicated loader worker via `module.register`; that worker imports
|
|
132
|
+
// transform-core.mjs as a static ESM import (not gated by the flag). The
|
|
133
|
+
// main-thread CJS require() transpile shim, which would need the core
|
|
134
|
+
// synchronously in-thread, is unavailable in this mode — an honest, additive
|
|
135
|
+
// degradation: the user opted out of require(esm), and nub's `.ts`-via-require()
|
|
136
|
+
// transpile rides on exactly that mechanism. `import`-side TS still transpiles
|
|
137
|
+
// through the registered loader-worker hooks. User require(esm) of THEIR own ES
|
|
138
|
+
// modules still gets Node's native ERR_REQUIRE_ESM, exactly as the flag promises.
|
|
139
|
+
const { pathToFileURL } = require("node:url");
|
|
140
|
+
module_.register("./preload-async-hooks.mjs", pathToFileURL(__filename).href);
|
|
141
|
+
|
|
142
|
+
// Sync, non-require(esm) polyfills still install (none of them require(esm)).
|
|
143
|
+
// Clobbered-polyfill packages are CJS requires, unaffected by the flag.
|
|
144
|
+
const __preloadedPolyfills = common.preloadPolyfillPackages(__require);
|
|
145
|
+
installSyncPolyfills(__preloadedPolyfills);
|
|
146
|
+
installLazyEsmPolyfills();
|
|
147
|
+
|
|
148
|
+
// Temporal lazy global needs only `__require` (it loads a CJS package), and the
|
|
149
|
+
// user's compile-cache re-enable is independent of require(esm).
|
|
150
|
+
common.installTemporalLazyGlobal(__require);
|
|
151
|
+
common.reenableUserCompileCache();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ── Lazy ESM-side-effect polyfills (R7) ─────────────────────────────
|
|
155
|
+
// The two ESM side-effect polyfills — the browser-shape Worker global
|
|
156
|
+
// (worker-polyfill.mjs) and Web Locks (navigator-locks.mjs) — were previously
|
|
157
|
+
// installed EAGERLY at preload (polyfills.cjs:installEsmPolyfillsSync). That drags
|
|
158
|
+
// ~50 builtins into bootstrap on EVERY startup: worker-polyfill.mjs imports
|
|
159
|
+
// node:worker_threads, which pulls internal/streams/* (readable/writable/duplex/
|
|
160
|
+
// transform/pipeline/…), internal/worker, internal/worker/io,
|
|
161
|
+
// internal/worker/messaging, vm, net, child_process, os, etc.; navigator-locks.mjs
|
|
162
|
+
// pulls internal/locks + internal/navigator. None of that is needed by the common
|
|
163
|
+
// "run a plain file, never touch Worker or navigator.locks" case, and the eager
|
|
164
|
+
// load is a cold-start regression that contradicts the fast-runner premise
|
|
165
|
+
// (test-bootstrap-modules: moduleLoadList must match Node's bootstrap set).
|
|
166
|
+
//
|
|
167
|
+
// Replace the eager install with lazy globals:
|
|
168
|
+
// • `globalThis.Worker` — a non-enumerable getter that, on first access (the
|
|
169
|
+
// first `new Worker(...)`), deletes itself, requires worker-polyfill.mjs (which
|
|
170
|
+
// then defines the real `globalThis.Worker`), and returns it.
|
|
171
|
+
// • `navigator.locks` — a non-enumerable getter that loads navigator-locks.mjs on
|
|
172
|
+
// first access (only when not native — Node 24.5+ ships it).
|
|
173
|
+
// In a WORKER thread, the worker-side bootstrap inside worker-polyfill.mjs (self/
|
|
174
|
+
// postMessage/message wiring) MUST run at startup, so we load it eagerly there.
|
|
175
|
+
// That costs nothing for bootstrap accounting: a worker already loaded
|
|
176
|
+
// worker_threads to exist, and test-bootstrap-modules measures the main thread.
|
|
177
|
+
function installLazyEsmPolyfills() {
|
|
178
|
+
// Cheap main-thread detection that does NOT pull node:worker_threads into the
|
|
179
|
+
// main-thread bootstrap (requiring it eagerly is exactly the regression we're
|
|
180
|
+
// fixing): in a worker, worker_threads is already in the module-load list by the
|
|
181
|
+
// time this preload runs; on the main thread it is not.
|
|
182
|
+
const inWorkerThread = process.moduleLoadList.some(
|
|
183
|
+
(m) => m === "NativeModule worker_threads",
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
const loadEsmSideEffect = (specifier) => {
|
|
187
|
+
try {
|
|
188
|
+
__require(specifier);
|
|
189
|
+
} catch (err) {
|
|
190
|
+
if (err && err.code === "ERR_REQUIRE_ESM") {
|
|
191
|
+
// require(esm) disabled — load via dynamic import (not flag-gated). Async,
|
|
192
|
+
// but side-effect-only; the Worker/locks polyfills are needed lazily, and
|
|
193
|
+
// for a worker thread the worker-side wiring lands a tick later, which is
|
|
194
|
+
// still before any user message round-trip can complete.
|
|
195
|
+
import(specifier).catch(() => {});
|
|
196
|
+
} else {
|
|
197
|
+
throw err;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
if (inWorkerThread) {
|
|
203
|
+
// Worker-side scope bootstrap must be present synchronously where possible.
|
|
204
|
+
loadEsmSideEffect("./worker-polyfill.mjs");
|
|
205
|
+
if (typeof globalThis.navigator?.locks === "undefined") {
|
|
206
|
+
loadEsmSideEffect("./navigator-locks.mjs");
|
|
207
|
+
}
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Main thread: lazy Worker global. Defined NON-ENUMERABLE so it stays invisible
|
|
212
|
+
// to `Object.keys(globalThis)` / for-in — the additive contract — matching how
|
|
213
|
+
// worker-polyfill.mjs defines the real one.
|
|
214
|
+
if (typeof globalThis.Worker === "undefined") {
|
|
215
|
+
let installing = false;
|
|
216
|
+
Object.defineProperty(globalThis, "Worker", {
|
|
217
|
+
configurable: true,
|
|
218
|
+
enumerable: false,
|
|
219
|
+
get() {
|
|
220
|
+
if (installing) return undefined;
|
|
221
|
+
installing = true;
|
|
222
|
+
// Drop this lazy accessor so worker-polyfill.mjs's own
|
|
223
|
+
// `if (typeof globalThis.Worker === "undefined")` guard fires and defines
|
|
224
|
+
// the real Worker.
|
|
225
|
+
delete globalThis.Worker;
|
|
226
|
+
loadEsmSideEffect("./worker-polyfill.mjs");
|
|
227
|
+
return globalThis.Worker;
|
|
228
|
+
},
|
|
229
|
+
set(value) {
|
|
230
|
+
// A user assigning their own Worker wins — replace the lazy accessor.
|
|
231
|
+
Object.defineProperty(globalThis, "Worker", {
|
|
232
|
+
value,
|
|
233
|
+
configurable: true,
|
|
234
|
+
enumerable: false,
|
|
235
|
+
writable: true,
|
|
236
|
+
});
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Main thread: lazy navigator.locks (native on Node 24.5+, absent on the 22.x
|
|
242
|
+
// floor). VERSION-GATE so we never even READ `globalThis.navigator` where locks
|
|
243
|
+
// is native: on Node 24.5+ the native `navigator` global is a lazy getter that,
|
|
244
|
+
// on first access, eagerly realizes internal/navigator + internal/locks AND the
|
|
245
|
+
// whole stream/worker-io transitive set (~30 builtins) — touching it at preload
|
|
246
|
+
// would be exactly the cold-start regression test-bootstrap-modules guards
|
|
247
|
+
// against, for zero benefit (locks is already there). Below 24.5 navigator is
|
|
248
|
+
// present but lacks `locks`, and accessing it is cheap (one internal module), so
|
|
249
|
+
// installing the lazy polyfill there is fine.
|
|
250
|
+
const [navMaj, navMin] = process.versions.node.split(".").map((n) => parseInt(n, 10));
|
|
251
|
+
const locksNative = navMaj > 24 || (navMaj === 24 && navMin >= 5);
|
|
252
|
+
if (locksNative) return;
|
|
253
|
+
|
|
254
|
+
const nav = globalThis.navigator;
|
|
255
|
+
if (nav && typeof nav.locks === "undefined") {
|
|
256
|
+
let installing = false;
|
|
257
|
+
Object.defineProperty(nav, "locks", {
|
|
258
|
+
configurable: true,
|
|
259
|
+
enumerable: true,
|
|
260
|
+
get() {
|
|
261
|
+
if (installing) return undefined;
|
|
262
|
+
installing = true;
|
|
263
|
+
delete nav.locks;
|
|
264
|
+
loadEsmSideEffect("./navigator-locks.mjs");
|
|
265
|
+
return nav.locks;
|
|
266
|
+
},
|
|
267
|
+
set(value) {
|
|
268
|
+
Object.defineProperty(nav, "locks", {
|
|
269
|
+
value,
|
|
270
|
+
configurable: true,
|
|
271
|
+
enumerable: true,
|
|
272
|
+
writable: true,
|
|
273
|
+
});
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
package/runtime/preload.mjs
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
//
|
|
10
10
|
// THIS file stays the compat path: on 18.19–22.14, `module.registerHooks` does not
|
|
11
11
|
// exist and `require(esm)` is unreliable, so hooks run async in a dedicated loader
|
|
12
|
-
// worker via `module.register
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
12
|
+
// worker via `module.register`. That async machinery is why the compat tier keeps
|
|
13
|
+
// `--import` — its top-level `await` is accepted here (an `--import` ESM module may
|
|
14
|
+
// be async), and the < 22.15 floor has no equivalent sync surface. (Module-format
|
|
15
|
+
// + decorator detection no longer needs a preloaded JS parser: it is a synchronous
|
|
16
|
+
// native addon call, so there is nothing to `await`-warm-up before hooks run.)
|
|
16
17
|
//
|
|
17
18
|
// Resolution + transpile primitives come from runtime/transform-core.mjs; the
|
|
18
19
|
// non-tier-specific wiring (watch IPC, the CJS require() shim, clobbered-polyfill
|
|
@@ -56,19 +57,29 @@ common.installWatchReporting(core);
|
|
|
56
57
|
if (__isFastTier) {
|
|
57
58
|
// Defensive only — the Rust path uses preload.cjs for 22.15+. If reached, the
|
|
58
59
|
// sync registerHooks API is available; register synchronously to stay correct.
|
|
60
|
+
// Match preload.cjs: NO classic require.extensions shim on the fast tier — the
|
|
61
|
+
// sync registerHooks load hook + native require(esm) cover require()'d `.ts`
|
|
62
|
+
// (incl. ES modules); the classic shim would shadow require(esm) and throw a
|
|
63
|
+
// bogus ERR_REQUIRE_ESM on 22.15–22.17.
|
|
59
64
|
const { resolve, load } = common.makeHooks(core, process.env.WATCH_REPORT_DEPENDENCIES === "1");
|
|
60
65
|
module.registerHooks({ resolve, load });
|
|
61
|
-
common.installCjsRequireHooks(core,
|
|
66
|
+
common.installCjsRequireHooks(core, false);
|
|
62
67
|
} else if (__isCompatTier) {
|
|
63
68
|
// Compat path: ESM `import` hooks run in a dedicated loader worker thread.
|
|
64
69
|
module.register("./preload-async-hooks.mjs", import.meta.url);
|
|
65
|
-
// The main-thread
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
await core.ensureParser();
|
|
70
|
+
// (The main-thread require() shim's module-format + decorator detection is a
|
|
71
|
+
// synchronous native addon call now — no parser warm-up; the old
|
|
72
|
+
// `await core.ensureParser()` for the ESM-only oxc-parser is gone.)
|
|
69
73
|
// module.register() is ESM-loader-only; augment CommonJS require() on the main
|
|
70
|
-
// thread too. The compat tier
|
|
71
|
-
//
|
|
74
|
+
// thread too. The compat tier has no sync registerHooks, so require()'d `.ts`
|
|
75
|
+
// MUST be transpiled by the classic require.extensions shim — hence it always
|
|
76
|
+
// installs (true). KNOWN LIMITATION: on the require(esm)-capable slice of the
|
|
77
|
+
// compat tier (22.12–22.14) an explicit `require('./esm-module.ts')` still
|
|
78
|
+
// surfaces ERR_REQUIRE_ESM, because the classic shim shadows native require(esm)
|
|
79
|
+
// and can't delegate to it from inside `_compile`. ESM `.ts` ENTRIES and `import`
|
|
80
|
+
// of ESM `.ts` both work (they ride the ESM loader); only require()-of-ESM-`.ts`
|
|
81
|
+
// is affected — an uncommon pattern. Below 22.12 the error is fully correct
|
|
82
|
+
// (no require(esm) at all). Fast tier (22.15+) has none of this — see preload.cjs.
|
|
72
83
|
common.installCjsRequireHooks(core, !__hasNativeTs);
|
|
73
84
|
} else {
|
|
74
85
|
process.stderr.write(
|