Conversation
The only value for this option in the ecosystem is node_modules. This option also slightly impacts performance.
WalkthroughThis set of changes removes support for custom module directories from the module resolution logic. The Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Resolver
participant Cache
Caller->>Resolver: load_node_modules(cached_path, ...)
loop Walk up directory tree
Resolver->>Cache: cached_node_modules(current_path, ...)
alt node_modules found
Resolver->>Cache: Check for package directory
alt package found
Resolver->>Cache: Load package exports
else file/directory fallback
Resolver->>Cache: Try as file or directory
end
end
end
Resolver-->>Caller: Return resolved module or error
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
💤 Files with no reviewable changes (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/fs_cache.rs (1)
313-318: Minor inefficiency & doubleis_dircallInside
cached_node_moduleswe already callcache.is_dir(&cached_path, ctx)before returning the directory.
The extraself.cache.is_dir(cached_path, ctx)guard executed in the caller (load_node_modules) therefore checks the parent directory twice on the hot-path.Consider eliminating one of the checks to shave a hash-lookup per iteration:
- if !self.cache.is_dir(cached_path, ctx) { - continue; - } - - let Some(cached_path) = cached_path.cached_node_modules(self.cache.as_ref(), ctx) else { + let Some(cached_path) = cached_path.cached_node_modules(self.cache.as_ref(), ctx) else { continue; };Only a micro-optimisation, but safe and measurable when resolving thousands of paths.
src/lib.rs (1)
773-838:load_node_modules– small readability / perf tweaks
- The outer
is_dircheck (see previous comment) duplicates the inner one performed bycached_node_modules.- Variable reuse (
cached_pathis reassigned several times) makes the loop harder to follow.A lightweight refactor keeps the behaviour but avoids the double check and clarifies intent:
for ancestor in std::iter::successors(Some(cached_path), |p| p.parent()) { - if !self.cache.is_dir(ancestor, ctx) { - continue; - } - - let Some(node_modules) = ancestor.cached_node_modules(self.cache.as_ref(), ctx) else { + let Some(node_modules) = ancestor.cached_node_modules(self.cache.as_ref(), ctx) else { continue; }; + // `node_modules` definitely exists here. if !package_name.is_empty() { let package_dir = node_modules.normalize_with(package_name, self.cache.as_ref()); ...Behaviour is identical, but we save one metadata lookup and reduce shadowing.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
README.md(1 hunks)src/cache.rs(0 hunks)src/fs_cache.rs(1 hunks)src/lib.rs(2 hunks)src/options.rs(0 hunks)
💤 Files with no reviewable changes (2)
- src/cache.rs
- src/options.rs
🧰 Additional context used
🪛 GitHub Actions: CI
src/lib.rs
[error] 201-201: Rust compiler error E0560: struct ResolveOptions has no field named modules.
[error] 201-201: Rust compiler error E0609: no field modules on type ResolveOptions. Available fields are: tsconfig, alias, alias_fields, condition_names, description_files, and others.
🔇 Additional comments (1)
README.md (1)
193-194: Documentation aligns with code – looks goodThe
modulesoption is now correctly moved to “Unimplemented Options”, reflecting the removal in the codebase. No further action required.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #484 +/- ##
==========================================
+ Coverage 93.73% 93.80% +0.06%
==========================================
Files 13 13
Lines 2825 2791 -34
==========================================
- Hits 2648 2618 -30
+ Misses 177 173 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #484 will not alter performanceComparing Summary
|
## 🤖 New release
* `oxc_resolver`: 7.0.1 -> 8.0.0 (⚠ API breaking changes)
### ⚠ `oxc_resolver` breaking changes
```text
--- failure inherent_method_missing: pub method removed or renamed ---
Description:
A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/inherent_method_missing.ron
Failed in:
ResolveOptions::with_module, previously in file /tmp/.tmpCfZ3uE/oxc_resolver/src/options.rs:342
--- failure struct_pub_field_missing: pub struct's pub field removed or renamed ---
Description:
A publicly-visible struct has at least one public field that is no longer available under its prior name. It may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/struct_pub_field_missing.ron
Failed in:
field description_files of struct ResolveOptions, previously in file /tmp/.tmpCfZ3uE/oxc_resolver/src/options.rs:47
field modules of struct ResolveOptions, previously in file /tmp/.tmpCfZ3uE/oxc_resolver/src/options.rs:119
--- failure trait_method_added: pub trait method added ---
Description:
A non-sealed public trait added a new method without a default implementation, which breaks downstream implementations of the trait
ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/trait_method_added.ron
Failed in:
trait method oxc_resolver::CachedPath::is_node_modules in file /tmp/.tmpoUaDz8/oxc-resolver/src/cache.rs:65
trait method oxc_resolver::CachedPath::inside_node_modules in file /tmp/.tmpoUaDz8/oxc-resolver/src/cache.rs:67
--- failure trait_method_missing: pub trait method removed or renamed ---
Description:
A trait method is no longer callable, and may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#major-any-change-to-trait-item-signatures
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/trait_method_missing.ron
Failed in:
method node_modules of trait CachedPath, previously in file /tmp/.tmpCfZ3uE/oxc_resolver/src/cache.rs:65
method module_directory of trait CachedPath, previously in file /tmp/.tmpCfZ3uE/oxc_resolver/src/cache.rs:67
method cached_node_modules of trait CachedPath, previously in file /tmp/.tmpCfZ3uE/oxc_resolver/src/cache.rs:74
```
<details><summary><i><b>Changelog</b></i></summary><p>
<blockquote>
##
[8.0.0](oxc_resolver-v7.0.1...oxc_resolver-v8.0.0)
- 2025-05-01
### <!-- 1 -->Bug Fixes
- fix incorrect return of package.json when a workspace module has
`node_modules`
([#482](#482))
### <!-- 2 -->Performance
- cache whether a path is `node_modules` or inside `node_modules`
([#490](#490))
- remove a useless `load_as_directory` call
([#487](#487))
### <!-- 4 -->Refactor
- [**breaking**] remove `description_files` option
([#488](#488))
- [**breaking**] remove `modules` options
([#484](#484))
</blockquote>
</p></details>
---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Documentation**
- Added a new changelog entry for version 8.0.0, highlighting a bug fix,
performance improvements, and breaking changes.
- **Chores**
- Updated the package version to 8.0.0 in project files.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
Some libraries use this option to resolve |
That won't work for scoped packages? |
|
See #493 |
## 🤖 New release
* `oxc_resolver`: 8.0.0 -> 9.0.0 (⚠ API breaking changes)
* `oxc_napi_resolver`: 8.0.0
### ⚠ `oxc_resolver` breaking changes
```text
--- failure constructible_struct_adds_field: externally-constructible struct adds field ---
Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/constructible_struct_adds_field.ron
Failed in:
field ResolveOptions.modules in /tmp/.tmpTBvVad/oxc-resolver/src/options.rs:114
--- failure trait_method_added: pub trait method added ---
Description:
A non-sealed public trait added a new method without a default implementation, which breaks downstream implementations of the trait
ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/trait_method_added.ron
Failed in:
trait method oxc_resolver::CachedPath::module_directory in file /tmp/.tmpTBvVad/oxc-resolver/src/cache.rs:69
trait method oxc_resolver::CachedPath::cached_node_modules in file /tmp/.tmpTBvVad/oxc-resolver/src/cache.rs:76
```
<details><summary><i><b>Changelog</b></i></summary><p>
## `oxc_resolver`
<blockquote>
##
[9.0.0](oxc_resolver-v8.0.0...oxc_resolver-v9.0.0)
- 2025-05-09
### <!-- 1 -->Bug Fixes
- hash import does not need to load from node_modules
([#501](#501))
### <!-- 7 -->Chore
- add `--tsconfig` to example
([#505](#505))
- publish `oxc_napi_resolver`
([#496](#496))
</blockquote>
## `oxc_napi_resolver`
<blockquote>
##
[8.0.0](https://github.com/oxc-project/oxc-resolver/releases/tag/oxc_napi_resolver-v8.0.0)
- 2025-05-09
### <!-- 0 -->Features
- *(napi)* add mimalloc
([#423](#423))
- [**breaking**] Rust Edition 2024
([#402](#402))
- expose `package_json_path`
([#376](#376))
- *(napi)* expose module type info in ResolveResult
([#223](#223))
- *(napi)* add tracing via `OXC_LOG:DEBUG`
([#202](#202))
- *(napi)* add async API
([#191](#191))
- add `imports_fields` option
([#138](#138))
- add more builder functions for options
([#110](#110))
- *(napi)* support wasi target
([#31](#31))
- add file_dependencies and missing_dependencies API
([#50](#50))
- *(napi)* expose cloneWithOptions and clearCache methods
([#40](#40))
- *(napi)* update the doc and type for tsconfig references
([#24](#24))
- *(napi)* add options
([#19](#19))
- *(resolver)* add tracing-subscriber feature
([#904](#904))
- *(resolver)* tsconfig project references
([#862](#862))
- *(resolver)* add thiserror
([#847](#847))
- *(resolver)* implement nested alias field
([#795](#795))
- *(resolver)* implement tsconfig-paths
([#750](#750))
- *(resolver)* implement configurable `exports_fields` option
([#733](#733))
- *(resolver)* implement `main_fields`
- *(resolver)* implement resolveToContext
([#694](#694))
- *(resolver)* implement restrictions (path only)
([#693](#693))
- *(resolver)* implement fully specified
([#687](#687))
- *(resolver)* imports field
([#681](#681))
- *(resolver)* finish most of exports field
([#674](#674))
- *(resolver)* port the rest of the exports field tests
([#659](#659))
- *(resolver)* implement symlinks
([#582](#582))
- *(resolver)* complete query and fragment parsing
([#579](#579))
- *(resolver)* add preferRelative and preferAbsolute
([#577](#577))
- *(resolver)* implement roots
([#576](#576))
- *(resolver)* implement fallback
([#572](#572))
- *(resolver)* implement enforceExtension
([#566](#566))
- *(resolver)* implement descriptionFiles option
([#565](#565))
- *(resolver)* implement the basics of path alias
([#564](#564))
- *(resolver)* accept different file system implementations
([#562](#562))
- *(resolver)* implement browser field
([#561](#561))
- *(resolver)* implement scoped packages
([#558](#558))
- *(resolver)* port incorrect description file test
([#557](#557))
- *(resolver)* implement extension_alias
([#556](#556))
- *(resolver)* port resolve tests
([#555](#555))
- *(resolver)* resolve extensions
([#549](#549))
- *(resolver)* add resolver test fixtures
([#542](#542))
### <!-- 1 -->Bug Fixes
- hash import does not need to load from node_modules
([#501](#501))
- *(napi)* `new ResolverFactory()` options should be optional
([#256](#256))
- *(napi)* update buggy NAPI-RS versions
([#225](#225))
- canonicalize is not supported on wasi target
([#124](#124))
- resolve "browser" field when "exports" is present
([#59](#59))
### <!-- 4 -->Refactor
- [**breaking**] remove `description_files` option
([#488](#488))
- [**breaking**] remove `modules` options
([#484](#484))
- vitest ([#380](#380))
- apply latest `cargo +nightly fmt`
([#281](#281))
- selectively parse package_json fields instead of parsing everything
([#103](#103))
- *(resolver)* clean up some code and tests
- *(resolver)* change internal funcs to non-pub by moving to unit tests
([#682](#682))
### <!-- 7 -->Chore
- publish `oxc_napi_resolver`
([#496](#496))
- *(napi)* make mimalloc optional to build
([#495](#495))
- *(README)* add wasm usage example
- *(README)* crates.io badge use recent downloads
- *(napi)* auto download wasm binding on webcontainer
([#471](#471))
- use root package.json for napi build
([#469](#469))
- *(deps)* update github-actions
([#444](#444))
- *(deps)* lock file maintenance npm packages
([#436](#436))
- bump napi
([#404](#404))
- *(deps)* lock file maintenance npm packages
([#391](#391))
- *(deps)* lock file maintenance rust crates
([#390](#390))
- *(README)* clarify Rust and node.js usages
- add dprint
([#326](#326))
- *(deps)* update napi-rs to 3.0.0-alpha
- `cargo upgrade` && `pnpm upgrade`
- *(deps)* update napi-rs to 3.0.0-alpha
- update napi changes
- *(deps)* update rust crate napi-derive to 3.0.0-alpha
- *(deps)* update rust crate napi to 3.0.0-alpha
- *(deps)* update napi-rs to 2.16.8
- *(napi)* make napi binary smaller with minimal tracing features
([#213](#213))
- *(napi)* remove tokio
([#212](#212))
- document directory is an absolute path for `resolve(directory,
specifier)`
([#206](#206))
- re-enable the wasi build
([#193](#193))
- use pnpm workspace
([#182](#182))
- *(deps)* update rust crates
([#176](#176))
- *(napi)* update NAPI-RS cli version and binding template
([#111](#111))
- update project github url
- *(deps)* update pnpm to v8.14.1
([#52](#52))
- *(deps)* update pnpm to v8.14.0
([#48](#48))
- *(deps)* update pnpm to v8.13.1
([#42](#42))
- remove FIXME comments
- *(napi)* align `*Fields` user options with enhanced-resolve
([#35](#35))
- *(deps)* update pnpm to v8.12.1
([#21](#21))
- add some doc for napi TsconfigOptions
([#20](#20))
- *(deps)* update pnpm to v8.12.0
([#18](#18))
- *(README)* adding debugging command from Rspack
- *(deps)* update pnpm to v8.11.0
([#9](#9))
- *(resolver)* remove tracing_subscriber
([#1362](https://github.com/oxc-project/oxc-resolver/pull/1362))
- *(resolver)* improve documentation
([#591](#591))
### <!-- 8 -->CI
- check for napi .d.index changes
([#491](#491))
- *(release-napi)* support `riscv64gc-unknown-linux-gnu` and
`s390x-unknown-linux-gnu`
([#451](#451))
</blockquote>
</p></details>
---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
The only value for this option in the ecosystem is
node_modules.This option also slightly impacts performance.
Summary by CodeRabbit
modulesoption from supported options.node_modulesresolution./node_modules.