Skip to content

Commit 76f53ad

Browse files
committed
Fix relative_path computation
1 parent 31ffeaa commit 76f53ad

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

crates/next-core/src/base_loader_tree.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
use std::path::MAIN_SEPARATOR;
2-
31
use anyhow::Result;
42
use indexmap::IndexMap;
53
use indoc::formatdoc;
6-
use turbo_tasks::{RcStr, Value, ValueToString, Vc};
4+
use turbo_tasks::{RcStr, Value, Vc};
75
use turbo_tasks_fs::FileSystemPath;
86
use turbopack::{transition::Transition, ModuleAssetContext};
97
use turbopack_core::{
@@ -112,18 +110,18 @@ impl BaseLoaderTreeBuilder {
112110
self.inner_assets
113111
.insert(format!("MODULE_{i}").into(), module);
114112

115-
let module_path = module.ident().path().to_string().await?;
116-
117-
let project_root_with_trailing_sep =
118-
format!("{}{}", self.project_root.to_string().await?, MAIN_SEPARATOR);
113+
let module_path = module.ident().path().await?.clone_value();
114+
let module_path_str = module_path.to_string();
119115

120-
let relative_path = module_path
121-
.strip_prefix(&project_root_with_trailing_sep)
122-
.unwrap_or(module_path.as_str());
116+
let relative_path = self
117+
.project_root
118+
.await?
119+
.get_path_to(&module_path)
120+
.unwrap_or(module_path_str.as_str());
123121

124122
Ok(format!(
125123
"[() => {identifier}, {path}, {relative_path}]",
126-
path = StringifyJs(&module_path),
124+
path = StringifyJs(&module_path_str.as_str()),
127125
relative_path = StringifyJs(&relative_path),
128126
))
129127
}

0 commit comments

Comments
 (0)