mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
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
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:
parent
6e77e86896
commit
0d8732f012
5 changed files with 23 additions and 7 deletions
|
@ -553,10 +553,9 @@ impl<
|
||||||
// }
|
// }
|
||||||
|
|
||||||
let p_str = path.to_str().unwrap();
|
let p_str = path.to_str().unwrap();
|
||||||
let path = if p_str.ends_with('/') {
|
let path = match p_str.strip_suffix('/') {
|
||||||
PathBuf::from(&p_str[p_str.len() - 1..])
|
Some(s) => Cow::Borrowed(Path::new(s)),
|
||||||
} else {
|
None => Cow::Owned(path),
|
||||||
path
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let maybe_file_type = self.sys.get_file_type(&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)));
|
.find(|e| self.sys.is_file(&path.join(e)));
|
||||||
Err(
|
Err(
|
||||||
UnsupportedDirImportError {
|
UnsupportedDirImportError {
|
||||||
dir_url: UrlOrPath::Path(path),
|
dir_url: UrlOrPath::Path(path.into_owned()),
|
||||||
maybe_referrer: maybe_referrer.map(|r| r.display()),
|
maybe_referrer: maybe_referrer.map(|r| r.display()),
|
||||||
suggested_file_name,
|
suggested_file_name,
|
||||||
}
|
}
|
||||||
|
@ -607,7 +606,7 @@ impl<
|
||||||
Ok(
|
Ok(
|
||||||
maybe_url
|
maybe_url
|
||||||
.map(UrlOrPath::Url)
|
.map(UrlOrPath::Url)
|
||||||
.unwrap_or(UrlOrPath::Path(path)),
|
.unwrap_or(UrlOrPath::Path(path.into_owned())),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -626,7 +625,7 @@ impl<
|
||||||
ModuleNotFoundError {
|
ModuleNotFoundError {
|
||||||
suggested_ext: self
|
suggested_ext: self
|
||||||
.module_not_found_ext_suggestion(&path, resolved_method),
|
.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()),
|
maybe_referrer: maybe_referrer.map(|r| r.display()),
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
|
|
13
tests/specs/bundle/require_dotdot/__test__.jsonc
Normal file
13
tests/specs/bundle/require_dotdot/__test__.jsonc
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1
tests/specs/bundle/require_dotdot/index.js
Normal file
1
tests/specs/bundle/require_dotdot/index.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
module.exports = "hello from index";
|
1
tests/specs/bundle/require_dotdot/package.json
Normal file
1
tests/specs/bundle/require_dotdot/package.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{}
|
2
tests/specs/bundle/require_dotdot/repro/foo.cjs
Normal file
2
tests/specs/bundle/require_dotdot/repro/foo.cjs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
const index = require("..");
|
||||||
|
console.log(index);
|
Loading…
Add table
Add a link
Reference in a new issue