fix(node_resolver): incorrect resolution of require("..") (#30524)
Some checks are pending
ci / build libs (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions

Fixes https://github.com/denoland/deno/issues/30505
This commit is contained in:
Nathan Whitaker 2025-08-25 19:10:36 -07:00 committed by GitHub
parent 6e77e86896
commit 0d8732f012
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 23 additions and 7 deletions

View file

@ -553,10 +553,9 @@ impl<
// }
let p_str = path.to_str().unwrap();
let path = if p_str.ends_with('/') {
PathBuf::from(&p_str[p_str.len() - 1..])
} else {
path
let path = match p_str.strip_suffix('/') {
Some(s) => Cow::Borrowed(Path::new(s)),
None => Cow::Owned(path),
};
let maybe_file_type = self.sys.get_file_type(&path);
@ -570,7 +569,7 @@ impl<
.find(|e| self.sys.is_file(&path.join(e)));
Err(
UnsupportedDirImportError {
dir_url: UrlOrPath::Path(path),
dir_url: UrlOrPath::Path(path.into_owned()),
maybe_referrer: maybe_referrer.map(|r| r.display()),
suggested_file_name,
}
@ -607,7 +606,7 @@ impl<
Ok(
maybe_url
.map(UrlOrPath::Url)
.unwrap_or(UrlOrPath::Path(path)),
.unwrap_or(UrlOrPath::Path(path.into_owned())),
)
}
_ => {
@ -626,7 +625,7 @@ impl<
ModuleNotFoundError {
suggested_ext: self
.module_not_found_ext_suggestion(&path, resolved_method),
specifier: UrlOrPath::Path(path),
specifier: UrlOrPath::Path(path.into_owned()),
maybe_referrer: maybe_referrer.map(|r| r.display()),
}
.into(),

View file

@ -0,0 +1,13 @@
{
"tempDir": true,
"steps": [
{
"args": "bundle -o out.js ./repro/foo.cjs",
"output": "[WILDCARD]"
},
{
"args": "run -A out.js",
"output": "hello from index\n"
}
]
}

View file

@ -0,0 +1 @@
module.exports = "hello from index";

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,2 @@
const index = require("..");
console.log(index);