|
1 |
| -use std::path::MAIN_SEPARATOR; |
2 |
| - |
3 | 1 | use anyhow::Result;
|
4 | 2 | use indexmap::IndexMap;
|
5 | 3 | use indoc::formatdoc;
|
6 |
| -use turbo_tasks::{RcStr, Value, ValueToString, Vc}; |
| 4 | +use turbo_tasks::{RcStr, Value, Vc}; |
7 | 5 | use turbo_tasks_fs::FileSystemPath;
|
8 | 6 | use turbopack::{transition::Transition, ModuleAssetContext};
|
9 | 7 | use turbopack_core::{
|
@@ -112,18 +110,18 @@ impl BaseLoaderTreeBuilder {
|
112 | 110 | self.inner_assets
|
113 | 111 | .insert(format!("MODULE_{i}").into(), module);
|
114 | 112 |
|
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(); |
119 | 115 |
|
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()); |
123 | 121 |
|
124 | 122 | Ok(format!(
|
125 | 123 | "[() => {identifier}, {path}, {relative_path}]",
|
126 |
| - path = StringifyJs(&module_path), |
| 124 | + path = StringifyJs(&module_path_str.as_str()), |
127 | 125 | relative_path = StringifyJs(&relative_path),
|
128 | 126 | ))
|
129 | 127 | }
|
|
0 commit comments