Skip to content

feat(core): accept an explicit tsconfig path through the API - #817

Merged
Brooooooklyn merged 6 commits into
mainfrom
claude/explicit-tsconfig-path-93vupp
Oct 10, 2026
Merged

Brooooooklyn merged 6 commits into
mainfrom
claude/explicit-tsconfig-path-93vupp

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Requested by Brooklyn · project thread

Closes #806

Before: a tool wrapping the loader could only pick a tsconfig by setting OXC_TSCONFIG_PATH (or TS_NODE_PROJECT), which also leaks into the user's script and every process it spawns, and a user-exported TS_NODE_PROJECT silently overrides it.

After: the wrapper calls setTsconfigPath(path) from @oxc-node/core before registering the loader. The config applies to the transform API and to the ESM resolve/load hooks (both registerHooks and the module.register worker thread), and process.env stays untouched.

import { setTsconfigPath } from "@oxc-node/core";

setTsconfigPath("./tsconfig.app.json");
await import("@oxc-node/core/register");

How: the path is stored in a process-wide override that init_resolver reads (and marks as consumed) under the same lock, so it feeds the existing TsconfigSource::Manual path. Precedence is API, then TS_NODE_PROJECT, then OXC_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 a OnceLock, a call after the first transform or resolve throws, unless it names the same config (so registering twice stays harmless). The export is added to index.js, index.d.ts and both WASI loaders, the README documents it, and tsconfig-discovery.spec.ts covers 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

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
@Brooooooklyn Brooooooklyn self-assigned this Oct 10, 2026
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
@Brooooooklyn
Brooooooklyn marked this pull request as ready for review October 10, 2026 03:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 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-10T03:37:57.155286Z c20cdd4 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: 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".

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

@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: 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".

Comment thread src/lib.rs Resolved
Comment thread packages/core/oxc-node.wasi.cjs Resolved
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

@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: 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".

Comment thread src/lib.rs Resolved
@Brooooooklyn
Brooooooklyn merged commit e70a368 into main Oct 10, 2026
131 of 132 checks passed
@Brooooooklyn
Brooooooklyn deleted the claude/explicit-tsconfig-path-93vupp branch October 10, 2026 08:43
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.

Accept an explicit tsconfig path through the API, not only TS_NODE_PROJECT / OXC_TSCONFIG_PATH

2 participants