Defer to native import-text on Node 26.5+ - #395
Merged
Conversation
Node 26.5.0 added `--experimental-import-text` (nodejs/node#62300), which gates `import x from './f' with { type: 'text' }`. nub already provides text imports on every version that parses the `with` syntax (Node 18.20+) via its loader polyfill (loadTextImport). Per the additive contract, defer to Node's own textStrategy where it now exists and keep the polyfill only below it. - feature_matrix: import-text Unflag row [26.5.0, inf) so nub injects --experimental-import-text (open-ended; never default-on through Node 27). Below the floor the flag is not injected and is stripped from an inherited NODE_OPTIONS (it is a "bad option" there). - preload-common.cjs (fast tier): feature-detect native support via process.allowedNodeEnvironmentFlags; on 26.5+ nextLoad to native, else loadTextImport. preload-async-hooks.mjs (compat tier) always polyfills -- that tier tops out at Node 22.14, below 26.5. - docs: Modern APIs row now reads "polyfilled below Node 26.5, native above", floored at Node 18.20 (the `with`-syntax parse floor). Verified byte-for-byte parity against `node --experimental-import-text` on 26.5.0; polyfill path on 26.4.0/18.20.4; SyntaxError on 18.19.1. Claude-Session: https://claude.ai/code/session_01BgByKuKHWvYLhy6NSgdMkh
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the fast-tier load hook now defers import … with { type: "text" } to Node's native --experimental-import-text on 26.5+, keeping the polyfill below.
- Add
import-textto the feature matrix — a single open-endedUnflag("--experimental-import-text")band[26.5.0, ∞)infeature_matrix.rs, slotting into the existing derived-floor machinery with no special-casing. - Fast-tier native deferral —
preload-common.cjsfeature-detects native support viaprocess.allowedNodeEnvironmentFlags(NATIVE_IMPORT_TEXT) and steps aside tonextLoadon 26.5+, else polyfills viacore.loadTextImport. - Compat-tier comment —
preload-async-hooks.mjsdocuments that its tier tops out at 22.14, so native import-text is never reachable there. - Tests —
flags.rsandfeature_matrix.rscover inject at/above 26.5, the--no-experimental-import-textopt-out,NODE_OPTIONSstripping below the floor, andunflag_floor == 26.5.0. - Docs — a new runtime-table row plus prose ("polyfilled below Node 26.5, native above", floor 18.20).
The change is clean, self-consistent, and well-scoped. Verified independently:
- The Node fact is grounded —
--experimental-import-textlanded in nodejs/node#62300 (semver-minor, experimental, flag-gated), matching the 26.5.0 placement in the matrix and evidence string. - The fast-tier deferral is correct: nub's resolve hook returns
{ url, shortCircuit }with noformat, sonextLoad(url, context)reaches Node's default load with thetype: "text"attribute intact and nativetextStrategyengages. - The compat-tier claim holds: that tier is 18.19–22.14, and the forced-async-tier path (
node_hook_compose_broken) is bounded to 22.15–24.11.0 — both below 26.5 — sopreload-async-hooks.mjsnever runs on a native-capable Node. - No regression: deferring to
nextLoadis strictly more permissive than the prior unconditional short-circuit, so a user load hook chained after nub's still observestype: "text"on 26.5+.
Claude Opus | 𝕏
This was referenced Jul 9, 2026
colinhacks
added a commit
that referenced
this pull request
Jul 9, 2026
The salvaged test comments referenced the env-signal design from the closed #396 branch (__NUB_NATIVE_IMPORT_TEXT); the merged #395 mechanism is the NATIVE_IMPORT_TEXT feature-detect const in preload-common.cjs. Comments only. Claude-Session: https://claude.ai/code/session_01Gp4tAn3Y66MWpAdGZm9VmL
colinhacks
added a commit
that referenced
this pull request
Jul 9, 2026
… 26.5 native) (#397) * test: pin cross-tier import-text behavior (22.13 compat / 24.4 fast / 26.5 native) Claude-Session: https://claude.ai/code/session_0144KrmfsBDfzFZnHAMaH6E3 * test: fix doc-comment references to the merged native-defer mechanism The salvaged test comments referenced the env-signal design from the closed #396 branch (__NUB_NATIVE_IMPORT_TEXT); the merged #395 mechanism is the NATIVE_IMPORT_TEXT feature-detect const in preload-common.cjs. Comments only. Claude-Session: https://claude.ai/code/session_01Gp4tAn3Y66MWpAdGZm9VmL
colinhacks
added a commit
that referenced
this pull request
Jul 10, 2026
…d set (#398) nub injects `--experimental-*` flags to unflag Node features early, with several open-ended version bands on the premise that once a flag exists Node accepts it forever. That premise is false: Node keeps some unflagged flags as no-ops but hard-removes others (`--experimental-policy`, `--experimental-network-imports`; `--experimental-permission` was deleted at 24.0 when it stabilized to `--permission`). Injecting a removed flag is a `node: bad option` startup abort, so an open-ended band would crash nub on a future Node that drops the flag. Probe the target Node's `process.allowedNodeEnvironmentFlags` once, cache it per (path, mtime), and intersect it with the version-band inject set in `compute_inject_flags` (Stage 4). A flag the running Node does not accept is dropped, so injection self-corrects with no nub release when Node removes a flag. Probe unavailable falls back to the prior version-band behavior. The probe clears NODE_OPTIONS so an inherited preload can't pollute or side-effect it. A host-Node invariant test asserts the intersection drops nothing on a current, supported Node (nub only injects env-allowed flags). Refs #395.
Contributor
Author
|
Shipped in v0.4.6: https://github.com/nubjs/nub/releases/tag/v0.4.6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Node 26.5.0 added
--experimental-import-text(nodejs/node#62300) forimport x from './f' with { type: "text" }. nub already polyfills text imports; this defers to nativetextStrategywhere it exists.import-textUnflag[26.5.0, ∞)→ inject the flag; stripped below the floor.allowedNodeEnvironmentFlags; 26.5+nextLoads to native, else polyfills.Byte-parity vs
node --experimental-import-texton 26.5.0; polyfill on 26.4.0/18.20.4.