Repository navigation
feat(core): option to transform TypeScript dependencies under node_modules - #826
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 445f07f337
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…dules Adds OXC_TRANSFORM_ALL=typescript (TS-family extensions only, never .js) and a napi API — setTransformDeps/getTransformDeps/transformsDep — so a wrapping tool can enable it without leaking a variable into the user's process.env. A dependency's .ts file under node_modules no longer defers to Node's type stripper, which rejects it; OXC_TRANSFORM_ALL itself gains the same coverage. The pirates matcher asks the binding per file at require() time, and the mode latches on the first transform/resolve or at register() on the module.register() path, with a late call throwing. Implements #821
445f07f to
3f60b4a
Compare
The napi build regenerated index.js/index.d.ts but the WASI stubs are maintained separately; without the export, register.mjs hits a TypeError on the WASI module.register() path.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 182ac92953
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…read freezeTransformDeps() now returns the effective mode and it — not only an API override — travels in the registration data: a WASI hook worker's env is a snapshot from when Node spawned it, so a mode chosen through process.env after that would otherwise diverge between the require() matcher on this binding and the ESM hooks. setTransformDeps learns "off" so every mode is expressible, and the WASI .d.cts signature is updated.
The overrides pinned @emnapi/core and @emnapi/runtime to ^2.0.0-alpha.5 while the direct emnapi dependency resolved alpha.6; the version mismatch aborted every wasm32-wasip1 build in CI.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da787d1b80
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
An explicit setTransformDeps("off") is stored and must stay
distinguishable from a cleared override; returning null would make a
wrapper forwarding the answer fall back to the environment variable.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c2a2d5c1b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
init_resolver used to overwrite a consumed value that freezeTransformDeps had already latched, so a process.env.OXC_TRANSFORM_ALL change between registration and the first transform could still move the mode. Only initialize consumed when it is still unset.
Summary
Fixes #821. Adds an option to transform TypeScript dependencies under
node_moduleswithoutOXC_TRANSFORM_ALL's blanket coverage, on both module systems:OXC_TRANSFORM_ALL=typescript— transforms.ts/.mts/.cts/.tsxdependencies;node_modules.jsstays untouched. Existing grammar is preserved: absent, empty,0,falsemean off; any other truthy value still means all.setTransformDeps("typescript" | "all" | null)+getTransformDeps()+transformsDep(path)— the API a wrapper (e.g. Vite+) can call instead, so the choice never entersprocess.envand the user's script or child processes. A set mode takes precedence over the variable. The mode latches on the first transform or resolve — or atregister()itself on themodule.register()path, whose worker thread needs the value as a snapshot — and a later call with a different mode throws.Reproduction also showed the issue's claimed escape hatch does not cover
.tsdependencies:transformable_dependency()increate_resolvedeferred.tsundernode_modulesto Node's own type stripping, which rejects it, soOXC_TRANSFORM_ALL=1could not run such a file at all. Both the env mode andOXC_TRANSFORM_ALL=1now give TypeScript dependencies a real format so the loader transforms them.On the CommonJS side the
pirateshook disablesignoreNodeModulesand asks the binding per file (transformsDep), sorequire()of a TypeScript dependency follows the same mode and a latesetTransformDepsis honored there up to the latch.Known caveat, documented in the README: an older
@oxc-node/corecopy registered in the same process readsOXC_TRANSFORM_ALL=typescriptas transform-all (every non-0/falsevalue meant that).setTransformDepsis invisible to older copies and avoids the skew entirely.This PR is stacked on #822, whose
transform_output/register.mjschanges this builds on; the diff will shrink once that merges.Test plan
integrate-vitestcover the env mode, the setter API (including late-call rejection),.jsdeps staying untouched, and therequire()path —pnpm test/vp checkpass.module.register()) and 26.11 (registerHooks()): anode_modulesdep exporting.tsfails withERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPINGby default, imports fine underOXC_TRANSFORM_ALL=typescriptorsetTransformDeps("typescript"), and a decorator-using.jsdep undertypescriptmode still runs through Node untouched.