perf: borrow relative main field instead of allocating a "./" prefix#1187
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1187 +/- ##
=======================================
Coverage 93.77% 93.77%
=======================================
Files 22 22
Lines 4210 4212 +2
=======================================
+ Hits 3948 3950 +2
Misses 262 262 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Merge activity
|
…1187) `load_as_directory` prefixed every `main` field that didn't already start with `./` or `../` with `format!("./{main_field}")`, allocating a `String` for the common `"main": "index.js"` / `"dist/index.js"` shapes (the dominant CJS package-entry path). `CachedPath::normalize_with` treats a leading `./` (`Component::CurDir`) as a no-op, so a bare relative field collapses to the identical `CachedPath` whether or not the `./` is present. This borrows the field directly and only builds the owned `./`-prefixed form when it is actually required: - an **empty** field — must become `./` to resolve the directory itself, and - an **absolute** path — whose `RootDir`/`Prefix` head must stay behind the `./` so it is joined rather than replacing the package directory. Resolution results are unchanged (the owned form is kept for exactly the cases where `normalize_with` would otherwise diverge). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
d53849d to
4e04a04
Compare
## 🤖 New release * `oxc_resolver`: 11.20.0 -> 11.21.0 * `oxc_resolver_napi`: 11.20.0 -> 11.21.0 <details><summary><i><b>Changelog</b></i></summary><p> ## `oxc_resolver` <blockquote> ## [11.21.0](v11.20.0...v11.21.0) - 2026-06-03 ### <!-- 0 -->🚀 Features - *(tsconfig)* support package.json imports field in extends ([#1199](#1199)) (by @Boshen) ### <!-- 1 -->🐛 Bug Fixes - *(tsconfig)* apply each referenced project's own `allowJs` ([#1198](#1198)) (by @shulaoda) - make symlink_metadata VPath-aware for Yarn PnP ([#1183](#1183)) (by @Boshen) ### <!-- 4 -->⚡ Performance - borrow relative main field instead of allocating a "./" prefix ([#1187](#1187)) (by @Boshen) - *(cache)* move package.json path into parse instead of cloning ([#1186](#1186)) (by @Boshen) - eliminate symlink stat syscalls by reusing canonicalization ([#1184](#1184)) (by @Boshen) - reduce resolution syscalls by unifying stat and lstat ([#1182](#1182)) (by @Boshen) ### <!-- 9 -->💼 Other - add baselines for each package manager x node_modules layout ([#1176](#1176)) (by @Boshen) ### Contributors * @shulaoda * @Boshen * @renovate[bot] </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). Co-authored-by: oxc-guard[bot] <276638029+oxc-guard[bot]@users.noreply.github.com>
load_as_directoryprefixed everymainfield that didn't already start with./or../withformat!("./{main_field}"), allocating aStringfor the common"main": "index.js"/"dist/index.js"shapes (the dominant CJS package-entry path).CachedPath::normalize_withtreats a leading./(Component::CurDir) as a no-op, so a bare relative field collapses to the identicalCachedPathwhether or not the./is present. This borrows the field directly and only builds the owned./-prefixed form when it is actually required:./to resolve the directory itself, andRootDir/Prefixhead must stay behind the./so it is joined rather than replacing the package directory.Resolution results are unchanged (the owned form is kept for exactly the cases where
normalize_withwould otherwise diverge).🤖 Generated with Claude Code