You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CachedPathImpl::is_dir (in src/cache.rs) only calls ctx.add_missing_dependency when fs.metadata() returns None (path absent). When the path exists but is not a directory (e.g., a regular file named node_modules), is_dir returns false without recording anything to missing_dependencies. This diverges from enhanced-resolve, which records the path in missingDependencies either way so that webpack/rspack watchers re-run resolution when the file/dir type flips.
Repro
Fixture:
/a/b/c/some.js (file)
/a/b/node_modules (REGULAR FILE — not a dir)
/a/node_modules/module/index.js (file inside real node_modules)
Webpack/rspack file watchers won't be notified when the user later replaces /a/b/node_modules (a file) with a real directory, so resolution stays stale and incremental rebuilds don't pick up the newly-installed package.
Needs auditing for over-tracking impact on other call sites (e.g., find_package_json's parent-walk loop), but the node_modules walk is the load-bearing case.
Test
Extend src/tests/dependencies.rs::warm_cache_missing_dependencies fixture with a regular file named node_modules at some ancestor, then assert both cold and warm missing_dependencies contain it (and remain equal).
Summary
CachedPathImpl::is_dir(insrc/cache.rs) only callsctx.add_missing_dependencywhenfs.metadata()returnsNone(path absent). When the path exists but is not a directory (e.g., a regular file namednode_modules),is_dirreturnsfalsewithout recording anything tomissing_dependencies. This diverges fromenhanced-resolve, which records the path inmissingDependencieseither way so that webpack/rspack watchers re-run resolution when the file/dir type flips.Repro
Fixture:
Resolve
modulefrom/a/b/c.enhanced-resolve (5.21.1)
missingDependenciesincludes:/a/b/c/node_modules(absent)/a/b/node_modules(exists as file — present)rspack-resolver cold path
missing_dependenciesincludes:/a/b/c/node_modules(absent)/a/b/node_modules) — missingWhy this matters
/a/b/node_modules(a file) with a real directory, so resolution stays stale and incremental rebuilds don't pick up the newly-installed package.None), while the cold path still doesn't.Suggested fix
In
src/cache.rs,is_dir:Needs auditing for over-tracking impact on other call sites (e.g.,
find_package_json's parent-walk loop), but the node_modules walk is the load-bearing case.Test
Extend
src/tests/dependencies.rs::warm_cache_missing_dependenciesfixture with a regular file namednode_modulesat some ancestor, then assert both cold and warmmissing_dependenciescontain it (and remain equal).Related: #236