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):**
This commit is contained in:
Donny/강동윤 2024-03-14 12:22:28 +09:00 committed by GitHub
parent 31ecd2a6c1
commit f988b66e1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 6 deletions

View File

@ -419,7 +419,7 @@ impl NodeModulesResolver {
module_specifier, base, self.target_env
);
{
if !module_specifier.starts_with('.') {
// Handle absolute path
let path = Path::new(module_specifier);

View File

@ -319,11 +319,13 @@ where
}
}
let path = self.base_url.join(module_specifier);
if !module_specifier.starts_with('.') {
let path = self.base_url.join(module_specifier);
// https://www.typescriptlang.org/docs/handbook/modules/reference.html#baseurl
if let Ok(v) = self.invoke_inner_resolver(base, &path.to_string_lossy()) {
return Ok(v);
// https://www.typescriptlang.org/docs/handbook/modules/reference.html#baseurl
if let Ok(v) = self.invoke_inner_resolver(base, &path.to_string_lossy()) {
return Ok(v);
}
}
self.invoke_inner_resolver(base, module_specifier)

View File

@ -2,7 +2,7 @@ use std::{
borrow::Cow,
env::current_dir,
fs::read_link,
io,
io::{self},
path::{Component, Path, PathBuf},
sync::Arc,
};