Skip to content

fix(core): honour --preserve-symlinks and write the OXC_LOG log to stderr - #857

Merged
Brooooooklyn merged 3 commits into
mainfrom
fix/issue-845
Oct 17, 2026
Merged

Brooooooklyn merged 3 commits into
mainfrom
fix/issue-845

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Closes #845

--preserve-symlinks was ignored

oxc-node's resolver always returned a module's real path, so under --preserve-symlinks a symlinked package got a different import.meta.url (and module identity) than plain Node gives it.

oxc-node now reads the flags as Node.js does:

  • Sources, in order: NODE_PRESERVE_SYMLINKS=1, then NODE_OPTIONS (split the way Node splits it, quotes included), then process.execArgv. The last mention wins, _ counts as -, and the --no- prefix works.
  • They are read once from process through napi, so the same code works on the main thread, the module.register() worker and WASI. No new binding export is needed.
  • When the flags apply, oxc_resolver's symlinks option is turned off: for the entry point (no parentURL) under --preserve-symlinks-main, and for every other module under --preserve-symlinks. This matches Node's defaultResolve. The per-conditions resolver cache now also keys on that setting.

OXC_LOG wrote to stdout

The tracing layer used fmt::layer()'s default writer, stdout, so the log interleaved with the program's output. It now uses .with_writer(std::io::stderr).

Tests

  • A Rust unit test covers flag parsing: precedence, the env var, --no-, underscores, and quoted NODE_OPTIONS values.
  • preserve-symlinks.spec.ts checks that oxc-node's output equals plain Node's for a symlinked package and a symlinked entry point, under no flag, --preserve-symlinks, --preserve_symlinks, a later --no-preserve-symlinks, --preserve-symlinks-main, NODE_OPTIONS and NODE_PRESERVE_SYMLINKS=1. It also covers a TypeScript importer, and OXC_LOG=debug leaving stdout to the program. 7 of these fail without the change. The entry-point cases are skipped on Windows, where file symlinks need elevated privileges.

🤖 Generated with Claude Code

…derr

- The resolver always returned a module's real path. Read Node.js'
  `--preserve-symlinks` and `--preserve-symlinks-main` the way Node.js does,
  from `NODE_PRESERVE_SYMLINKS=1`, `NODE_OPTIONS` and `process.execArgv`,
  and turn off oxc_resolver's `symlinks` option for the entry point under
  the latter and for every other module under the former.
- `OXC_LOG` wrote its log to stdout, mixed into the program's output; write
  it to stderr.

Closes #845

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 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-17T03:36:22.034700Z cd2374b 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: 2a7be525ed

ℹ️ 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 src/lib.rs Resolved
…rr checks

- Under --preserve-symlinks a linked node_modules/@oxc-node/core keeps the
  fixture's path, from which the WASI binding package cannot be found;
  import register.mjs by its real file URL instead.
- CI sets OXC_LOG=debug globally, and the log now goes to stderr, which the
  stdin/TTY specs check; unset it there as the other specs do.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@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: 3566ccaf62

ℹ️ 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
… them

- Node.js accepts `--preserve-symlinks=<anything>` (and the `-main` and
  `--no-` forms) and ignores the value; strip it before matching.
- Each Worker is its own Node.js environment, on its own thread, and may be
  started with its own execArgv; cache the flags per thread instead of for
  the whole process, so the first thread to resolve no longer decides for
  every other.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Brooooooklyn
Brooooooklyn merged commit 1a610f0 into main Oct 17, 2026
67 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/issue-845 branch October 17, 2026 03:59
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.

--preserve-symlinks is ignored, and OXC_LOG writes to stdout

1 participant