Repository navigation
fix: resolve symlink with nested node_modules - #125
Conversation
WalkthroughThe changes include removal of trailing commas in assertion macros for formatting consistency, addition of a Changes
Sequence Diagram(s)sequenceDiagram
participant Test as symlink_with_nested_node_modules()
participant Resolver1 as Resolver (symlinks enabled)
participant Resolver2 as Resolver (symlinks disabled)
participant FileSystem
Test->>Resolver1: resolve("dep", from "bar/node_modules/foo")
Resolver1->>FileSystem: load real path (follow symlinks)
FileSystem-->>Resolver1: real path resolved
Resolver1->>FileSystem: require module at real path
FileSystem-->>Resolver1: module resolved at foo/node_modules/dep/index.js
Resolver1-->>Test: returns resolved path
Test->>Resolver2: resolve("dep", from "bar/node_modules/foo")
Resolver2->>FileSystem: do not load real path (no symlinks)
Resolver2->>FileSystem: require module at cached path
FileSystem-->>Resolver2: module not found
Resolver2-->>Test: returns NotFound error
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🔇 Additional comments (1)
✨ Finishing Touches
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. 🪧 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.
Pull Request Overview
This PR fixes issues with resolving symlink paths in nested node_modules and cleans up several formatting issues in tests.
- Adjusts assertion formatting in tests
- Adds a new test case for handling symlink resolution with nested node_modules
- Removes extraneous trailing commas in assertions
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/tests/resolve.rs | Added new test for nested symlink resolution and updated assertions formatting |
| src/tests/alias.rs | Removed extraneous comma in error case assertion |
| examples/resolver.rs | Removed extraneous trailing comma from assert macro |
Files not reviewed (1)
- fixtures/symlink-with-nested-node_modules/.gitignore: Language not supported
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to f7b01b5 in 1 minute and 29 seconds. Click for details.
- Reviewed
94lines of code in8files - Skipped
0files when reviewing. - Skipped posting
7draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. examples/resolver.rs:11
- Draft comment:
Removed extraneous trailing comma in assert! call. Formatting change only. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
2. fixtures/symlink-with-nested-node_modules/.gitignore:1
- Draft comment:
New .gitignore file added to ensure node_modules is not ignored. This looks fine. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
3. fixtures/symlink-with-nested-node_modules/bar/node_modules/foo:1
- Draft comment:
Symlink file with target '../../foo' looks correct for testing nested node_modules. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
4. src/tests/alias.rs:257
- Draft comment:
Removed trailing comma in the expected error value for MatchedAliasNotFound. Pure formatting fix. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
5. src/tests/resolve.rs:158
- Draft comment:
New test 'symlink_with_nested_node_modules' added to verify symlink resolution. Consider confirming that the extension string '.js:' (used on lines 159 and 168) is intentional and not a typo ('.js' may be expected). Also, remove debugging print statements if not needed. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The comment is asking for confirmation about intentions rather than pointing out clear issues. The ".js:" extension appears in multiple tests and is likely intentional given the test passes. Debug prints could be removed but this is a test file where prints can be useful for debugging failures. None of these points identify clear problems that need fixing. I could be wrong about the ".js:" extension - it does look unusual and could be a legitimate typo. The debug prints do add noise to test output. Even if ".js:" is unusual, asking for confirmation violates our rules. If it was wrong, the test would fail. Debug prints in tests are acceptable. The comment should be deleted as it primarily asks for confirmation rather than identifying clear issues, and makes suggestions about debug prints which are acceptable in test code.
6. src/tests/resolve.rs:159
- Draft comment:
Typo: The extension string ".js:" in the options might contain an unintended colon. Did you mean ".js"? - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The test is specifically about symlink behavior and passes with.js:. The fact that it's used consistently in both resolver configurations within the same test and the test passes suggests this is intentional. Without access to the actual resolver implementation or documentation, I can't be certain if the colon serves a special purpose, but the evidence suggests it's not a typo. I could be wrong if this is actually a bug that happens to work. The test passing doesn't necessarily mean the colon is correct. While true, we should assume the author knows what they're doing unless we have strong evidence otherwise. The consistent usage and passing tests suggest this is intentional. The comment should be removed as we don't have strong evidence that.js:is a typo, and the test passes with this configuration.
7. src/tests/resolve.rs:168
- Draft comment:
Typo: The extension string ".js:" here might contain an extra colon. Please verify if this is intended or should be ".js". - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The extension string appears in a test file and is used consistently in both test cases. The test is passing with this extension string. Since this is test code and the tests pass, the extension string is likely intentional. Even if it was a typo, it's not causing any issues. The comment is asking for verification rather than pointing out a clear problem. I could be wrong about the extension string being intentional - maybe it really is a typo that happens to work. The test passing doesn't necessarily mean the code is correct. Even if it is a typo, the comment violates our rules by asking for verification ("Please verify if...") rather than making a clear assertion. We should not keep comments that ask the author to check things. Delete the comment because it asks for verification rather than pointing out a clear issue, and the extension string appears to be working as intended in the tests.
Workflow ID: wflow_R06gcbOX3tmLzw0i
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
fixtures/symlink-with-nested-node_modules/bar/node_modules/foois excluded by!**/node_modules/**fixtures/symlink-with-nested-node_modules/foo/node_modules/dep/index.jsis excluded by!**/node_modules/**
📒 Files selected for processing (4)
examples/resolver.rs(1 hunks)fixtures/symlink-with-nested-node_modules/.gitignore(1 hunks)src/tests/alias.rs(1 hunks)src/tests/resolve.rs(2 hunks)
🧰 Additional context used
🪛 GitHub Actions: Code Coverage
src/tests/resolve.rs
[error] 165-165: Test failure in 'tests::resolve::symlink_with_nested_node_modules': assertion left == right failed. Expected Ok path but got Err(NotFound("dep")).
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test (windows-latest)
🔇 Additional comments (4)
examples/resolver.rs (1)
11-11: LGTM! Clean formatting improvement.The trailing comma removal improves consistency with similar assertion statements across the codebase.
fixtures/symlink-with-nested-node_modules/.gitignore (1)
1-1: Good addition for test fixture integrity.The negation pattern
!node_modulesensures that the node_modules directory structure is preserved in the repository for testing symlink resolution behavior, which is essential for the new test case.src/tests/alias.rs (1)
257-257: LGTM! Consistent formatting improvement.The trailing comma removal aligns with the formatting cleanup being applied across the test files.
src/tests/resolve.rs (1)
71-71: LGTM! Consistent formatting improvement.The trailing comma removal aligns with the formatting cleanup applied across other test files.
1fe0ae5 to
0273940
Compare
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed 1fe0ae5 in 53 seconds. Click for details.
- Reviewed
85lines of code in5files - Skipped
0files when reviewing. - Skipped posting
6draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. examples/resolver.rs:11
- Draft comment:
Removed trailing comma from assert! call for consistent formatting. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
2. fixtures/symlink-with-nested-node_modules/.gitignore:1
- Draft comment:
Added .gitignore entry to ensure the node_modules directory in test fixtures is not ignored. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
3. fixtures/symlink-with-nested-node_modules/bar/node_modules/foo:1
- Draft comment:
Consider adding a trailing newline at the end of the file for POSIX compliance. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
4. src/tests/alias.rs:257
- Draft comment:
Removed extraneous trailing comma in the Err variant assert_eq! for consistency. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
5. src/tests/resolve.rs:70
- Draft comment:
Removed unnecessary trailing comma in assert_eq! call in issue238_resolve test. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
6. src/tests/resolve.rs:155
- Draft comment:
Added new test 'symlink_with_nested_node_modules' to verify resolution behavior with symlinked directories containing nested node_modules. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
Workflow ID: wflow_ZBEc4xx8YaIr6UMP
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed 0273940 in 56 seconds. Click for details.
- Reviewed
81lines of code in5files - Skipped
0files when reviewing. - Skipped posting
5draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. examples/resolver.rs:11
- Draft comment:
Removed trailing comma in the assert! macro for cleaner syntax. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
2. fixtures/symlink-with-nested-node_modules/bar/node_modules/foo:1
- Draft comment:
File is missing a trailing newline; consider adding one for POSIX compliance. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
3. src/tests/alias.rs:256
- Draft comment:
Removed an extraneous trailing comma from the expected error in assert_eq! for consistency. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
4. src/tests/resolve.rs:70
- Draft comment:
Removed an unnecessary trailing comma from the assert_eq! call for resolving config file. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
5. src/tests/resolve.rs:155
- Draft comment:
Added a new test to verify symlink resolution with nestednode_modules. Consider removing debug print statements if they are no longer needed. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
Workflow ID: wflow_OfDeWjNs8juPH3Or
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
39a7bcf to
3be0788
Compare
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed 3be0788 in 42 seconds. Click for details.
- Reviewed
79lines of code in5files - Skipped
0files when reviewing. - Skipped posting
6draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. examples/resolver.rs:11
- Draft comment:
Removed an unnecessary trailing comma in the assert! call. This improves code formatting. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
2. fixtures/symlink-with-nested-node_modules/.gitignore:1
- Draft comment:
The .gitignore file now explicitly includes node_modules. This ensures the fixture’s node_modules directory is tracked. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
3. fixtures/symlink-with-nested-node_modules/bar/node_modules/foo:1
- Draft comment:
File added without a trailing newline. Consider adding a newline at the end for POSIX compliance. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
4. src/tests/alias.rs:257
- Draft comment:
Removed the extra trailing comma in the assert_eq! macro. This cleanup is in line with Rust’s formatting best practices. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
5. src/tests/resolve.rs:68
- Draft comment:
Removed an extra trailing comma in the assert_eq! call. This minor formatting update ensures consistency. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
6. src/tests/resolve.rs:151
- Draft comment:
Added a new test 'symlink_with_nested_node_modules' to verify module resolution behavior when dealing with symlinked nested node_modules. The test correctly distinguishes behavior when symlink resolution is enabled versus disabled. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
Workflow ID: wflow_U42H5efQt6Fmx7wb
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
f507b01 to
86d2aff
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #125 +/- ##
==========================================
- Coverage 93.43% 93.40% -0.03%
==========================================
Files 13 13
Lines 2892 2897 +5
==========================================
+ Hits 2702 2706 +4
- Misses 190 191 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed 86d2aff in 1 minute and 16 seconds. Click for details.
- Reviewed
59lines of code in3files - Skipped
0files when reviewing. - Skipped posting
6draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. src/tests/resolve.rs:155
- Draft comment:
Great test covering symlink resolution in nested node_modules. Consider adding an inline comment describing why the expected resolution here is to 'foo/node_modules/dep/index.js' when symlinks are enabled. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. src/tests/resolve.rs:163
- Draft comment:
When testing error cases (e.g. symlinks disabled), consider matching on the error variant rather than asserting full equality to avoid brittleness if error messages change. - Reason this comment was not posted:
Comment looked like it was already resolved.
3. tests/resolve_test.rs:10
- Draft comment:
Good coverage for handling Unicode paths. The 'chinese' test ensures non-ASCII file names are resolved correctly. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
4. tests/resolve_test.rs:195
- Draft comment:
The 'nested_symlinks' test effectively verifies the fix for symlink resolution in nested structures. This is crucial for the PR and appears well‐structured. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
5. tests/resolve_test.rs:220
- Draft comment:
The 'windows_symlinked_longfilename' test is a nice addition ensuring that very long Windows paths are handled properly. Documentation in the comments is helpful. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
6. tests/resolve_test.rs:252
- Draft comment:
The 'dual_condition_names' test shows coverage for multiple condition names. This is useful for ensuring compatibility with both ESM and CJS environments. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
Workflow ID: wflow_pcBi4jvnnVMJR4M6
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
CodSpeed Performance ReportMerging #125 will not alter performanceComparing Summary
|
86d2aff to
e69f9b9
Compare
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed e69f9b9 in 51 seconds. Click for details.
- Reviewed
59lines of code in3files - Skipped
0files when reviewing. - Skipped posting
9draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. src/tests/resolve.rs:155
- Draft comment:
Good test for symlink resolution: it clearly distinguishes behavior when symlinks are enabled vs disabled. Consider adding a brief inline comment explaining why the disabled case should return NotFound. - Reason this comment was not posted:
Confidence changes required:30%<= threshold50%None
2. src/tests/resolve.rs:172
- Draft comment:
The Windows normalization test is well written; it would be helpful to note that the expected path separator normalization is platform‐specific. - Reason this comment was not posted:
Confidence changes required:20%<= threshold50%None
3. tests/resolve_test.rs:10
- Draft comment:
The 'chinese' test effectively validates Unicode file paths. No changes needed. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
4. tests/resolve_test.rs:20
- Draft comment:
The 'styled_components' test covers both CJS and ESM resolution paths; the use of alias_fields and main_fields is clear. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
5. tests/resolve_test.rs:119
- Draft comment:
Tests for 'ipaddr_js', 'decimal_js' and related modules nicely cover extension alias and condition scenarios. Inline comments might clarify the rationale for different resolver configurations. - Reason this comment was not posted:
Confidence changes required:20%<= threshold50%None
6. tests/resolve_test.rs:194
- Draft comment:
The 'nested_symlinks' test effectively validates nested node_modules resolution via symlinks. A brief inline note on the mapping (e.g. from 'apps/web/nm/@repo/typescript-config' to 'nm/index.js') would aid clarity. - Reason this comment was not posted:
Confidence changes required:30%<= threshold50%None
7. tests/resolve_test.rs:218
- Draft comment:
The Windows long filename symlink test is comprehensive. Consider a comment noting that the test ensures mitigation of OS path length quirks. - Reason this comment was not posted:
Confidence changes required:20%<= threshold50%None
8. tests/resolve_test.rs:241
- Draft comment:
The 'package_json_with_bom' test covers an important edge case. The test is clear and concise. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
9. tests/resolve_test.rs:252
- Draft comment:
The 'dual_condition_names' test is a well-structured verification of multiple condition names. No changes required. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
Workflow ID: wflow_lZ0u1rXNvSTUnsl7
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
|
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed 5d96179 in 40 seconds. Click for details.
- Reviewed
15lines of code in1files - Skipped
0files when reviewing. - Skipped posting
1draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. src/tests/symlink.rs:196
- Draft comment:
Updated expected error value: using dos_device_temp_path directly now, instead of its parent's parent's path. Ensure this change aligns with the intended error reporting behavior. - Reason this comment was not posted:
Comment did not seem useful. Confidence is useful =30%<= threshold50%The comment is asking the PR author to ensure that the change aligns with the intended behavior, which violates the rule against asking the author to confirm their intention or ensure behavior. However, it does point out a specific change in the code, which could be useful if rephrased to focus on the change itself rather than asking for confirmation.
Workflow ID: wflow_WWUDJ6ayVha33EJe
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
| Err(ResolveError::PathNotSupported( | ||
| dos_device_temp_path.parent().unwrap().parent().unwrap().to_path_buf() | ||
| )) | ||
| Err(ResolveError::PathNotSupported(dos_device_temp_path)) |



Important
Improves module resolution to handle symlinks conditionally and adds a test for nested
node_moduleswith symlinks.src/lib.rsto handle symlinks conditionally based onResolveOptions.symlink_with_nested_node_modulesinsrc/tests/resolve.rsto verify resolution behavior with symlinks and nestednode_modules.examples/resolver.rsandsrc/tests/alias.rsby removing trailing commas..gitignoreinfixtures/symlink-with-nested-node_modulesto ensurenode_modulesis not ignored in test fixtures.This description was created by
for 5d96179. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit
New Features
Chores