@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
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
// Temporal lazy global, watch-mode IPC, and the compat-tier CJS `require()`
|
|
9
9
|
// shim. EVERYTHING about how a file is resolved and transpiled — extension
|
|
10
10
|
// probing, the `.js`→`.ts` swap, tsconfig `paths`, module-format detection,
|
|
11
|
-
//
|
|
11
|
+
// transform options (including `target: 'es2022'` `using`-lowering), the
|
|
12
12
|
// Stage-3 decorator guard, the on-disk cache, data-format imports, package
|
|
13
13
|
// clobbering — lives here, so the two tiers can never drift. (They used to:
|
|
14
14
|
// separate copies diverged on probe order, `target` lowering, the decorator
|
|
15
15
|
// guard, module-format detection, the Temporal clobber's named exports, and the
|
|
16
16
|
// reserved-export filter — every one a real compat bug. This module is the fix.)
|
|
17
17
|
//
|
|
18
|
-
// Side effects are confined to: loading the N-API data
|
|
19
|
-
//
|
|
20
|
-
// top-level hook registration here — importing this module never augments the
|
|
18
|
+
// Side effects are confined to: loading the N-API addon (data parsers + the
|
|
19
|
+
// in-process TS/JSX transpiler), and reading/writing the transpile cache. There is
|
|
20
|
+
// no top-level hook registration here — importing this module never augments the
|
|
21
21
|
// realm; the tier files do that.
|
|
22
22
|
|
|
23
23
|
// EVERY dependency of this module is pulled in via CJS `require()` (below), NOT
|
|
@@ -25,86 +25,58 @@
|
|
|
25
25
|
// nub loads transform-core through `require(esm)`, and Node's `require(esm)`
|
|
26
26
|
// instantiates the module by walking its STATIC IMPORT graph through whatever ESM
|
|
27
27
|
// loader hooks are registered — including the USER's `--loader`/`register()`
|
|
28
|
-
// chain. Static `import
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
28
|
+
// chain. Static `import get-tsconfig`/`./version.mjs`/`node:*` here therefore
|
|
29
|
+
// leaked nub's entire internal graph (transform-core, version.mjs, get-tsconfig,
|
|
30
|
+
// their transitive node_modules deps, and the node: builtins) THROUGH the user's
|
|
31
|
+
// resolve/load hooks, which observed and corrupted it (a user load hook returning
|
|
32
|
+
// `source: 1` for version.mjs, a strict loader throwing on a bare specifier — see
|
|
33
|
+
// test-esm-loader-chaining, -example-loader, -preserve-symlinks-not-found,
|
|
34
|
+
// test-shadow-realm-custom-loaders). Verified: a CJS `require()` of a
|
|
35
|
+
// package/builtin does NOT route through the ESM loader chain, so loading the graph
|
|
36
|
+
// this way bypasses the user chain entirely. (The transpiler and TS/JSX detection
|
|
37
|
+
// no longer go through any npm package at all: they are native calls into nub's own
|
|
38
|
+
// N-API addon, so the worst historical leak — pulling oxc-transform's ESM entry
|
|
39
|
+
// graph through the user chain — is gone by construction.) `process
|
|
38
40
|
// .getBuiltinModule` fetches node: builtins synchronously off the loader chain;
|
|
39
41
|
// `createRequire(import.meta.url)` resolves the bare deps from nub's distribution.
|
|
40
42
|
// This file keeps its `export`s (it stays an ES module), but has ZERO static
|
|
41
43
|
// imports, so `require(esm)` finds no dependency graph to route through the user.
|
|
42
|
-
|
|
44
|
+
// `process.getBuiltinModule` (Node 22.3 / backported to 20.16 / 18.20.4) fetches a
|
|
45
|
+
// node: builtin synchronously off the loader chain. On older floor Node (18.19,
|
|
46
|
+
// 20.11–20.15, 22.0–22.2) it's `undefined` — calling it threw `TypeError: process
|
|
47
|
+
// .getBuiltinModule is not a function`, aborting every run. Fall back to a
|
|
48
|
+
// createRequire bootstrapped from a single static `node:module` import. That import
|
|
49
|
+
// is a BUILTIN specifier — resolved by Node natively, never routed through a user
|
|
50
|
+
// loader hook (and resolved here at preload time, before any hook registers) — so
|
|
51
|
+
// the "zero user-routable dependency graph for require(esm)" property still holds.
|
|
52
|
+
import { createRequire as __bootstrapCreateRequire } from "node:module";
|
|
53
|
+
const __getBuiltin =
|
|
54
|
+
typeof process.getBuiltinModule === "function"
|
|
55
|
+
? (id) => process.getBuiltinModule(id)
|
|
56
|
+
: ((__r) => (id) => __r(id))(__bootstrapCreateRequire(import.meta.url));
|
|
57
|
+
|
|
58
|
+
const { createRequire } = __getBuiltin("node:module");
|
|
43
59
|
const __require = createRequire(import.meta.url);
|
|
44
60
|
|
|
45
|
-
const module =
|
|
46
|
-
const { readFileSync, writeFileSync, mkdirSync, statSync, renameSync, unlinkSync, readdirSync } =
|
|
47
|
-
const { fileURLToPath, pathToFileURL } =
|
|
48
|
-
const { join, dirname, resolve: pathResolve, extname: pathExtname } =
|
|
49
|
-
//
|
|
50
|
-
// `
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
// (
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// `module._compile` at its real path so its internal `require('./binding.node')`
|
|
61
|
-
// and `__dirname` resolve correctly. A CJS-compiled module has no static-import
|
|
62
|
-
// graph for Node to route through any loader. Falls back to plain require(esm) if
|
|
63
|
-
// the source shape ever changes (then the leak returns, but transpilation works).
|
|
64
|
-
function requireOxcAsCjs() {
|
|
65
|
-
const Module = module;
|
|
66
|
-
let entry;
|
|
67
|
-
try {
|
|
68
|
-
entry = __require.resolve("oxc-transform");
|
|
69
|
-
} catch {
|
|
70
|
-
return __require("oxc-transform");
|
|
71
|
-
}
|
|
72
|
-
// Only the .js NAPI-RS wrapper has the mixed ESM-header/CJS-body shape we can
|
|
73
|
-
// safely transform; anything else, defer to the normal loader.
|
|
74
|
-
if (!entry.endsWith(".js")) return __require("oxc-transform");
|
|
75
|
-
try {
|
|
76
|
-
let src = readFileSync(entry, "utf8");
|
|
77
|
-
// Strip the ESM header: `import { createRequire } from 'node:module'`,
|
|
78
|
-
// `const require = createRequire(import.meta.url)`, and any
|
|
79
|
-
// `const __dirname = new URL('.', import.meta.url).pathname`. In a CJS module
|
|
80
|
-
// `require`, `__dirname`, `__filename` are already injected by _compile.
|
|
81
|
-
src = src
|
|
82
|
-
.replace(/^\s*import\s*\{[^}]*\}\s*from\s*['"]node:module['"];?\s*$/m, "")
|
|
83
|
-
.replace(/^\s*const\s+require\s*=\s*createRequire\([^)]*\);?\s*$/m, "")
|
|
84
|
-
.replace(/^\s*const\s+__dirname\s*=\s*new URL\([^)]*\)\.pathname;?\s*$/m, "");
|
|
85
|
-
// Convert the `export { Name }` footer lines to a single CJS exports block.
|
|
86
|
-
const names = [];
|
|
87
|
-
src = src.replace(/^\s*export\s*\{\s*([A-Za-z0-9_$]+)\s*\}\s*;?\s*$/gm, (_m, n) => {
|
|
88
|
-
names.push(n);
|
|
89
|
-
return "";
|
|
90
|
-
});
|
|
91
|
-
// Guard: if any `import`/`export`/`import.meta` survived, we don't understand
|
|
92
|
-
// this version's shape — bail to the safe loader rather than ship broken code.
|
|
93
|
-
if (/^\s*(import|export)\s/m.test(src) || /\bimport\.meta\b/.test(src)) {
|
|
94
|
-
return __require("oxc-transform");
|
|
95
|
-
}
|
|
96
|
-
if (names.length === 0) return __require("oxc-transform");
|
|
97
|
-
src += `\nmodule.exports = { ${names.join(", ")} };\n`;
|
|
98
|
-
const m = new Module(entry, null);
|
|
99
|
-
m.filename = entry;
|
|
100
|
-
m.paths = Module._nodeModulePaths(dirname(entry));
|
|
101
|
-
m._compile(src, entry);
|
|
102
|
-
return m.exports;
|
|
103
|
-
} catch {
|
|
104
|
-
return __require("oxc-transform");
|
|
105
|
-
}
|
|
61
|
+
const module = __getBuiltin("node:module");
|
|
62
|
+
const { readFileSync, writeFileSync, mkdirSync, statSync, renameSync, unlinkSync, readdirSync } = __getBuiltin("node:fs");
|
|
63
|
+
const { fileURLToPath, pathToFileURL } = __getBuiltin("node:url");
|
|
64
|
+
const { join, dirname, resolve: pathResolve, extname: pathExtname } = __getBuiltin("node:path");
|
|
65
|
+
// Nub's N-API addon — the in-process TS/JSX transpiler (`transform`,
|
|
66
|
+
// `detectModuleInfo`) AND the data-format parsers (`parseYaml`/`parseToml`/
|
|
67
|
+
// `parseJson5`/`parseJsonc`), all native. Loaded once per module instance (= once
|
|
68
|
+
// per thread: the main thread and the loader worker each import this module
|
|
69
|
+
// separately). It is a `.node` binary resolved by absolute path off this file's
|
|
70
|
+
// dir, so it never touches the ESM loader chain — the historical
|
|
71
|
+
// require(esm)-of-an-ESM-npm-package leak (oxc-transform) is gone: transpilation
|
|
72
|
+
// is a synchronous native call, no JS package, no static-import graph to route.
|
|
73
|
+
let nubNative = null;
|
|
74
|
+
for (const rel of ["./addons/nub-native.node", "../runtime/addons/nub-native.node"]) {
|
|
75
|
+
try { nubNative = __require(fileURLToPath(new URL(rel, import.meta.url))); break; } catch {}
|
|
106
76
|
}
|
|
107
|
-
|
|
77
|
+
// get-tsconfig is `type: module` but ships a CJS `require` export
|
|
78
|
+
// (./dist/index.cjs), so `require()` of it loads the CommonJS build — no
|
|
79
|
+
// require(esm), no ESM-loader-chain routing.
|
|
108
80
|
const { getTsconfig, createPathsMatcher } = __require("get-tsconfig");
|
|
109
81
|
|
|
110
82
|
// NUB_VERSION is the single source of truth in runtime/version.mjs. We must NOT
|
|
@@ -174,14 +146,6 @@ export const CLOBBER_MAP = new Map([
|
|
|
174
146
|
["abort-controller", () => `export const AbortController = globalThis.AbortController; export const AbortSignal = globalThis.AbortSignal; export default globalThis.AbortController;`],
|
|
175
147
|
]);
|
|
176
148
|
|
|
177
|
-
// Nub's N-API addon for data-format parsing (Rust-native YAML/TOML/JSON5/JSONC).
|
|
178
|
-
// Loaded once per module instance (= once per thread: the main thread and the
|
|
179
|
-
// loader worker each import this module separately).
|
|
180
|
-
let nubNative = null;
|
|
181
|
-
for (const rel of ["./addons/nub-native.node", "../runtime/addons/nub-native.node"]) {
|
|
182
|
-
try { nubNative = __require(fileURLToPath(new URL(rel, import.meta.url))); break; } catch {}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
149
|
// ── Watch-mode hooks (injected by the main-thread tier) ─────────────
|
|
186
150
|
// `nub watch` needs config files (tsconfig.json, package.json) and `.env*` —
|
|
187
151
|
// which are not in any import graph — surfaced to Node's FilesWatcher. The main
|
|
@@ -366,34 +330,34 @@ export function getProbeOrder(parentExt) {
|
|
|
366
330
|
|
|
367
331
|
// nub's own runtime directory (this file's dir, as a file: URL prefix). Any
|
|
368
332
|
// resolution whose IMPORTER lives here is one of nub's internal requires — the
|
|
369
|
-
// preload loading transform-core,
|
|
370
|
-
//
|
|
371
|
-
//
|
|
372
|
-
//
|
|
373
|
-
//
|
|
374
|
-
//
|
|
375
|
-
//
|
|
376
|
-
//
|
|
333
|
+
// preload loading transform-core, the Temporal lazy getter resolving
|
|
334
|
+
// @js-temporal/polyfill — and must NEVER be routed through nub's own
|
|
335
|
+
// clobber/vendored/tsconfig logic: those are user-code conveniences, and applying
|
|
336
|
+
// them to nub's internals both breaks them (e.g. the Temporal clobber re-exports
|
|
337
|
+
// globalThis.Temporal, which IS the getter → a require of the polyfill from the
|
|
338
|
+
// getter would recurse into the clobber) and amplifies the user loader chain by
|
|
339
|
+
// re-walking nub's internal graph through user hooks (R11). Short-circuit to native
|
|
340
|
+
// resolution for these.
|
|
377
341
|
const RUNTIME_DIR_URL = new URL(".", import.meta.url).href;
|
|
378
342
|
|
|
379
343
|
// nub's internal-graph package roots — the file: URL prefixes of the npm packages
|
|
380
|
-
// nub itself loads (
|
|
381
|
-
//
|
|
382
|
-
//
|
|
383
|
-
//
|
|
384
|
-
//
|
|
385
|
-
//
|
|
386
|
-
//
|
|
387
|
-
//
|
|
388
|
-
//
|
|
389
|
-
//
|
|
390
|
-
//
|
|
391
|
-
//
|
|
344
|
+
// nub itself loads (get-tsconfig) and their transitive deps. Any resolution whose
|
|
345
|
+
// IMPORTER lives under one of these is part of nub's internal graph, NOT user code,
|
|
346
|
+
// and must FULLY short-circuit (resolve natively, return shortCircuit:true) — never
|
|
347
|
+
// delegate to nextResolve — for EVERY specifier, including node: builtins and the
|
|
348
|
+
// package's own relative imports, so the user ESM loader chain never observes nub's
|
|
349
|
+
// internals (R11). get-tsconfig is loaded as CJS (its `require` export resolves to
|
|
350
|
+
// ./dist/index.cjs), so its graph already bypasses the chain; this short-circuit is
|
|
351
|
+
// the belt-and-suspenders for any ESM hop into a nub-internal package. The biggest
|
|
352
|
+
// historical leak — oxc-transform's `type: module` entry pulled through require(esm)
|
|
353
|
+
// and walked through the user loader — is gone: the transpiler is now a native
|
|
354
|
+
// addon call, no npm package. Computed lazily (and pinned even on resolve failure)
|
|
355
|
+
// so a missing dep can't wedge startup.
|
|
392
356
|
let _nubGraphRoots = null;
|
|
393
357
|
function nubGraphRoots() {
|
|
394
358
|
if (_nubGraphRoots) return _nubGraphRoots;
|
|
395
359
|
const roots = [];
|
|
396
|
-
for (const pkg of ["
|
|
360
|
+
for (const pkg of ["get-tsconfig"]) {
|
|
397
361
|
try {
|
|
398
362
|
const entry = __require.resolve(pkg);
|
|
399
363
|
// Package root = the directory two levels up does not work generically;
|
|
@@ -438,7 +402,7 @@ export function resolveSpec(specifier, parentURL) {
|
|
|
438
402
|
// user's loader chain) never observes nub's internals. This MUST run before the
|
|
439
403
|
// node:/data:/builtin early-returns below, because those `return null` =
|
|
440
404
|
// DELEGATE to the user loader — and a nub-internal `import "node:module"` (e.g.
|
|
441
|
-
// from
|
|
405
|
+
// from a nub-dependency ESM entry) delegated to a strict user loader is exactly
|
|
442
406
|
// the R11 leak. See isNubInternalParent / nubGraphRoots.
|
|
443
407
|
if (isNubInternalParent(parentURL)) {
|
|
444
408
|
if (specifier.startsWith("node:") || module.builtinModules.includes(specifier)) {
|
|
@@ -572,68 +536,29 @@ export function requireTargetIsEsm(filePath, ext) {
|
|
|
572
536
|
}
|
|
573
537
|
|
|
574
538
|
// ── Module-format detection ─────────────────────────────────────────
|
|
575
|
-
//
|
|
576
|
-
//
|
|
577
|
-
//
|
|
578
|
-
//
|
|
579
|
-
//
|
|
580
|
-
//
|
|
581
|
-
//
|
|
582
|
-
//
|
|
583
|
-
//
|
|
584
|
-
//
|
|
585
|
-
//
|
|
586
|
-
|
|
587
|
-
//
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
/// Async, idempotent: ensure oxc-parser is loaded via dynamic import (the only
|
|
593
|
-
/// form that works below require(esm)). Compat-tier callers await this before the
|
|
594
|
-
/// synchronous detection below runs.
|
|
595
|
-
export async function ensureParser() {
|
|
596
|
-
if (_parseSync || _importTried) return;
|
|
597
|
-
_importTried = true;
|
|
598
|
-
try { _parseSync = (await import("oxc-parser")).parseSync; } catch { /* unavailable */ }
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
function getParseSync() {
|
|
602
|
-
if (!_parseSync && !_requireTried) {
|
|
603
|
-
_requireTried = true;
|
|
604
|
-
try { _parseSync = __require("oxc-parser").parseSync; } catch { /* try ensureParser instead */ }
|
|
605
|
-
}
|
|
606
|
-
return _parseSync;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// Does the source carry VALUE-level ESM syntax? Mirrors Node's
|
|
610
|
-
// `--experimental-detect-module`: type-only imports/exports are erased by oxc
|
|
611
|
-
// and must NOT count, but a value import/export, a bare `import "x"`, an
|
|
612
|
-
// `export {}` marker, `import.meta`, or top-level `await` all force ESM.
|
|
613
|
-
// Used only for the ambiguous extensions when package.json has no `type`.
|
|
614
|
-
function hasEsmSyntax(filePath, source, lang) {
|
|
615
|
-
const parse = getParseSync();
|
|
616
|
-
if (!parse) return true; // detection unavailable → default ESM (the common case)
|
|
617
|
-
let mod;
|
|
539
|
+
// Both signals nub needs to read off a file's syntax — the absent-`type` module
|
|
540
|
+
// format and the Stage-3-decorator guard — come from ONE native call into nub's
|
|
541
|
+
// N-API addon (`detectModuleInfo`, the oxc parser compiled in-process). There is
|
|
542
|
+
// no JS parser package anymore: `oxc-parser` (ESM-only, which used to need
|
|
543
|
+
// `require(esm)` on the fast tier and a dynamic-`import()` `ensureParser()` dance
|
|
544
|
+
// on the 18.19 compat tier) is gone, and with it the whole "is require(esm)
|
|
545
|
+
// available here?" fork. The native call is synchronous and works identically on
|
|
546
|
+
// every supported Node, so there is nothing to preload and no async warm-up — the
|
|
547
|
+
// former `ensureParser()` export is removed (its compat-tier callers just stop
|
|
548
|
+
// calling it). Used only for ambiguous extensions / the decorator guard; explicit
|
|
549
|
+
// `type` and `.mts`/`.cts` short-circuit before the parser runs.
|
|
550
|
+
function detectModuleInfo(filePath, source, lang) {
|
|
551
|
+
// Addon missing (should never happen in a real install): default to ESM for
|
|
552
|
+
// format (the common case) and "no decorators" for the guard — the same fallback
|
|
553
|
+
// the old oxc-parser-unavailable branches used.
|
|
554
|
+
if (!nubNative) return { hasValueEsmSyntax: true, hasDecorators: false };
|
|
618
555
|
try {
|
|
619
|
-
|
|
556
|
+
return nubNative.detectModuleInfo(filePath, source, lang);
|
|
620
557
|
} catch {
|
|
621
|
-
|
|
558
|
+
// Unparseable → CJS for format + no decorators (the transpile/V8 surfaces the
|
|
559
|
+
// real error), matching the old per-call catch blocks.
|
|
560
|
+
return { hasValueEsmSyntax: false, hasDecorators: false };
|
|
622
561
|
}
|
|
623
|
-
const valueImport = mod.staticImports.some(
|
|
624
|
-
(si) => si.entries.length === 0 || si.entries.some((e) => !e.isType),
|
|
625
|
-
);
|
|
626
|
-
const valueExport = mod.staticExports.some(
|
|
627
|
-
(se) => se.entries.length === 0 || se.entries.some((e) => !e.isType),
|
|
628
|
-
);
|
|
629
|
-
if (valueImport || valueExport || mod.importMetas.length > 0) return true;
|
|
630
|
-
// Top-level await: `hasModuleSyntax` is set with no static import/export/meta.
|
|
631
|
-
return (
|
|
632
|
-
mod.hasModuleSyntax &&
|
|
633
|
-
mod.staticImports.length === 0 &&
|
|
634
|
-
mod.staticExports.length === 0 &&
|
|
635
|
-
mod.importMetas.length === 0
|
|
636
|
-
);
|
|
637
562
|
}
|
|
638
563
|
|
|
639
564
|
// Map a transpiled file's extension + nearest package.json "type" to the module
|
|
@@ -647,7 +572,7 @@ export function moduleFormatFor(ext, pkgType, filePath, source) {
|
|
|
647
572
|
if (pkgType === "module") return "module";
|
|
648
573
|
if (pkgType === "commonjs") return "commonjs";
|
|
649
574
|
const lang = ext === ".tsx" ? "tsx" : ext === ".jsx" ? "jsx" : "ts";
|
|
650
|
-
return
|
|
575
|
+
return detectModuleInfo(filePath, source, lang).hasValueEsmSyntax ? "module" : "commonjs";
|
|
651
576
|
}
|
|
652
577
|
|
|
653
578
|
// The Stage-3-decorator rejection diagnostic. oxc does not lower TC39 Stage 3
|
|
@@ -672,36 +597,9 @@ function stage3DecoratorError(filePath) {
|
|
|
672
597
|
// member)? Used ONLY when legacy decorators are off, to surface a clear
|
|
673
598
|
// diagnostic instead of oxc's verbatim passthrough → V8 SyntaxError. The cheap
|
|
674
599
|
// `source.includes("@")` pre-filter in the caller keeps decorator-free files off
|
|
675
|
-
// the parser
|
|
676
|
-
// their members (incl. accessors), and to `export`/`export default` wrappers.
|
|
600
|
+
// the native parser. The walk now happens in Rust (detectModuleInfo's AST visit).
|
|
677
601
|
function hasDecoratorSyntax(filePath, source, lang) {
|
|
678
|
-
|
|
679
|
-
if (!parse) return false; // parser unavailable → let oxc/V8 surface the error
|
|
680
|
-
let program;
|
|
681
|
-
try {
|
|
682
|
-
program = parse(filePath, source, { lang }).program;
|
|
683
|
-
} catch {
|
|
684
|
-
return false; // unparseable → the transpile/V8 surfaces the real error
|
|
685
|
-
}
|
|
686
|
-
let found = false;
|
|
687
|
-
const visit = (node) => {
|
|
688
|
-
if (found || !node || typeof node !== "object") return;
|
|
689
|
-
if (Array.isArray(node)) {
|
|
690
|
-
for (const child of node) visit(child);
|
|
691
|
-
return;
|
|
692
|
-
}
|
|
693
|
-
if (Array.isArray(node.decorators) && node.decorators.length > 0) {
|
|
694
|
-
found = true;
|
|
695
|
-
return;
|
|
696
|
-
}
|
|
697
|
-
for (const k in node) {
|
|
698
|
-
if (k === "type" || k === "start" || k === "end") continue;
|
|
699
|
-
visit(node[k]);
|
|
700
|
-
if (found) return;
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
visit(program.body);
|
|
704
|
-
return found;
|
|
602
|
+
return detectModuleInfo(filePath, source, lang).hasDecorators;
|
|
705
603
|
}
|
|
706
604
|
|
|
707
605
|
// Drop a trailing bare `export {};` — oxc injects it to preserve module-ness
|
|
@@ -713,8 +611,9 @@ function stripEmptyExportMarker(code) {
|
|
|
713
611
|
|
|
714
612
|
// ── Transpile cache ─────────────────────────────────────────────────
|
|
715
613
|
// NUB_VERSION (from version.mjs) is the SOLE version component of the cache key:
|
|
716
|
-
//
|
|
717
|
-
// only in a new nub version, which `make version`
|
|
614
|
+
// the transpiler is nub's own native addon, compiled per release against a pinned
|
|
615
|
+
// oxc, so any emit change ships only in a new nub version, which `make version`
|
|
616
|
+
// bumps (and which rebuilds the addon). CACHE_SCHEMA busts the
|
|
718
617
|
// cache when the on-disk ENTRY FORMAT changes (v3 = integrity prefix + leading
|
|
719
618
|
// format byte). The fast and compat tiers share this cache: post-extraction they
|
|
720
619
|
// emit byte-identical output for the same (source, ext, tsconfig, pkgType), so a
|
|
@@ -873,7 +772,7 @@ export function loadTranspile(url, ext) {
|
|
|
873
772
|
throw stage3DecoratorError(filePath);
|
|
874
773
|
}
|
|
875
774
|
|
|
876
|
-
const result =
|
|
775
|
+
const result = nubNative.transform(filePath, source, opts);
|
|
877
776
|
if (result.errors.length > 0) {
|
|
878
777
|
const details = result.errors.map((e) => e.codeframe || e.message).join("\n\n");
|
|
879
778
|
throw new Error(`Transpile error in ${filePath}:\n${details}`);
|
package/runtime/version.mjs
CHANGED
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
// previously lived as a literal inside preload.mjs, which `make version` patched,
|
|
10
10
|
// while the worker carried a hand-maintained "…-compat" copy that `make version`
|
|
11
11
|
// never touched — a latent staleness bug this module closes.)
|
|
12
|
-
export const NUB_VERSION = "0.0.
|
|
12
|
+
export const NUB_VERSION = "0.0.15";
|
|
@@ -13,8 +13,21 @@
|
|
|
13
13
|
// the child crashes (observed against test-esm-loader-chaining). `process
|
|
14
14
|
// .getBuiltinModule` fetches the real builtin synchronously off the loader
|
|
15
15
|
// graph, bypassing the user chain entirely — same fix transform-core.mjs uses.
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// `process.getBuiltinModule` doesn't exist below Node 22.3 / 20.16 / 18.20.4 (it
|
|
17
|
+
// threw `TypeError: ... is not a function` there). Fall back to a createRequire
|
|
18
|
+
// bootstrapped from a single static `node:module` import. The actual builtins below
|
|
19
|
+
// are still fetched through `__getBuiltin` — getBuiltinModule on new Node, CJS
|
|
20
|
+
// `__require` on old — and BOTH bypass the user ESM loader chain (the whole reason
|
|
21
|
+
// this file avoids a static `import` of node:worker_threads). Only the bootstrap
|
|
22
|
+
// touches node:module, which user loader hooks don't intercept (unlike the mockable
|
|
23
|
+
// node:worker_threads the chaining test targets), so the bypass guarantee holds.
|
|
24
|
+
import { createRequire as __bootstrapCreateRequire } from "node:module";
|
|
25
|
+
const __getBuiltin =
|
|
26
|
+
typeof process.getBuiltinModule === "function"
|
|
27
|
+
? (id) => process.getBuiltinModule(id)
|
|
28
|
+
: ((__r) => (id) => __r(id))(__bootstrapCreateRequire(import.meta.url));
|
|
29
|
+
const { Worker: NodeWorker, parentPort, isMainThread } = __getBuiltin("node:worker_threads");
|
|
30
|
+
const { fileURLToPath } = __getBuiltin("node:url");
|
|
18
31
|
|
|
19
32
|
// `ErrorEvent` only became a global in Node 26. On the 22/24 floor it is
|
|
20
33
|
// undefined, so `new ErrorEvent(...)` below would throw a ReferenceError inside
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@oxc-parser/binding-win32-arm64-msvc",
|
|
3
|
-
"version": "0.132.0",
|
|
4
|
-
"cpu": [
|
|
5
|
-
"arm64"
|
|
6
|
-
],
|
|
7
|
-
"main": "parser.win32-arm64-msvc.node",
|
|
8
|
-
"files": [
|
|
9
|
-
"parser.win32-arm64-msvc.node"
|
|
10
|
-
],
|
|
11
|
-
"description": "Oxc Parser Node API",
|
|
12
|
-
"keywords": [
|
|
13
|
-
"ast",
|
|
14
|
-
"estree",
|
|
15
|
-
"javascript",
|
|
16
|
-
"oxc",
|
|
17
|
-
"parser",
|
|
18
|
-
"typescript"
|
|
19
|
-
],
|
|
20
|
-
"author": "Boshen and oxc contributors",
|
|
21
|
-
"homepage": "https://oxc.rs/docs/guide/usage/parser",
|
|
22
|
-
"license": "MIT",
|
|
23
|
-
"engines": {
|
|
24
|
-
"node": "^20.19.0 || >=22.12.0"
|
|
25
|
-
},
|
|
26
|
-
"repository": {
|
|
27
|
-
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/oxc-project/oxc.git",
|
|
29
|
-
"directory": "napi/parser"
|
|
30
|
-
},
|
|
31
|
-
"bugs": "https://github.com/oxc-project/oxc/issues",
|
|
32
|
-
"publishConfig": {
|
|
33
|
-
"registry": "https://registry.npmjs.org/",
|
|
34
|
-
"access": "public"
|
|
35
|
-
},
|
|
36
|
-
"os": [
|
|
37
|
-
"win32"
|
|
38
|
-
]
|
|
39
|
-
}
|
package/runtime/node_modules/@oxc-parser/binding-win32-arm64-msvc/parser.win32-arm64-msvc.node
DELETED
|
Binary file
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@oxc-parser/binding-win32-x64-msvc",
|
|
3
|
-
"version": "0.132.0",
|
|
4
|
-
"cpu": [
|
|
5
|
-
"x64"
|
|
6
|
-
],
|
|
7
|
-
"main": "parser.win32-x64-msvc.node",
|
|
8
|
-
"files": [
|
|
9
|
-
"parser.win32-x64-msvc.node"
|
|
10
|
-
],
|
|
11
|
-
"description": "Oxc Parser Node API",
|
|
12
|
-
"keywords": [
|
|
13
|
-
"ast",
|
|
14
|
-
"estree",
|
|
15
|
-
"javascript",
|
|
16
|
-
"oxc",
|
|
17
|
-
"parser",
|
|
18
|
-
"typescript"
|
|
19
|
-
],
|
|
20
|
-
"author": "Boshen and oxc contributors",
|
|
21
|
-
"homepage": "https://oxc.rs/docs/guide/usage/parser",
|
|
22
|
-
"license": "MIT",
|
|
23
|
-
"engines": {
|
|
24
|
-
"node": "^20.19.0 || >=22.12.0"
|
|
25
|
-
},
|
|
26
|
-
"repository": {
|
|
27
|
-
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/oxc-project/oxc.git",
|
|
29
|
-
"directory": "napi/parser"
|
|
30
|
-
},
|
|
31
|
-
"bugs": "https://github.com/oxc-project/oxc/issues",
|
|
32
|
-
"publishConfig": {
|
|
33
|
-
"registry": "https://registry.npmjs.org/",
|
|
34
|
-
"access": "public"
|
|
35
|
-
},
|
|
36
|
-
"os": [
|
|
37
|
-
"win32"
|
|
38
|
-
]
|
|
39
|
-
}
|
|
Binary file
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-present VoidZero Inc. & Contributors
|
|
4
|
-
Copyright (c) 2023 Boshen
|
|
5
|
-
|
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
in the Software without restriction, including without limitation the rights
|
|
9
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
furnished to do so, subject to the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
SOFTWARE.
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@oxc-project/types",
|
|
3
|
-
"version": "0.132.0",
|
|
4
|
-
"description": "Types for Oxc AST nodes",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"AST",
|
|
7
|
-
"Parser"
|
|
8
|
-
],
|
|
9
|
-
"homepage": "https://oxc.rs",
|
|
10
|
-
"bugs": "https://github.com/oxc-project/oxc/issues",
|
|
11
|
-
"license": "MIT",
|
|
12
|
-
"author": "Boshen and oxc contributors",
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/oxc-project/oxc.git",
|
|
16
|
-
"directory": "npm/oxc-types"
|
|
17
|
-
},
|
|
18
|
-
"funding": {
|
|
19
|
-
"url": "https://github.com/sponsors/Boshen"
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"types.d.ts"
|
|
23
|
-
],
|
|
24
|
-
"type": "module",
|
|
25
|
-
"types": "types.d.ts"
|
|
26
|
-
}
|