Skip to content

Commit b78a061

Browse files
fireairforceyuzheng14
authored andcommitted
fix(turbopack): normalize Windows absolute imports to filesystem-root-relative request (#155)
1 parent 08237e9 commit b78a061

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • turbopack/crates/turbopack-core/src/resolve

turbopack/crates/turbopack-core/src/resolve/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,14 +2112,19 @@ async fn resolve_internal_inline(
21122112
if let Some(fs_path) = disk_fs.try_from_sys_path(disk_fs_vc, sys_path, None)
21132113
{
21142114
let root_path = disk_fs_vc.root().owned().await?;
2115+
// Windows absolute requests should be normalized through the
2116+
// filesystem root. Otherwise an absolute request can keep the
2117+
// importer's lookup path in the resolved identity chain, which may
2118+
// create a different module record from a relative request to the same
2119+
// physical file.
21152120
let (relative_lookup_path, relative_path) = if let Some(relative_path) =
2116-
lookup_path.get_relative_path_to(&fs_path)
2117-
{
2118-
(lookup_path.clone(), relative_path)
2119-
} else if let Some(relative_path) =
21202121
root_path.get_relative_path_to(&fs_path)
21212122
{
21222123
(root_path.clone(), relative_path)
2124+
} else if let Some(relative_path) =
2125+
lookup_path.get_relative_path_to(&fs_path)
2126+
{
2127+
(lookup_path.clone(), relative_path)
21232128
} else {
21242129
continue;
21252130
};

0 commit comments

Comments
 (0)