-
Couldn't load subscription status.
- Fork 6
feat: resolve symbol linked missing files when symlinks enabled
#109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR resolves an issue where missing files that are accessed through symbolic links are not properly tracked for file watching. When symlinks are enabled and a file resolution fails, the resolver now attempts to determine the real path of the missing file by traversing its parent directories to find an existing symlinked ancestor.
- Adds logic to resolve symbolic link paths for missing files when
symlinksoption is enabled - Introduces a new
is_filemethod that handles missing dependency tracking for symlinked files - Replaces direct
is_filecalls with the new method that handles symlink resolution
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/lib.rs | Implements symlink resolution for missing files and refactors file existence checking |
| src/tests/missing.rs | Adds test case for missing files in symbol-linked folders |
| fixtures/pnpm-workspace/packages/missing/package.json | Creates test fixture package with missing files |
| fixtures/pnpm-workspace/packages/app/package.json | Adds dependency on missing package for testing |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/lib.rs
Outdated
| let right_path = path.strip_prefix(ancestor).unwrap(); | ||
|
|
||
| return Some(real_path.join(right_path)); |
Copilot
AI
Oct 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using unwrap() can cause panics. Consider using proper error handling or a more descriptive error message if this operation is expected to always succeed.
| let right_path = path.strip_prefix(ancestor).unwrap(); | |
| return Some(real_path.join(right_path)); | |
| if let Ok(right_path) = path.strip_prefix(ancestor) { | |
| return Some(real_path.join(right_path)); | |
| } |
CodSpeed Performance ReportMerging #109 will degrade performances by 33.48%Comparing Summary
Benchmarks breakdown
|
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…' into fix/missng_files_resolve_to_real
201f25e to
f6fac32
Compare
Why
for issue web-infra-dev/rspack#11239 (comment)
When rspack-resolver failed, the missing files were just recorded by symbol-linked paths.
In some cases, Watchpack will not emit FS change events when symbol-linked files are changed.
Solution
When a missing file is detected, add its "real" path to the missing file dependencies.
Since the file does not exist in the file system, we attempt to canonicalize it by its ancestors' path, then assemble a real path.
For example:
/root/app/node_module/lib/dist/esm/index.mjsis not existed./root/app/node_module/lib/is symbol linked to real path/root/lib/So the real path is
/root/lib/dist/esm/index.mjsWe get the both symbolic path and real path in missing files in a failure resolving, so it makes watchpack to watch the right files.