fix(linter/plugins): resolve JS plugins only with conditions Node.js supports#15248
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull Request Overview
This PR updates the module resolution configuration for external plugin loading to support the module-sync export condition and prioritize node and import conditions. The key change removes the main_fields configuration and updates the condition_names to better align with Node.js module resolution standards.
- Replaced
main_fieldswith updatedcondition_namesfor external plugin resolution - Added support for
module-syncexport condition with priority ordering - Added test fixtures (plugin15 and plugin16) to verify the new resolution behavior
Reviewed Changes
Copilot reviewed 23 out of 28 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_linter/src/config/config_builder.rs | Updated resolver configuration to use module-sync, node, and import condition names, removed main_fields |
| apps/oxlint/test/fixtures/load_paths/node_modules/plugin16/* | Added test plugin using module-sync export condition |
| apps/oxlint/test/fixtures/load_paths/node_modules/plugin15/* | Added test plugin with module and default exports to verify correct condition resolution |
| apps/oxlint/test/fixtures/load_paths/.oxlintrc.json | Added plugin15 and plugin16 to test configuration |
| apps/oxlint/test/fixtures/load_paths/output.snap.md | Updated snapshot to reflect new plugin loading order |
| Various other output.snap.md files | Updated snapshots reflecting diagnostic output ordering changes due to parallel execution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #15248 will not alter performanceComparing Summary
Footnotes
|
possibly |
bb2784f to
eb8bcb1
Compare
Merge activity
|
…supports (#15248) Fixes the `require` related error described in #14862 (comment). This was happening because Node.js does not use `module` condition but the plugin resolver used that. I aligned the conditions to what Node.js uses (I didn't include `node-addon` because it's not popular and requires detecting `--no-addons` to do it properly). https://nodejs.org/docs/v24.11.0/api/packages.html#conditional-exports I'm not sure why, but the test snapshot doesn't seem stable on my machine. cc @TheAlexLichter refs #14541
eb8bcb1 to
56c6627
Compare
Ah, I see. FYI I was running with |

Fixes the
requirerelated error described in #14862 (comment).This was happening because Node.js does not use
modulecondition but the plugin resolver used that. I aligned the conditions to what Node.js uses (I didn't includenode-addonbecause it's not popular and requires detecting--no-addonsto do it properly).https://nodejs.org/docs/v24.11.0/api/packages.html#conditional-exports
I'm not sure why, but the test snapshot doesn't seem stable on my machine.
cc @TheAlexLichter
refs #14541