perf(cache): move package.json path into parse instead of cloning#1186
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1186 +/- ##
==========================================
- Coverage 93.78% 93.77% -0.01%
==========================================
Files 22 22
Lines 4216 4210 -6
==========================================
- Hits 3954 3948 -6
Misses 262 262 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 3.64%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Merge activity
|
) `find_package_json_impl` cloned `package_json_path` to pass into `PackageJson::parse` so the original could outlive the call for the `.inspect`/`.inspect_err` closures that record the file dependency. This replaces the combinator chain with a `match` that **moves** `package_json_path` into `parse` and reads the dependency path back from: - `package_json.path()` on success — `PackageJson` stores the path verbatim, and - `JSONError.path` on error — set from the same input path, dropping one unconditional `PathBuf` allocation on the parse-success path. The whole block is behind `path.package_json.get_or_try_init`, so this only fires on the first parse of each unique `package.json` over the resolver's lifetime (a cache miss). Behavior is unchanged: file/missing-dependency recording, error contents, and return values are identical. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
48b4149 to
aba01c3
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>
find_package_json_implclonedpackage_json_pathto pass intoPackageJson::parseso the original could outlive the call for the.inspect/.inspect_errclosures that record the file dependency.This replaces the combinator chain with a
matchthat movespackage_json_pathintoparseand reads the dependency path back from:package_json.path()on success —PackageJsonstores the path verbatim, andJSONError.pathon error — set from the same input path,dropping one unconditional
PathBufallocation on the parse-success path. The whole block is behindpath.package_json.get_or_try_init, so this only fires on the first parse of each uniquepackage.jsonover the resolver's lifetime (a cache miss).Behavior is unchanged: file/missing-dependency recording, error contents, and return values are identical.
🤖 Generated with Claude Code