Repository navigation
feat(core): accept an explicit tsconfig path through the API - #817
Conversation
Add `setTsconfigPath(path)`, which pins one tsconfig for the process like `OXC_TSCONFIG_PATH` does but without touching `process.env`, so a wrapper's choice does not leak into the user's script or the processes it spawns. It takes precedence over `TS_NODE_PROJECT` and `OXC_TSCONFIG_PATH`, and must run before the first transform or resolve; a later call with a different path throws. Closes #806 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01F3MJsqPq6Ld1Ja17wrxmC7
The native current directory is not the loader's working directory under WASI, so a relative path resolved at call time missed the config. Join it in `init_resolver` instead, exactly as the environment variables are. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01F3MJsqPq6Ld1Ja17wrxmC7
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01F3MJsqPq6Ld1Ja17wrxmC7
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: 7127671da6
ℹ️ 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".
Under WASI the hook thread instantiates its own copy of the binding, so an override set on the main thread never reached the ESM hooks there: an .mts entry ignored it on Node.js below 26.2. register.mjs now passes the path through `data` and esm.mjs applies it in `initialize`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01F3MJsqPq6Ld1Ja17wrxmC7
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2302b4e860
ℹ️ 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".
A late call naming the config that TS_NODE_PROJECT or OXC_TSCONFIG_PATH already selected threw, because only the API override was compared. Record the effective path when the resolver reads it and compare against that. Also declare the new functions in the WASI type declarations. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01F3MJsqPq6Ld1Ja17wrxmC7
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c20cdd4edd
ℹ️ 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".
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01F3MJsqPq6Ld1Ja17wrxmC7
Requested by Brooklyn · project thread
Closes #806
Before: a tool wrapping the loader could only pick a tsconfig by setting
OXC_TSCONFIG_PATH(orTS_NODE_PROJECT), which also leaks into the user's script and every process it spawns, and a user-exportedTS_NODE_PROJECTsilently overrides it.After: the wrapper calls
setTsconfigPath(path)from@oxc-node/corebefore registering the loader. The config applies to the transform API and to the ESM resolve/load hooks (bothregisterHooksand themodule.registerworker thread), andprocess.envstays untouched.How: the path is stored in a process-wide override that
init_resolverreads (and marks as consumed) under the same lock, so it feeds the existingTsconfigSource::Manualpath. Precedence is API, thenTS_NODE_PROJECT, thenOXC_TSCONFIG_PATH, then discovery, which stays the default. A relative path resolves against the loader's working directory, exactly like the environment variables (the native current directory is not that directory under WASI);null/undefined/""clears the override. Because the resolver is aOnceLock, a call after the first transform or resolve throws, unless it names the same config (so registering twice stays harmless). The export is added toindex.js,index.d.tsand both WASI loaders, the README documents it, andtsconfig-discovery.spec.tscovers precedence over both env vars, env left untouched, the hooks path, and the late-call error.🤖 Generated with Claude Code
https://claude.ai/code/session_01F3MJsqPq6Ld1Ja17wrxmC7