Skip to content

Commit

Permalink
fix: should not assume module directories always exist (#5326)
Browse files Browse the repository at this point in the history
  • Loading branch information
h-a-n-a authored Jan 15, 2024
1 parent ccbc304 commit 3b576a3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crates/rspack_core/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,14 @@ Add the extension to the request.", suggestion, args.specifier));
.resolve_options
.as_deref()
.or(Some(&plugin_driver.options.resolve))
.and_then(|o| o.modules.as_ref().map(|m| m.join(", ")))
.expect("module directories should exist");
.and_then(|o| o.modules.as_ref().map(|m| m.join(", ")));
let module_directories = {
if let Some(module_directories) = module_directories {
format!(" ({module_directories}).")
} else {
".".to_string()
}
};
let resolver = plugin_driver.resolver_factory.get(dep);
let request = format!("./{}", args.specifier);
match resolver.resolve(base_dir, &request) {
Expand All @@ -151,7 +157,7 @@ Add the extension to the request.", suggestion, args.specifier));
"Did you mean './{}'?
Requests that should resolve in the current directory need to start with './'.
Requests that start with a name are treated as module requests and resolve within module directories ({module_directories}).
Requests that start with a name are treated as module requests and resolve within module directories{module_directories}
If changing the source code is not an option, there is also a resolve options called 'preferRelative'
which tries to resolve these kind of requests in the current directory too.",
Expand Down

1 comment on commit 3b576a3

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

name base current %
10000_development-mode + exec 1.64 s ± 23 ms 1.63 s ± 17 ms -0.60%
10000_development-mode_hmr + exec 994 ms ± 15 ms 996 ms ± 14 ms +0.23%
10000_production-mode + exec 2.8 s ± 16 ms 2.86 s ± 65 ms +2.04%
threejs_development-mode_10x + exec 2 s ± 24 ms 1.99 s ± 19 ms -0.72%
threejs_development-mode_10x_hmr + exec 1.31 s ± 4.5 ms 1.31 s ± 5.7 ms -0.05%
threejs_production-mode_10x + exec 6.1 s ± 128 ms 5.96 s ± 11 ms -2.33%

Please sign in to comment.