Skip to content

Commit f988b66

Browse files
authoredMar 14, 2024··
fix(es/module): Fix regression of resolving relative modules (#8748)
**Description:** - x-ref (vercel slack): https://vercel.slack.com/archives/C03S8ED1DKM/p1710371667695459?thread_ts=1710362018.271789&cid=C03S8ED1DKM **Related issue (if exists):**
1 parent 31ecd2a commit f988b66

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed
 

‎crates/swc_ecma_loader/src/resolvers/node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ impl NodeModulesResolver {
419419
module_specifier, base, self.target_env
420420
);
421421

422-
{
422+
if !module_specifier.starts_with('.') {
423423
// Handle absolute path
424424

425425
let path = Path::new(module_specifier);

‎crates/swc_ecma_loader/src/resolvers/tsc.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,13 @@ where
319319
}
320320
}
321321

322-
let path = self.base_url.join(module_specifier);
322+
if !module_specifier.starts_with('.') {
323+
let path = self.base_url.join(module_specifier);
323324

324-
// https://www.typescriptlang.org/docs/handbook/modules/reference.html#baseurl
325-
if let Ok(v) = self.invoke_inner_resolver(base, &path.to_string_lossy()) {
326-
return Ok(v);
325+
// https://www.typescriptlang.org/docs/handbook/modules/reference.html#baseurl
326+
if let Ok(v) = self.invoke_inner_resolver(base, &path.to_string_lossy()) {
327+
return Ok(v);
328+
}
327329
}
328330

329331
self.invoke_inner_resolver(base, module_specifier)

‎crates/swc_ecma_transforms_module/src/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{
22
borrow::Cow,
33
env::current_dir,
44
fs::read_link,
5-
io,
5+
io::{self},
66
path::{Component, Path, PathBuf},
77
sync::Arc,
88
};

0 commit comments

Comments
 (0)
Please sign in to comment.