Revert "perf: do not canonicalize the entry path (#848)" (#204)

This commit is contained in:
JounQin
2026-05-19 11:30:39 +08:00
committed by GitHub
parent b5838da1b5
commit 2fffbc9128
10 changed files with 25 additions and 7 deletions
+1 -1
View File
@@ -1 +1 @@
22.17.0
22.22.3
-1
View File
@@ -8,6 +8,5 @@ test('resolver', () => {
const resolver = new ResolverFactory()
const directory = import.meta.dirname
const resolution = resolver.sync(directory, 'is-even')
console.log(resolution)
assert.strictEqual(resolution.path, pnpapi.resolveRequest('is-even', directory))
})
+1
View File
@@ -0,0 +1 @@
!node_modules
+1
View File
@@ -0,0 +1 @@
../../foo/node_modules/foo
+4 -2
View File
@@ -320,8 +320,10 @@ impl<Fs: FileSystem> ResolverGeneric<Fs> {
) -> Result<Resolution, ResolveError> {
ctx.with_fully_specified(self.options.fully_specified);
let cached_path = self.cache.value(path);
let cached_path = self.require(&cached_path, specifier, tsconfig, ctx)?;
let cached_path = self.load_realpath(&self.cache.value(path))?;
let cached_path =
self.require(&self.cache.value(&cached_path), specifier, tsconfig, ctx)?;
let path = self.load_realpath(&cached_path)?;
let package_json = self.find_package_json_for_a_package(&cached_path, ctx)?;
+16
View File
@@ -212,6 +212,22 @@ fn resolve_dot() {
}
}
#[test]
fn symlink_with_nested_node_modules() {
let f = super::fixture_root().join("symlink-with-nested-node_modules");
let resolver = Resolver::default();
let resolved_path =
resolver.resolve(f.join("bar/node_modules/foo"), "dep").map(|r| r.full_path());
assert_eq!(resolved_path, Ok(f.join("foo/node_modules/dep/index.js")));
let resolver = Resolver::new(ResolveOptions { symlinks: false, ..ResolveOptions::default() });
assert_eq!(
resolver.resolve(f.join("bar/node_modules/foo"), "dep"),
Err(ResolveError::NotFound("dep".into()))
);
}
#[test]
fn abnormal_relative() {
let f = super::fixture_root().join("integration/abnormal-relative-with-node_modules");
+2 -3
View File
@@ -174,7 +174,7 @@ fn test() {
fn test_unsupported_targets() {
use crate::ResolveError;
let Some(SymlinkFixturePaths { root, temp_path }) =
let Some(SymlinkFixturePaths { root: _, temp_path }) =
prepare_symlinks("temp.test_unsupported_targets").unwrap()
else {
return;
@@ -200,10 +200,9 @@ fn test_unsupported_targets() {
// from `FsCachedPath::find_package_json` when trying to canonicalize the full path of `package.json`.
// * Otherwise, a `ResolveError::NotFound` will be returned.
let dos_device_temp_path = get_dos_device_path(&temp_path).unwrap();
let dos_device_root = get_dos_device_path(&root).unwrap();
assert_eq!(
resolver_with_symlinks.resolve(&dos_device_temp_path, "./index.js"),
Err(ResolveError::PathNotSupported(dos_device_root))
Err(ResolveError::PathNotSupported(dos_device_temp_path))
);
}
View File