Repository navigation
fix(core): honour --preserve-symlinks and write the OXC_LOG log to stderr - #857
Conversation
…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>
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: 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".
…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>
There was a problem hiding this comment.
💡 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".
… 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>
Closes #845
--preserve-symlinkswas ignoredoxc-node's resolver always returned a module's real path, so under
--preserve-symlinksa symlinked package got a differentimport.meta.url(and module identity) than plain Node gives it.oxc-node now reads the flags as Node.js does:
NODE_PRESERVE_SYMLINKS=1, thenNODE_OPTIONS(split the way Node splits it, quotes included), thenprocess.execArgv. The last mention wins,_counts as-, and the--no-prefix works.processthrough napi, so the same code works on the main thread, themodule.register()worker and WASI. No new binding export is needed.symlinksoption is turned off: for the entry point (noparentURL) under--preserve-symlinks-main, and for every other module under--preserve-symlinks. This matches Node'sdefaultResolve. The per-conditions resolver cache now also keys on that setting.OXC_LOGwrote to stdoutThe 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
--no-, underscores, and quotedNODE_OPTIONSvalues.preserve-symlinks.spec.tschecks 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_OPTIONSandNODE_PRESERVE_SYMLINKS=1. It also covers a TypeScript importer, andOXC_LOG=debugleaving 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