From c1ce16c513fc0e3495ed1341eab4970e1c180e85 Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Wed, 11 Sep 2024 15:33:42 +0800 Subject: [PATCH] fix: context module alternative_requests --- crates/rspack_core/src/context_module.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/rspack_core/src/context_module.rs b/crates/rspack_core/src/context_module.rs index 3c03318d9d3..a72d833a8c6 100644 --- a/crates/rspack_core/src/context_module.rs +++ b/crates/rspack_core/src/context_module.rs @@ -1299,14 +1299,12 @@ fn alternative_requests( for item in std::mem::take(&mut items) { items.push(item.clone()); - // TODO resolveOptions.modules can be array for module in resolve_options.modules() { let dir = module.replace('\\', "/"); - let full_path: String = format!("{}{}", item.context.replace('\\', "/"), &item.request[1..]); - if full_path.starts_with(&dir) { + if item.request.starts_with(&format!("./{}/", dir)) { items.push(AlternativeRequest::new( item.context.clone(), - full_path[(dir.len() + 1)..].to_string(), + item.request[dir.len() + 3..].to_string(), )); } }