Repository navigation
feat: return traced output layout and hoist rootDir-resolvable version - #76
Merged
Merged
Conversation
- prefer the version resolvable from rootDir when hoisting ties - return `TracedLayout` from `traceNodeModules` and add `tracedLayout` hook - write hoisted versions in generated package.json ref nitrojs/nitro#4731
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
⛔ Files ignored due to path filters (4)
📒 Files selected for processing (6)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #76 +/- ##
==========================================
+ Coverage 80.70% 81.51% +0.80%
==========================================
Files 5 5
Lines 596 622 +26
Branches 172 181 +9
==========================================
+ Hits 481 507 +26
Misses 84 84
Partials 31 31 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- compare root-resolvable version by version, not path (same version may be installed twice) - relink hoisted version over a stale top-level link so it matches the layout - resolve relative inputs against cwd (like nft) for `layout.files` - fix windows path assertion in tests; clarify layout JSDoc
pi0
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context: nitrojs/nitro#4731. Bundled code can import two versions of the same external package, for example app code using root
[email protected]and a bundled workspace package using its nested[email protected]. Neither version has a traced parent, so nf3 always hoisted the newest one. The other version was copied into.nf3/but nothing could reach it, and callers had no way to find out where each version ended up.Changes
rootDir(<rootDir>/node_modules/<name>, compared by version, since the same version can be installed in more than one place). Newest is now only the last fallback, and the result doesn't depend on input order.traceNodeModulesnow returns aTracedLayout(it returned nothing before), and a newhooks.tracedLayouthook receives it once all files are written:packages[name]:{ name, hoisted, versions: { [v]: { path, outPath, hoisted } } }, withoutPathrelative tooutDir(e.g.node_modules/.nf3/[email protected])files: maps each input file (as passed) to its output path relative tooutDirwritePackageJson: each dependency version is now the hoisted version. Before, it was the first version key, which could disagree with thenode_modules/<name>symlink.Tests
@fixture/hoist-dep1.0.0 at the root and 2.0.0 underpackages/composition/node_modules, passed only as direct inputs and tested in both orders. Checks the hoisted version, the layout and hook,files, that every reported path can be imported, andpackage.json.nitro-liblayout and that the nested parentnode_modulessymlink is still created.🤖 Generated with AI assistant
Summary by CodeRabbit