Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions libs/node_resolver/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,10 @@ 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 = p_str
.strip_suffix('/')
.map(Path::new)
.unwrap_or(path.as_path());

let maybe_file_type = self.sys.get_file_type(&path);
match maybe_file_type {
Expand All @@ -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.to_path_buf()),
maybe_referrer: maybe_referrer.map(|r| r.display()),
suggested_file_name,
}
Expand Down Expand Up @@ -607,7 +606,7 @@ impl<
Ok(
maybe_url
.map(UrlOrPath::Url)
.unwrap_or(UrlOrPath::Path(path)),
.unwrap_or(UrlOrPath::Path(path.to_path_buf())),
)
}
_ => {
Expand All @@ -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.to_path_buf()),
maybe_referrer: maybe_referrer.map(|r| r.display()),
}
.into(),
Expand Down
13 changes: 13 additions & 0 deletions tests/specs/bundle/require_dotdot/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions tests/specs/bundle/require_dotdot/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "hello from index";
1 change: 1 addition & 0 deletions tests/specs/bundle/require_dotdot/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 2 additions & 0 deletions tests/specs/bundle/require_dotdot/repro/foo.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const index = require("..");
console.log(index);
Loading