Skip to content

Revisit special case for jest-runner-../../.. #597

@Boshen

Description

@Boshen

oxc-resolver/src/lib.rs

Lines 578 to 607 in 195e2f9

// TODO: add a new option for this legacy behavior?
// abnormal relative specifier like `jest-runner-../../..`
// which only works with `require` not ESM
// see also https://github.com/jestjs/jest/issues/15712
// it's kind of bug feature
if specifier.contains("/../..") || specifier.contains("../../") {
let path = Path::new(specifier).normalize_relative();
let mut owned = path.to_string_lossy().into_owned();
if specifier.ends_with('/') {
owned += "/";
}
let specifier_owned = Some(owned);
let normalized_specifier = specifier_owned.as_deref().unwrap();
let (package_name, subpath) = Self::parse_package_specifier(normalized_specifier);
if package_name == ".." {
if let Some(path) = self.load_node_modules(
cached_path,
normalized_specifier,
package_name,
subpath,
ctx,
)? {
return Ok(path);
}
}
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions