Skip to content

feat(core): option to transform TypeScript dependencies under node_modules - #826

Merged
Brooooooklyn merged 6 commits into
mainfrom
feat/821-transform-ts-deps
Oct 12, 2026
Merged

Brooooooklyn merged 6 commits into
mainfrom
feat/821-transform-ts-deps

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Summary

Fixes #821. Adds an option to transform TypeScript dependencies under node_modules without OXC_TRANSFORM_ALL's blanket coverage, on both module systems:

  • OXC_TRANSFORM_ALL=typescript — transforms .ts/.mts/.cts/.tsx dependencies; node_modules .js stays untouched. Existing grammar is preserved: absent, empty, 0, false mean 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 enters process.env and 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 at register() itself on the module.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 .ts dependencies: transformable_dependency() in create_resolve deferred .ts under node_modules to Node's own type stripping, which rejects it, so OXC_TRANSFORM_ALL=1 could not run such a file at all. Both the env mode and OXC_TRANSFORM_ALL=1 now give TypeScript dependencies a real format so the loader transforms them.

On the CommonJS side the pirates hook disables ignoreNodeModules and asks the binding per file (transformsDep), so require() of a TypeScript dependency follows the same mode and a late setTransformDeps is honored there up to the latch.

Known caveat, documented in the README: an older @oxc-node/core copy registered in the same process reads OXC_TRANSFORM_ALL=typescript as transform-all (every non-0/false value meant that). setTransformDeps is invisible to older copies and avoids the skew entirely.

This PR is stacked on #822, whose transform_output/register.mjs changes this builds on; the diff will shrink once that merges.

Test plan

  • New integration specs in integrate-vitest cover the env mode, the setter API (including late-call rejection), .js deps staying untouched, and the require() path — pnpm test / vp check pass.
  • Manually verified on Node 24.21 (module.register()) and 26.11 (registerHooks()): a node_modules dep exporting .ts fails with ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING by default, imports fine under OXC_TRANSFORM_ALL=typescript or setTransformDeps("typescript"), and a decorator-using .js dep under typescript mode still runs through Node untouched.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T15:37:10.434804Z 257959e New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/core/register.mjs Resolved
…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
@Brooooooklyn
Brooooooklyn force-pushed the feat/821-transform-ts-deps branch from 445f07f to 3f60b4a Compare October 12, 2026 04:16
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/core/register.mjs Resolved
…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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/lib.rs Resolved
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/lib.rs Resolved
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.
@Brooooooklyn
Brooooooklyn merged commit e25e546 into main Oct 12, 2026
67 checks passed
@Brooooooklyn
Brooooooklyn deleted the feat/821-transform-ts-deps branch October 12, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an option to transform TypeScript dependencies without OXC_TRANSFORM_ALL

1 participant