Unverified Commit 8389b9f7 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: remove `clone_value` again (#81539)

```
ast-grep run --pattern '$$$X.await?.clone_value()' --rewrite '$$$X.owned().await?' --lang rust -U
```

This was originally removed in #75852, but added again in #80634 for no apparent reason.
parent e3a1aba8
...@@ -454,7 +454,7 @@ pub async fn project_new( ...@@ -454,7 +454,7 @@ pub async fn project_new(
turbo_tasks.spawn_once_task({ turbo_tasks.spawn_once_task({
let tt = turbo_tasks.clone(); let tt = turbo_tasks.clone();
async move { async move {
benchmark_file_io(tt, container.project().node_root().await?.clone_value()) benchmark_file_io(tt, container.project().node_root().owned().await?)
.await .await
.inspect_err(|err| tracing::warn!(%err, "failed to benchmark file IO")) .inspect_err(|err| tracing::warn!(%err, "failed to benchmark file IO"))
} }
...@@ -1501,12 +1501,8 @@ pub async fn project_trace_source_operation( ...@@ -1501,12 +1501,8 @@ pub async fn project_trace_source_operation(
} }
}; };
let project_root_uri = uri_from_file( let project_root_uri =
container.project().project_root_path().await?.clone_value(), uri_from_file(container.project().project_root_path().owned().await?, None).await? + "/";
None,
)
.await?
+ "/";
let (file, original_file, is_internal) = let (file, original_file, is_internal) =
if let Some(source_file) = original_file.strip_prefix(&project_root_uri) { if let Some(source_file) = original_file.strip_prefix(&project_root_uri) {
// Client code uses file:// // Client code uses file://
......
This diff is collapsed.
...@@ -83,7 +83,7 @@ impl InstrumentationEndpoint { ...@@ -83,7 +83,7 @@ impl InstrumentationEndpoint {
let edge_entry_module = wrap_edge_entry( let edge_entry_module = wrap_edge_entry(
*self.asset_context, *self.asset_context,
self.project.project_path().await?.clone_value(), self.project.project_path().owned().await?,
*userland_module, *userland_module,
rcstr!("instrumentation"), rcstr!("instrumentation"),
) )
...@@ -177,7 +177,7 @@ impl InstrumentationEndpoint { ...@@ -177,7 +177,7 @@ impl InstrumentationEndpoint {
let edge_files = self.edge_files(); let edge_files = self.edge_files();
let mut output_assets = edge_files.owned().await?; let mut output_assets = edge_files.owned().await?;
let node_root = this.project.node_root().await?.clone_value(); let node_root = this.project.node_root().owned().await?;
let node_root_value = node_root.clone(); let node_root_value = node_root.clone();
let file_paths_from_root = let file_paths_from_root =
...@@ -243,7 +243,7 @@ impl Endpoint for InstrumentationEndpoint { ...@@ -243,7 +243,7 @@ impl Endpoint for InstrumentationEndpoint {
let output_assets = self.output_assets(); let output_assets = self.output_assets();
let server_paths = if this.project.next_mode().await?.is_development() { let server_paths = if this.project.next_mode().await?.is_development() {
let node_root = this.project.node_root().await?.clone_value(); let node_root = this.project.node_root().owned().await?;
all_server_paths(output_assets, node_root).owned().await? all_server_paths(output_assets, node_root).owned().await?
} else { } else {
vec![] vec![]
......
...@@ -82,7 +82,7 @@ impl MiddlewareEndpoint { ...@@ -82,7 +82,7 @@ impl MiddlewareEndpoint {
let module = get_middleware_module( let module = get_middleware_module(
*self.asset_context, *self.asset_context,
self.project.project_path().await?.clone_value(), self.project.project_path().owned().await?,
userland_module, userland_module,
); );
...@@ -94,7 +94,7 @@ impl MiddlewareEndpoint { ...@@ -94,7 +94,7 @@ impl MiddlewareEndpoint {
} }
Ok(wrap_edge_entry( Ok(wrap_edge_entry(
*self.asset_context, *self.asset_context,
self.project.project_path().await?.clone_value(), self.project.project_path().owned().await?,
module, module,
rcstr!("middleware"), rcstr!("middleware"),
)) ))
...@@ -282,7 +282,7 @@ impl MiddlewareEndpoint { ...@@ -282,7 +282,7 @@ impl MiddlewareEndpoint {
let edge_files = self.edge_files(); let edge_files = self.edge_files();
let mut output_assets = edge_files.owned().await?; let mut output_assets = edge_files.owned().await?;
let node_root = this.project.node_root().await?.clone_value(); let node_root = this.project.node_root().owned().await?;
let node_root_value = node_root.clone(); let node_root_value = node_root.clone();
let file_paths_from_root = let file_paths_from_root =
...@@ -362,11 +362,11 @@ impl Endpoint for MiddlewareEndpoint { ...@@ -362,11 +362,11 @@ impl Endpoint for MiddlewareEndpoint {
let output_assets = self.output_assets(); let output_assets = self.output_assets();
let (server_paths, client_paths) = if this.project.next_mode().await?.is_development() { let (server_paths, client_paths) = if this.project.next_mode().await?.is_development() {
let node_root = this.project.node_root().await?.clone_value(); let node_root = this.project.node_root().owned().await?;
let server_paths = all_server_paths(output_assets, node_root).owned().await?; let server_paths = all_server_paths(output_assets, node_root).owned().await?;
// Middleware could in theory have a client path (e.g. `new URL`). // Middleware could in theory have a client path (e.g. `new URL`).
let client_relative_root = this.project.client_relative_path().await?.clone_value(); let client_relative_root = this.project.client_relative_path().owned().await?;
let client_paths = all_paths_in_root(output_assets, client_relative_root) let client_paths = all_paths_in_root(output_assets, client_relative_root)
.into_future() .into_future()
.owned() .owned()
......
...@@ -408,8 +408,8 @@ impl Issue for CssGlobalImportIssue { ...@@ -408,8 +408,8 @@ impl Issue for CssGlobalImportIssue {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn description(&self) -> Result<Vc<OptionStyledString>> { async fn description(&self) -> Result<Vc<OptionStyledString>> {
let parent_path = self.parent_module.ident().path().await?.clone_value(); let parent_path = self.parent_module.ident().path().owned().await?;
let module_path = self.module.ident().path().await?.clone_value(); let module_path = self.module.ident().path().owned().await?;
let relative_import_location = parent_path.parent(); let relative_import_location = parent_path.parent();
let import_path = match relative_import_location.get_relative_path_to(&module_path) { let import_path = match relative_import_location.get_relative_path_to(&module_path) {
......
...@@ -234,7 +234,7 @@ impl Asset for NftJsonAsset { ...@@ -234,7 +234,7 @@ impl Asset for NftJsonAsset {
// Apply outputFileTracingIncludes and outputFileTracingExcludes // Apply outputFileTracingIncludes and outputFileTracingExcludes
// Extract route from chunk path for pattern matching // Extract route from chunk path for pattern matching
if let Some(route) = &this.page_name { if let Some(route) = &this.page_name {
let project_path = this.project.project_path().await?.clone_value(); let project_path = this.project.project_path().owned().await?;
let mut combined_includes = BTreeSet::new(); let mut combined_includes = BTreeSet::new();
// Process includes // Process includes
......
This diff is collapsed.
This diff is collapsed.
...@@ -264,7 +264,7 @@ async fn get_entries(assets: OperationVc<OutputAssets>) -> Result<Vc<GetEntriesR ...@@ -264,7 +264,7 @@ async fn get_entries(assets: OperationVc<OutputAssets>) -> Result<Vc<GetEntriesR
let entries = assets_ref let entries = assets_ref
.iter() .iter()
.map(|&asset| async move { .map(|&asset| async move {
let path = asset.path().await?.clone_value(); let path = asset.path().owned().await?;
Ok((path, asset)) Ok((path, asset))
}) })
.try_join() .try_join()
......
...@@ -25,6 +25,6 @@ pub(crate) async fn next_js_file_path(path: RcStr) -> Result<Vc<FileSystemPath>> ...@@ -25,6 +25,6 @@ pub(crate) async fn next_js_file_path(path: RcStr) -> Result<Vc<FileSystemPath>>
#[turbo_tasks::function] #[turbo_tasks::function]
pub(crate) async fn next_asset(path: RcStr) -> Result<Vc<Box<dyn Source>>> { pub(crate) async fn next_asset(path: RcStr) -> Result<Vc<Box<dyn Source>>> {
Ok(Vc::upcast(FileSource::new( Ok(Vc::upcast(FileSource::new(
next_js_file_path(path).await?.clone_value(), next_js_file_path(path).owned().await?,
))) )))
} }
...@@ -55,7 +55,7 @@ pub async fn emit_assets( ...@@ -55,7 +55,7 @@ pub async fn emit_assets(
let client_output_path = client_output_path.clone(); let client_output_path = client_output_path.clone();
async move { async move {
let path = asset.path().await?.clone_value(); let path = asset.path().owned().await?;
let span = tracing::info_span!("emit asset", name = %path.value_to_string().await?); let span = tracing::info_span!("emit asset", name = %path.value_to_string().await?);
async move { async move {
Ok(if path.is_inside_ref(&node_root) { Ok(if path.is_inside_ref(&node_root) {
...@@ -88,7 +88,7 @@ async fn emit(asset: Vc<Box<dyn OutputAsset>>) -> Result<()> { ...@@ -88,7 +88,7 @@ async fn emit(asset: Vc<Box<dyn OutputAsset>>) -> Result<()> {
.content() .content()
.resolve() .resolve()
.await? .await?
.write(asset.path().await?.clone_value()) .write(asset.path().owned().await?)
.as_side_effect() .as_side_effect()
.await?; .await?;
Ok(()) Ok(())
...@@ -100,9 +100,9 @@ async fn emit_rebase( ...@@ -100,9 +100,9 @@ async fn emit_rebase(
from: FileSystemPath, from: FileSystemPath,
to: FileSystemPath, to: FileSystemPath,
) -> Result<()> { ) -> Result<()> {
let path = rebase(asset.path().await?.clone_value(), from, to) let path = rebase(asset.path().owned().await?, from, to)
.await? .owned()
.clone_value(); .await?;
let content = asset.content(); let content = asset.content();
content content
.resolve() .resolve()
......
...@@ -179,7 +179,7 @@ pub async fn get_app_client_references_chunks( ...@@ -179,7 +179,7 @@ pub async fn get_app_client_references_chunks(
let base_ident = server_component.ident(); let base_ident = server_component.ident();
let server_path = server_component.server_path().await?.clone_value(); let server_path = server_component.server_path().owned().await?;
let is_layout = server_path.file_stem() == Some("layout"); let is_layout = server_path.file_stem() == Some("layout");
let server_component_path = server_path.value_to_string().await?; let server_component_path = server_path.value_to_string().await?;
......
...@@ -55,7 +55,7 @@ pub async fn get_app_route_entry( ...@@ -55,7 +55,7 @@ pub async fn get_app_route_entry(
let original_name: RcStr = page.to_string().into(); let original_name: RcStr = page.to_string().into();
let pathname: RcStr = AppPath::from(page.clone()).to_string().into(); let pathname: RcStr = AppPath::from(page.clone()).to_string().into();
let path = source.ident().path().await?.clone_value(); let path = source.ident().path().owned().await?;
const INNER: &str = "INNER_APP_ROUTE"; const INNER: &str = "INNER_APP_ROUTE";
......
...@@ -16,7 +16,7 @@ pub async fn get_postcss_package_mapping( ...@@ -16,7 +16,7 @@ pub async fn get_postcss_package_mapping(
.resolved_cell(), .resolved_cell(),
ImportMapping::PrimaryAlternative( ImportMapping::PrimaryAlternative(
"postcss".into(), "postcss".into(),
Some(get_next_package(project_path.clone()).await?.clone_value()), Some(get_next_package(project_path.clone()).owned().await?),
) )
.resolved_cell(), .resolved_cell(),
]) ])
......
...@@ -149,7 +149,7 @@ pub async fn get_client_resolve_options_context( ...@@ -149,7 +149,7 @@ pub async fn get_client_resolve_options_context(
.await?; .await?;
let custom_conditions = vec![mode.await?.condition().into()]; let custom_conditions = vec![mode.await?.condition().into()];
let resolve_options_context = ResolveOptionsContext { let resolve_options_context = ResolveOptionsContext {
enable_node_modules: Some(project_path.root().await?.clone_value()), enable_node_modules: Some(project_path.root().owned().await?),
custom_conditions, custom_conditions,
import_map: Some(next_client_import_map), import_map: Some(next_client_import_map),
fallback_import_map: Some(next_client_fallback_import_map), fallback_import_map: Some(next_client_fallback_import_map),
...@@ -431,9 +431,7 @@ pub async fn get_client_chunking_context( ...@@ -431,9 +431,7 @@ pub async fn get_client_chunking_context(
client_root_to_root_path, client_root_to_root_path,
client_root.clone(), client_root.clone(),
client_root.join("static/chunks")?, client_root.join("static/chunks")?,
get_client_assets_path(client_root.clone()) get_client_assets_path(client_root.clone()).owned().await?,
.await?
.clone_value(),
environment.to_resolved().await?, environment.to_resolved().await?,
next_mode.runtime_type(), next_mode.runtime_type(),
) )
......
...@@ -154,7 +154,7 @@ pub async fn get_edge_resolve_options_context( ...@@ -154,7 +154,7 @@ pub async fn get_edge_resolve_options_context(
}; };
let resolve_options_context = ResolveOptionsContext { let resolve_options_context = ResolveOptionsContext {
enable_node_modules: Some(project_path.root().await?.clone_value()), enable_node_modules: Some(project_path.root().owned().await?),
enable_edge_node_externals: true, enable_edge_node_externals: true,
custom_conditions, custom_conditions,
import_map: Some(next_edge_import_map), import_map: Some(next_edge_import_map),
......
...@@ -50,7 +50,7 @@ impl ImportMappingReplacement for NextEdgeUnsupportedModuleReplacer { ...@@ -50,7 +50,7 @@ impl ImportMappingReplacement for NextEdgeUnsupportedModuleReplacer {
// Call out to separate `unsupported_module_source` to only have a single Source cell // Call out to separate `unsupported_module_source` to only have a single Source cell
// for requests with different subpaths: `fs` and `fs/promises`. // for requests with different subpaths: `fs` and `fs/promises`.
let source = let source =
unsupported_module_source(lookup_path.root().await?.clone_value(), module.clone()) unsupported_module_source(lookup_path.root().owned().await?, module.clone())
.to_resolved() .to_resolved()
.await?; .await?;
Ok(ImportMapResult::Result(ResolveResult::source(ResolvedVc::upcast(source))).cell()) Ok(ImportMapResult::Result(ResolveResult::source(ResolvedVc::upcast(source))).cell())
......
...@@ -730,7 +730,7 @@ async fn get_mock_stylesheet( ...@@ -730,7 +730,7 @@ async fn get_mock_stylesheet(
) )
.module(); .module();
let root = mock_fs.root().await?.clone_value(); let root = mock_fs.root().owned().await?;
let val = evaluate( let val = evaluate(
mocked_response_asset, mocked_response_asset,
root, root,
......
...@@ -624,7 +624,7 @@ async fn insert_next_server_special_aliases( ...@@ -624,7 +624,7 @@ async fn insert_next_server_special_aliases(
ServerContextType::AppSSR { app_dir } ServerContextType::AppSSR { app_dir }
| ServerContextType::AppRSC { app_dir, .. } | ServerContextType::AppRSC { app_dir, .. }
| ServerContextType::AppRoute { app_dir, .. } => { | ServerContextType::AppRoute { app_dir, .. } => {
let next_package = get_next_package(app_dir.clone()).await?.clone_value(); let next_package = get_next_package(app_dir.clone()).owned().await?;
import_map.insert_exact_alias( import_map.insert_exact_alias(
"styled-jsx", "styled-jsx",
request_to_import_mapping(next_package.clone(), "styled-jsx"), request_to_import_mapping(next_package.clone(), "styled-jsx"),
...@@ -966,7 +966,7 @@ async fn insert_next_shared_aliases( ...@@ -966,7 +966,7 @@ async fn insert_next_shared_aliases(
next_mode: Vc<NextMode>, next_mode: Vc<NextMode>,
is_runtime_edge: bool, is_runtime_edge: bool,
) -> Result<()> { ) -> Result<()> {
let package_root = next_js_fs().root().await?.clone_value(); let package_root = next_js_fs().root().owned().await?;
insert_alias_to_alternatives( insert_alias_to_alternatives(
import_map, import_map,
...@@ -1033,7 +1033,7 @@ async fn insert_next_shared_aliases( ...@@ -1033,7 +1033,7 @@ async fn insert_next_shared_aliases(
.resolved_cell(), .resolved_cell(),
); );
let next_package = get_next_package(project_path.clone()).await?.clone_value(); let next_package = get_next_package(project_path.clone()).owned().await?;
import_map.insert_singleton_alias("@swc/helpers", next_package.clone()); import_map.insert_singleton_alias("@swc/helpers", next_package.clone());
import_map.insert_singleton_alias("styled-jsx", next_package.clone()); import_map.insert_singleton_alias("styled-jsx", next_package.clone());
import_map.insert_singleton_alias("next", project_path.clone()); import_map.insert_singleton_alias("next", project_path.clone());
...@@ -1108,10 +1108,7 @@ async fn insert_next_shared_aliases( ...@@ -1108,10 +1108,7 @@ async fn insert_next_shared_aliases(
insert_package_alias( insert_package_alias(
import_map, import_map,
"@vercel/turbopack-node/", "@vercel/turbopack-node/",
turbopack_node::embed_js::embed_fs() turbopack_node::embed_js::embed_fs().root().owned().await?,
.root()
.await?
.clone_value(),
); );
let image_config = next_config.image_config().await?; let image_config = next_config.image_config().await?;
...@@ -1138,7 +1135,7 @@ pub async fn get_next_package(context_directory: FileSystemPath) -> Result<Vc<Fi ...@@ -1138,7 +1135,7 @@ pub async fn get_next_package(context_directory: FileSystemPath) -> Result<Vc<Fi
context_directory.clone(), context_directory.clone(),
ReferenceType::CommonJs(CommonJsReferenceSubType::Undefined), ReferenceType::CommonJs(CommonJsReferenceSubType::Undefined),
Request::parse(Pattern::Constant(rcstr!("next/package.json"))), Request::parse(Pattern::Constant(rcstr!("next/package.json"))),
node_cjs_resolve_options(context_directory.root().await?.clone_value()), node_cjs_resolve_options(context_directory.root().owned().await?),
); );
let source = result let source = result
.first_source() .first_source()
...@@ -1248,8 +1245,8 @@ async fn insert_turbopack_dev_alias(import_map: &mut ImportMap) -> Result<()> { ...@@ -1248,8 +1245,8 @@ async fn insert_turbopack_dev_alias(import_map: &mut ImportMap) -> Result<()> {
"@vercel/turbopack-ecmascript-runtime/", "@vercel/turbopack-ecmascript-runtime/",
turbopack_ecmascript_runtime::embed_fs() turbopack_ecmascript_runtime::embed_fs()
.root() .root()
.await? .owned()
.clone_value(), .await?,
); );
Ok(()) Ok(())
} }
......
...@@ -139,7 +139,7 @@ impl ClientReferenceManifest { ...@@ -139,7 +139,7 @@ impl ClientReferenceManifest {
Ok(if let Some(path) = path { Ok(if let Some(path) = path {
(chunk, Either::Left(path)) (chunk, Either::Left(path))
} else { } else {
(chunk, Either::Right(chunk.path().await?.clone_value())) (chunk, Either::Right(chunk.path().owned().await?))
}) })
}) })
.try_join() .try_join()
......
...@@ -111,7 +111,7 @@ pub async fn create_page_ssr_entry_module( ...@@ -111,7 +111,7 @@ pub async fn create_page_ssr_entry_module(
let file = File::from(result.build()); let file = File::from(result.build());
source = Vc::upcast(VirtualSource::new( source = Vc::upcast(VirtualSource::new(
source.ident().path().await?.clone_value(), source.ident().path().owned().await?,
AssetContent::file(file.into()), AssetContent::file(file.into()),
)); ));
} }
...@@ -188,7 +188,7 @@ async fn process_global_item( ...@@ -188,7 +188,7 @@ async fn process_global_item(
reference_type: ReferenceType, reference_type: ReferenceType,
module_context: Vc<Box<dyn AssetContext>>, module_context: Vc<Box<dyn AssetContext>>,
) -> Result<Vc<Box<dyn Module>>> { ) -> Result<Vc<Box<dyn Module>>> {
let source = Vc::upcast(FileSource::new(item.file_path().await?.clone_value())); let source = Vc::upcast(FileSource::new(item.file_path().owned().await?));
Ok(module_context.process(source, reference_type).module()) Ok(module_context.process(source, reference_type).module())
} }
......
...@@ -141,7 +141,7 @@ pub async fn get_server_resolve_options_context( ...@@ -141,7 +141,7 @@ pub async fn get_server_resolve_options_context(
.await?; .await?;
let foreign_code_context_condition = let foreign_code_context_condition =
foreign_code_context_condition(next_config, project_path.clone()).await?; foreign_code_context_condition(next_config, project_path.clone()).await?;
let root_dir = project_path.root().await?.clone_value(); let root_dir = project_path.root().owned().await?;
let module_feature_report_resolve_plugin = let module_feature_report_resolve_plugin =
ModuleFeatureReportResolvePlugin::new(project_path.clone()) ModuleFeatureReportResolvePlugin::new(project_path.clone())
.to_resolved() .to_resolved()
...@@ -194,7 +194,7 @@ pub async fn get_server_resolve_options_context( ...@@ -194,7 +194,7 @@ pub async fn get_server_resolve_options_context(
let server_external_packages_plugin = ExternalCjsModulesResolvePlugin::new( let server_external_packages_plugin = ExternalCjsModulesResolvePlugin::new(
project_path.clone(), project_path.clone(),
project_path.root().await?.clone_value(), project_path.root().owned().await?,
ExternalPredicate::Only(ResolvedVc::cell(external_packages)).cell(), ExternalPredicate::Only(ResolvedVc::cell(external_packages)).cell(),
*next_config.import_externals().await?, *next_config.import_externals().await?,
) )
...@@ -219,7 +219,7 @@ pub async fn get_server_resolve_options_context( ...@@ -219,7 +219,7 @@ pub async fn get_server_resolve_options_context(
} else { } else {
ExternalCjsModulesResolvePlugin::new( ExternalCjsModulesResolvePlugin::new(
project_path.clone(), project_path.clone(),
project_path.root().await?.clone_value(), project_path.root().owned().await?,
ExternalPredicate::AllExcept(ResolvedVc::cell(transpiled_packages)).cell(), ExternalPredicate::AllExcept(ResolvedVc::cell(transpiled_packages)).cell(),
*next_config.import_externals().await?, *next_config.import_externals().await?,
) )
......
...@@ -215,9 +215,9 @@ impl AfterResolvePlugin for ExternalCjsModulesResolvePlugin { ...@@ -215,9 +215,9 @@ impl AfterResolvePlugin for ExternalCjsModulesResolvePlugin {
let mut request_str = request_str.to_string(); let mut request_str = request_str.to_string();
let node_resolve_options = if is_esm { let node_resolve_options = if is_esm {
node_esm_resolve_options(lookup_path.root().await?.clone_value()) node_esm_resolve_options(lookup_path.root().owned().await?)
} else { } else {
node_cjs_resolve_options(lookup_path.root().await?.clone_value()) node_cjs_resolve_options(lookup_path.root().owned().await?)
}; };
let result_from_original_location = loop { let result_from_original_location = loop {
let node_resolved_from_original_location = resolve( let node_resolved_from_original_location = resolve(
...@@ -348,7 +348,7 @@ impl AfterResolvePlugin for ExternalCjsModulesResolvePlugin { ...@@ -348,7 +348,7 @@ impl AfterResolvePlugin for ExternalCjsModulesResolvePlugin {
)]); )]);
} }
} }
let path = result.ident().path().await?.clone_value(); let path = result.ident().path().owned().await?;
let file_type = get_file_type(path.clone(), &path).await?; let file_type = get_file_type(path.clone(), &path).await?;
let external_type = match (file_type, is_esm) { let external_type = match (file_type, is_esm) {
...@@ -370,7 +370,7 @@ impl AfterResolvePlugin for ExternalCjsModulesResolvePlugin { ...@@ -370,7 +370,7 @@ impl AfterResolvePlugin for ExternalCjsModulesResolvePlugin {
// It would be more efficient to use an CJS external instead of an ESM external, // It would be more efficient to use an CJS external instead of an ESM external,
// but we need to verify if that would be correct (as in resolves to the same file). // but we need to verify if that would be correct (as in resolves to the same file).
let node_resolve_options = let node_resolve_options =
node_cjs_resolve_options(lookup_path.root().await?.clone_value()); node_cjs_resolve_options(lookup_path.root().owned().await?);
let node_resolved = resolve( let node_resolved = resolve(
self.project_path.clone(), self.project_path.clone(),
reference_type.clone(), reference_type.clone(),
...@@ -378,7 +378,7 @@ impl AfterResolvePlugin for ExternalCjsModulesResolvePlugin { ...@@ -378,7 +378,7 @@ impl AfterResolvePlugin for ExternalCjsModulesResolvePlugin {
node_resolve_options, node_resolve_options,
); );
let resolves_equal = if let Some(result) = *node_resolved.first_source().await? { let resolves_equal = if let Some(result) = *node_resolved.first_source().await? {
let cjs_path = result.ident().path().await?.clone_value(); let cjs_path = result.ident().path().owned().await?;
cjs_path == path cjs_path == path
} else { } else {
false false
......
...@@ -221,7 +221,7 @@ impl AfterResolvePlugin for NextExternalResolvePlugin { ...@@ -221,7 +221,7 @@ impl AfterResolvePlugin for NextExternalResolvePlugin {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn after_resolve_condition(&self) -> Result<Vc<AfterResolvePluginCondition>> { async fn after_resolve_condition(&self) -> Result<Vc<AfterResolvePluginCondition>> {
Ok(AfterResolvePluginCondition::new( Ok(AfterResolvePluginCondition::new(
self.project_path.root().await?.clone_value(), self.project_path.root().owned().await?,
Glob::new("**/next/dist/**/*.{external,runtime.dev,runtime.prod}.js".into()), Glob::new("**/next/dist/**/*.{external,runtime.dev,runtime.prod}.js".into()),
)) ))
} }
...@@ -275,7 +275,7 @@ impl AfterResolvePlugin for NextNodeSharedRuntimeResolvePlugin { ...@@ -275,7 +275,7 @@ impl AfterResolvePlugin for NextNodeSharedRuntimeResolvePlugin {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn after_resolve_condition(&self) -> Result<Vc<AfterResolvePluginCondition>> { async fn after_resolve_condition(&self) -> Result<Vc<AfterResolvePluginCondition>> {
Ok(AfterResolvePluginCondition::new( Ok(AfterResolvePluginCondition::new(
self.root.root().await?.clone_value(), self.root.root().owned().await?,
Glob::new("**/next/dist/**/*.shared-runtime.js".into()), Glob::new("**/next/dist/**/*.shared-runtime.js".into()),
)) ))
} }
...@@ -400,7 +400,7 @@ impl AfterResolvePlugin for NextSharedRuntimeResolvePlugin { ...@@ -400,7 +400,7 @@ impl AfterResolvePlugin for NextSharedRuntimeResolvePlugin {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn after_resolve_condition(&self) -> Result<Vc<AfterResolvePluginCondition>> { async fn after_resolve_condition(&self) -> Result<Vc<AfterResolvePluginCondition>> {
Ok(AfterResolvePluginCondition::new( Ok(AfterResolvePluginCondition::new(
self.root.root().await?.clone_value(), self.root.root().owned().await?,
Glob::new("**/next/dist/esm/**/*.shared-runtime.js".into()), Glob::new("**/next/dist/esm/**/*.shared-runtime.js".into()),
)) ))
} }
......
...@@ -65,7 +65,7 @@ pub async fn get_swc_ecma_transform_rule_impl( ...@@ -65,7 +65,7 @@ pub async fn get_swc_ecma_transform_rule_impl(
let resolve_options = resolve_options( let resolve_options = resolve_options(
project_path.clone(), project_path.clone(),
ResolveOptionsContext { ResolveOptionsContext {
enable_node_modules: Some(project_path.root().await?.clone_value()), enable_node_modules: Some(project_path.root().owned().await?),
enable_node_native_modules: true, enable_node_native_modules: true,
..Default::default() ..Default::default()
} }
......
...@@ -31,8 +31,8 @@ pub async fn create_page_loader_entry_module( ...@@ -31,8 +31,8 @@ pub async fn create_page_loader_entry_module(
writeln!(result, "const PAGE_PATH = {};\n", StringifyJs(&pathname))?; writeln!(result, "const PAGE_PATH = {};\n", StringifyJs(&pathname))?;
let page_loader_path = next_js_file_path(rcstr!("entry/page-loader.ts")) let page_loader_path = next_js_file_path(rcstr!("entry/page-loader.ts"))
.await? .owned()
.clone_value(); .await?;
let base_code = page_loader_path.read(); let base_code = page_loader_path.read();
if let FileContent::Content(base_file) = &*base_code.await? { if let FileContent::Content(base_file) = &*base_code.await? {
result += base_file.content() result += base_file.content()
...@@ -103,7 +103,7 @@ impl PageLoaderAsset { ...@@ -103,7 +103,7 @@ impl PageLoaderAsset {
// If we are provided a prefix path, we need to rewrite our chunk paths to // If we are provided a prefix path, we need to rewrite our chunk paths to
// remove that prefix. // remove that prefix.
if let Some(rebase_path) = &*rebase_prefix_path.await? { if let Some(rebase_path) = &*rebase_prefix_path.await? {
let root_path = rebase_path.root().await?.clone_value(); let root_path = rebase_path.root().owned().await?;
let rebased = chunks let rebased = chunks
.await? .await?
.iter() .iter()
...@@ -114,12 +114,12 @@ impl PageLoaderAsset { ...@@ -114,12 +114,12 @@ impl PageLoaderAsset {
Vc::upcast::<Box<dyn OutputAsset>>(ProxiedAsset::new( Vc::upcast::<Box<dyn OutputAsset>>(ProxiedAsset::new(
*chunk, *chunk,
FileSystemPath::rebase( FileSystemPath::rebase(
chunk.path().await?.clone_value(), chunk.path().owned().await?,
rebase_path.clone(), rebase_path.clone(),
root_path.clone(), root_path.clone(),
) )
.await? .owned()
.clone_value(), .await?,
)) ))
.to_resolved() .to_resolved()
.await .await
......
...@@ -103,15 +103,11 @@ pub async fn find_pages_structure( ...@@ -103,15 +103,11 @@ pub async fn find_pages_structure(
next_router_root: FileSystemPath, next_router_root: FileSystemPath,
page_extensions: Vc<Vec<RcStr>>, page_extensions: Vc<Vec<RcStr>>,
) -> Result<Vc<PagesStructure>> { ) -> Result<Vc<PagesStructure>> {
let pages_root = project_root.join("pages")?.realpath().await?.clone_value(); let pages_root = project_root.join("pages")?.realpath().owned().await?;
let pages_root = if *pages_root.get_type().await? == FileSystemEntryType::Directory { let pages_root = if *pages_root.get_type().await? == FileSystemEntryType::Directory {
Some(pages_root) Some(pages_root)
} else { } else {
let src_pages_root = project_root let src_pages_root = project_root.join("src/pages")?.realpath().owned().await?;
.join("src/pages")?
.realpath()
.await?
.clone_value();
if *src_pages_root.get_type().await? == FileSystemEntryType::Directory { if *src_pages_root.get_type().await? == FileSystemEntryType::Directory {
Some(src_pages_root) Some(src_pages_root)
} else { } else {
......
...@@ -25,7 +25,7 @@ async fn get_typescript_options( ...@@ -25,7 +25,7 @@ async fn get_typescript_options(
Some(FindContextFileResult::Found(path, _)) => read_tsconfigs( Some(FindContextFileResult::Found(path, _)) => read_tsconfigs(
path.read(), path.read(),
ResolvedVc::upcast(FileSource::new(path.clone()).to_resolved().await?), ResolvedVc::upcast(FileSource::new(path.clone()).to_resolved().await?),
node_cjs_resolve_options(path.root().await?.clone_value()), node_cjs_resolve_options(path.root().owned().await?),
) )
.await .await
.ok(), .ok(),
......
...@@ -187,19 +187,14 @@ pub async fn foreign_code_context_condition( ...@@ -187,19 +187,14 @@ pub async fn foreign_code_context_condition(
// subject to Next.js's configuration even if it's embedded assets. // subject to Next.js's configuration even if it's embedded assets.
pub async fn internal_assets_conditions() -> Result<ContextCondition> { pub async fn internal_assets_conditions() -> Result<ContextCondition> {
Ok(ContextCondition::any(vec![ Ok(ContextCondition::any(vec![
ContextCondition::InPath(next_js_fs().root().await?.clone_value()), ContextCondition::InPath(next_js_fs().root().owned().await?),
ContextCondition::InPath( ContextCondition::InPath(
turbopack_ecmascript_runtime::embed_fs() turbopack_ecmascript_runtime::embed_fs()
.root() .root()
.await? .owned()
.clone_value(), .await?,
),
ContextCondition::InPath(
turbopack_node::embed_js::embed_fs()
.root()
.await?
.clone_value(),
), ),
ContextCondition::InPath(turbopack_node::embed_js::embed_fs().root().owned().await?),
])) ]))
} }
......
...@@ -125,10 +125,7 @@ async fn errors_on_failed_connection() { ...@@ -125,10 +125,7 @@ async fn errors_on_failed_connection() {
assert_eq!(*err.kind.await?, FetchErrorKind::Connect); assert_eq!(*err.kind.await?, FetchErrorKind::Connect);
assert_eq!(*err.url.await?, url); assert_eq!(*err.url.await?, url);
let issue = err_vc.to_issue( let issue = err_vc.to_issue(IssueSeverity::Error, get_issue_context().owned().await?);
IssueSeverity::Error,
get_issue_context().await?.clone_value(),
);
assert_eq!(issue.await?.severity(), IssueSeverity::Error); assert_eq!(issue.await?.severity(), IssueSeverity::Error);
assert_eq!( assert_eq!(
*issue.description().await?.unwrap().await?, *issue.description().await?.unwrap().await?,
...@@ -162,10 +159,7 @@ async fn errors_on_404() { ...@@ -162,10 +159,7 @@ async fn errors_on_404() {
assert!(matches!(*err.kind.await?, FetchErrorKind::Status(404))); assert!(matches!(*err.kind.await?, FetchErrorKind::Status(404)));
assert_eq!(*err.url.await?, url); assert_eq!(*err.url.await?, url);
let issue = err_vc.to_issue( let issue = err_vc.to_issue(IssueSeverity::Error, get_issue_context().owned().await?);
IssueSeverity::Error,
get_issue_context().await?.clone_value(),
);
assert_eq!(issue.await?.severity(), IssueSeverity::Error); assert_eq!(issue.await?.severity(), IssueSeverity::Error);
assert_eq!( assert_eq!(
*issue.description().await?.unwrap().await?, *issue.description().await?.unwrap().await?,
......
...@@ -42,15 +42,6 @@ where ...@@ -42,15 +42,6 @@ where
} }
} }
impl<T> ReadRef<T>
where
T: VcValueType + Clone,
{
pub fn clone_value(&self) -> VcReadTarget<T> {
T::Read::value_to_target((*self.0).clone())
}
}
impl<T> Display for ReadRef<T> impl<T> Display for ReadRef<T>
where where
T: VcValueType, T: VcValueType,
......
...@@ -62,8 +62,8 @@ impl EcmascriptBrowserChunkContent { ...@@ -62,8 +62,8 @@ impl EcmascriptBrowserChunkContent {
#[turbo_tasks::function] #[turbo_tasks::function]
pub(crate) async fn own_version(&self) -> Result<Vc<EcmascriptBrowserChunkVersion>> { pub(crate) async fn own_version(&self) -> Result<Vc<EcmascriptBrowserChunkVersion>> {
Ok(EcmascriptBrowserChunkVersion::new( Ok(EcmascriptBrowserChunkVersion::new(
self.chunking_context.output_root().await?.clone_value(), self.chunking_context.output_root().owned().await?,
self.chunk.path().await?.clone_value(), self.chunk.path().owned().await?,
*self.content, *self.content,
)) ))
} }
......
...@@ -70,7 +70,7 @@ impl EcmascriptBrowserEvaluateChunk { ...@@ -70,7 +70,7 @@ impl EcmascriptBrowserEvaluateChunk {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn chunks_data(&self) -> Result<Vc<ChunksData>> { async fn chunks_data(&self) -> Result<Vc<ChunksData>> {
Ok(ChunkData::from_assets( Ok(ChunkData::from_assets(
self.chunking_context.output_root().await?.clone_value(), self.chunking_context.output_root().owned().await?,
*self.other_chunks, *self.other_chunks,
)) ))
} }
......
...@@ -210,7 +210,7 @@ async fn build_internal( ...@@ -210,7 +210,7 @@ async fn build_internal(
.unwrap_or(project_relative) .unwrap_or(project_relative)
.replace(MAIN_SEPARATOR, "/") .replace(MAIN_SEPARATOR, "/")
.into(); .into();
let root_path = project_fs.root().await?.clone_value(); let root_path = project_fs.root().owned().await?;
let project_path = root_path.join(&project_relative)?; let project_path = root_path.join(&project_relative)?;
let build_output_root = output_fs.root().await?.join("dist")?; let build_output_root = output_fs.root().await?.join("dist")?;
...@@ -502,7 +502,7 @@ async fn build_internal( ...@@ -502,7 +502,7 @@ async fn build_internal(
chunks chunks
.iter() .iter()
.map(|c| async move { c.content().write(c.path().await?.clone_value()).await }) .map(|c| async move { c.content().write(c.path().owned().await?).await })
.try_join() .try_join()
.await?; .await?;
......
...@@ -64,8 +64,8 @@ pub async fn get_client_import_map(project_path: FileSystemPath) -> Result<Vc<Im ...@@ -64,8 +64,8 @@ pub async fn get_client_import_map(project_path: FileSystemPath) -> Result<Vc<Im
Some( Some(
turbopack_ecmascript_runtime::embed_fs() turbopack_ecmascript_runtime::embed_fs()
.root() .root()
.await? .owned()
.clone_value(), .await?,
), ),
) )
.resolved_cell(), .resolved_cell(),
...@@ -83,7 +83,7 @@ pub async fn get_client_resolve_options_context( ...@@ -83,7 +83,7 @@ pub async fn get_client_resolve_options_context(
.to_resolved() .to_resolved()
.await?; .await?;
let module_options_context = ResolveOptionsContext { let module_options_context = ResolveOptionsContext {
enable_node_modules: Some(project_path.root().await?.clone_value()), enable_node_modules: Some(project_path.root().owned().await?),
custom_conditions: vec![node_env.await?.to_string().into(), "browser".into()], custom_conditions: vec![node_env.await?.to_string().into(), "browser".into()],
import_map: Some(next_client_import_map), import_map: Some(next_client_import_map),
browser: true, browser: true,
......
...@@ -266,7 +266,7 @@ async fn source( ...@@ -266,7 +266,7 @@ async fn source(
let output_fs = output_fs(project_dir); let output_fs = output_fs(project_dir);
let fs: Vc<Box<dyn FileSystem>> = project_fs(root_dir, /* watch= */ true); let fs: Vc<Box<dyn FileSystem>> = project_fs(root_dir, /* watch= */ true);
let root_path = fs.root().await?.clone_value(); let root_path = fs.root().owned().await?;
let project_path = root_path.join(&project_relative)?; let project_path = root_path.join(&project_relative)?;
let env = load_env(root_path.clone()); let env = load_env(root_path.clone());
...@@ -294,7 +294,7 @@ async fn source( ...@@ -294,7 +294,7 @@ async fn source(
ExecutionContext::new(root_path.clone(), Vc::upcast(build_chunking_context), env); ExecutionContext::new(root_path.clone(), Vc::upcast(build_chunking_context), env);
let server_fs = Vc::upcast::<Box<dyn FileSystem>>(ServerFileSystem::new()); let server_fs = Vc::upcast::<Box<dyn FileSystem>>(ServerFileSystem::new());
let server_root = server_fs.root().await?.clone_value(); let server_root = server_fs.root().owned().await?;
let entry_requests = entry_requests let entry_requests = entry_requests
.iter() .iter()
.map(|r| match r { .map(|r| match r {
......
...@@ -84,8 +84,8 @@ pub async fn get_client_runtime_entries( ...@@ -84,8 +84,8 @@ pub async fn get_client_runtime_entries(
RuntimeEntry::Source(ResolvedVc::upcast( RuntimeEntry::Source(ResolvedVc::upcast(
FileSource::new( FileSource::new(
embed_file_path(rcstr!("entry/bootstrap.ts")) embed_file_path(rcstr!("entry/bootstrap.ts"))
.await? .owned()
.clone_value(), .await?,
) )
.to_resolved() .to_resolved()
.await?, .await?,
......
...@@ -910,7 +910,7 @@ impl PlainIssue { ...@@ -910,7 +910,7 @@ impl PlainIssue {
into_plain_trace( into_plain_trace(
tracer tracer
.await? .await?
.get_traces(issue.file_path().await?.clone_value()) .get_traces(issue.file_path().owned().await?)
.await?, .await?,
) )
.await? .await?
......
...@@ -42,7 +42,7 @@ impl OutputAsset for RebasedAsset { ...@@ -42,7 +42,7 @@ impl OutputAsset for RebasedAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn path(&self) -> Result<Vc<FileSystemPath>> { async fn path(&self) -> Result<Vc<FileSystemPath>> {
Ok(FileSystemPath::rebase( Ok(FileSystemPath::rebase(
self.module.ident().path().await?.clone_value(), self.module.ident().path().owned().await?,
self.input_dir.clone(), self.input_dir.clone(),
self.output_dir.clone(), self.output_dir.clone(),
)) ))
......
...@@ -1133,20 +1133,20 @@ async fn type_exists( ...@@ -1133,20 +1133,20 @@ async fn type_exists(
ty: FileSystemEntryType, ty: FileSystemEntryType,
refs: &mut Vec<ResolvedVc<Box<dyn Source>>>, refs: &mut Vec<ResolvedVc<Box<dyn Source>>>,
) -> Result<Option<FileSystemPath>> { ) -> Result<Option<FileSystemPath>> {
let result = fs_path.realpath_with_links().await?; let result = fs_path.realpath_with_links().owned().await?;
refs.extend( refs.extend(
result result
.symlinks .symlinks
.iter() .into_iter()
.map(|path| async move { .map(|path| async move {
Ok(ResolvedVc::upcast( Ok(ResolvedVc::upcast(
FileSource::new(path.clone()).to_resolved().await?, FileSource::new(path).to_resolved().await?,
)) ))
}) })
.try_join() .try_join()
.await?, .await?,
); );
let path = result.clone_value().path; let path = result.path;
Ok(if *path.get_type().await? == ty { Ok(if *path.get_type().await? == ty {
Some(path) Some(path)
} else { } else {
...@@ -1158,20 +1158,20 @@ async fn any_exists( ...@@ -1158,20 +1158,20 @@ async fn any_exists(
fs_path: FileSystemPath, fs_path: FileSystemPath,
refs: &mut Vec<ResolvedVc<Box<dyn Source>>>, refs: &mut Vec<ResolvedVc<Box<dyn Source>>>,
) -> Result<Option<(FileSystemEntryType, FileSystemPath)>> { ) -> Result<Option<(FileSystemEntryType, FileSystemPath)>> {
let result = fs_path.realpath_with_links().await?; let result = fs_path.realpath_with_links().owned().await?;
refs.extend( refs.extend(
result result
.symlinks .symlinks
.iter() .into_iter()
.map(|path| async move { .map(|path| async move {
Ok(ResolvedVc::upcast( Ok(ResolvedVc::upcast(
FileSource::new(path.clone()).to_resolved().await?, FileSource::new(path).to_resolved().await?,
)) ))
}) })
.try_join() .try_join()
.await?, .await?,
); );
let path = result.clone_value().path; let path = result.path;
let ty = *path.get_type().await?; let ty = *path.get_type().await?;
Ok( Ok(
if matches!( if matches!(
...@@ -1508,7 +1508,7 @@ pub async fn resolve_raw( ...@@ -1508,7 +1508,7 @@ pub async fn resolve_raw(
{ {
let path = Pattern::new(pat); let path = Pattern::new(pat);
let matches = read_matches( let matches = read_matches(
lookup_dir.root().await?.clone_value(), lookup_dir.root().owned().await?,
rcstr!("/ROOT/"), rcstr!("/ROOT/"),
true, true,
path, path,
...@@ -1644,7 +1644,7 @@ pub async fn url_resolve( ...@@ -1644,7 +1644,7 @@ pub async fn url_resolve(
handle_resolve_error( handle_resolve_error(
result, result,
reference_type, reference_type,
origin.origin_path().await?.clone_value(), origin.origin_path().owned().await?,
request, request,
resolve_options, resolve_options,
is_optional, is_optional,
...@@ -1717,7 +1717,7 @@ async fn handle_after_resolve_plugins( ...@@ -1717,7 +1717,7 @@ async fn handle_after_resolve_plugins(
for (key, primary) in result_value.primary.iter() { for (key, primary) in result_value.primary.iter() {
if let &ResolveResultItem::Source(source) = primary { if let &ResolveResultItem::Source(source) = primary {
let path = source.ident().path().await?.clone_value(); let path = source.ident().path().owned().await?;
if let Some(new_result) = apply_plugins_to_path( if let Some(new_result) = apply_plugins_to_path(
path.clone(), path.clone(),
lookup_path.clone(), lookup_path.clone(),
...@@ -1944,7 +1944,7 @@ async fn resolve_internal_inline( ...@@ -1944,7 +1944,7 @@ async fn resolve_internal_inline(
} }
Box::pin(resolve_internal_inline( Box::pin(resolve_internal_inline(
lookup_path.root().await?.clone_value(), lookup_path.root().owned().await?,
relative, relative,
options, options,
)) ))
...@@ -2768,10 +2768,10 @@ async fn resolve_import_map_result( ...@@ -2768,10 +2768,10 @@ async fn resolve_import_map_result(
match ty { match ty {
// TODO is that root correct? // TODO is that root correct?
ExternalType::CommonJs => { ExternalType::CommonJs => {
node_cjs_resolve_options(alias_lookup_path.root().await?.clone_value()) node_cjs_resolve_options(alias_lookup_path.root().owned().await?)
} }
ExternalType::EcmaScriptModule => { ExternalType::EcmaScriptModule => {
node_esm_resolve_options(alias_lookup_path.root().await?.clone_value()) node_esm_resolve_options(alias_lookup_path.root().owned().await?)
} }
ExternalType::Script | ExternalType::Url | ExternalType::Global => options, ExternalType::Script | ExternalType::Url | ExternalType::Global => options,
}, },
......
...@@ -75,7 +75,7 @@ where ...@@ -75,7 +75,7 @@ where
) -> Result<Vc<ResolveOptions>> { ) -> Result<Vc<ResolveOptions>> {
Ok(self Ok(self
.asset_context() .asset_context()
.resolve_options(self.origin_path().await?.clone_value(), reference_type)) .resolve_options(self.origin_path().owned().await?, reference_type))
} }
fn with_transition(self: ResolvedVc<Self>, transition: RcStr) -> Vc<Box<dyn ResolveOrigin>> { fn with_transition(self: ResolvedVc<Self>, transition: RcStr) -> Vc<Box<dyn ResolveOrigin>> {
...@@ -103,7 +103,7 @@ async fn resolve_asset( ...@@ -103,7 +103,7 @@ async fn resolve_asset(
.resolve() .resolve()
.await? .await?
.resolve_asset( .resolve_asset(
resolve_origin.origin_path().await?.clone_value(), resolve_origin.origin_path().owned().await?,
request.resolve().await?, request.resolve().await?,
options.resolve().await?, options.resolve().await?,
reference_type, reference_type,
......
...@@ -102,7 +102,7 @@ impl CssChunk { ...@@ -102,7 +102,7 @@ impl CssChunk {
{ {
fileify_source_map( fileify_source_map(
content.source_map.as_ref(), content.source_map.as_ref(),
self.chunking_context().root_path().await?.clone_value(), self.chunking_context().root_path().owned().await?,
) )
.await? .await?
} else { } else {
...@@ -154,7 +154,7 @@ impl CssChunk { ...@@ -154,7 +154,7 @@ impl CssChunk {
async fn ident_for_path(&self) -> Result<Vc<AssetIdent>> { async fn ident_for_path(&self) -> Result<Vc<AssetIdent>> {
let CssChunkContent { chunk_items, .. } = &*self.content.await?; let CssChunkContent { chunk_items, .. } = &*self.content.await?;
let mut common_path = if let Some(chunk_item) = chunk_items.first() { let mut common_path = if let Some(chunk_item) = chunk_items.first() {
let path = chunk_item.asset_ident().path().await?.clone_value(); let path = chunk_item.asset_ident().path().owned().await?;
Some((path.clone(), path)) Some((path.clone(), path))
} else { } else {
None None
...@@ -191,7 +191,7 @@ impl CssChunk { ...@@ -191,7 +191,7 @@ impl CssChunk {
path: if let Some((common_path, _)) = common_path { path: if let Some((common_path, _)) = common_path {
common_path common_path
} else { } else {
ServerFileSystem::new().root().await?.clone_value() ServerFileSystem::new().root().owned().await?
}, },
query: RcStr::default(), query: RcStr::default(),
fragment: RcStr::default(), fragment: RcStr::default(),
...@@ -243,7 +243,7 @@ pub struct CssChunkContent { ...@@ -243,7 +243,7 @@ pub struct CssChunkContent {
impl Chunk for CssChunk { impl Chunk for CssChunk {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn ident(self: Vc<Self>) -> Result<Vc<AssetIdent>> { async fn ident(self: Vc<Self>) -> Result<Vc<AssetIdent>> {
Ok(AssetIdent::from_path(self.path().await?.clone_value())) Ok(AssetIdent::from_path(self.path().owned().await?))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -85,7 +85,7 @@ impl Chunk for SingleItemCssChunk { ...@@ -85,7 +85,7 @@ impl Chunk for SingleItemCssChunk {
async fn ident(self: Vc<Self>) -> Result<Vc<AssetIdent>> { async fn ident(self: Vc<Self>) -> Result<Vc<AssetIdent>> {
let self_as_output_asset: Vc<Box<dyn OutputAsset>> = Vc::upcast(self); let self_as_output_asset: Vc<Box<dyn OutputAsset>> = Vc::upcast(self);
Ok(AssetIdent::from_path( Ok(AssetIdent::from_path(
self_as_output_asset.path().await?.clone_value(), self_as_output_asset.path().owned().await?,
)) ))
} }
......
...@@ -28,7 +28,7 @@ pub async fn embed_static_code( ...@@ -28,7 +28,7 @@ pub async fn embed_static_code(
) -> Result<Vc<Code>> { ) -> Result<Vc<Code>> {
Ok(StaticEcmascriptCode::new( Ok(StaticEcmascriptCode::new(
asset_context, asset_context,
embed_file_path(path).await?.clone_value(), embed_file_path(path).owned().await?,
generate_source_map, generate_source_map,
) )
.code()) .code())
......
...@@ -62,7 +62,7 @@ impl AsyncLoaderChunkItem { ...@@ -62,7 +62,7 @@ impl AsyncLoaderChunkItem {
async fn chunks_data(self: Vc<Self>) -> Result<Vc<ChunksData>> { async fn chunks_data(self: Vc<Self>) -> Result<Vc<ChunksData>> {
let this = self.await?; let this = self.await?;
Ok(ChunkData::from_assets( Ok(ChunkData::from_assets(
this.chunking_context.output_root().await?.clone_value(), this.chunking_context.output_root().owned().await?,
self.chunks(), self.chunks(),
)) ))
} }
......
...@@ -55,7 +55,7 @@ impl EcmascriptChunkItemContent { ...@@ -55,7 +55,7 @@ impl EcmascriptChunkItemContent {
Ok(EcmascriptChunkItemContent { Ok(EcmascriptChunkItemContent {
rewrite_source_path: if *chunking_context.should_use_file_source_map_uris().await? { rewrite_source_path: if *chunking_context.should_use_file_source_map_uris().await? {
Some(chunking_context.root_path().await?.clone_value()) Some(chunking_context.root_path().owned().await?)
} else { } else {
None None
}, },
...@@ -279,7 +279,7 @@ async fn module_factory_with_code_generation_issue( ...@@ -279,7 +279,7 @@ async fn module_factory_with_code_generation_issue(
let js_error_message = serde_json::to_string(&error_message)?; let js_error_message = serde_json::to_string(&error_message)?;
CodeGenerationIssue { CodeGenerationIssue {
severity: IssueSeverity::Error, severity: IssueSeverity::Error,
path: chunk_item.asset_ident().path().await?.clone_value(), path: chunk_item.asset_ident().path().owned().await?,
title: StyledString::Text(rcstr!("Code generation for chunk item errored")) title: StyledString::Text(rcstr!("Code generation for chunk item errored"))
.resolved_cell(), .resolved_cell(),
message: StyledString::Text(error_message).resolved_cell(), message: StyledString::Text(error_message).resolved_cell(),
......
...@@ -72,7 +72,7 @@ impl Chunk for EcmascriptChunk { ...@@ -72,7 +72,7 @@ impl Chunk for EcmascriptChunk {
async fn ident(&self) -> Result<Vc<AssetIdent>> { async fn ident(&self) -> Result<Vc<AssetIdent>> {
let chunk_items = &*self.content.included_chunk_items().await?; let chunk_items = &*self.content.included_chunk_items().await?;
let mut common_path = if let Some(chunk_item) = chunk_items.first() { let mut common_path = if let Some(chunk_item) = chunk_items.first() {
let path = chunk_item.asset_ident().path().await?.clone_value(); let path = chunk_item.asset_ident().path().owned().await?;
Some(path) Some(path)
} else { } else {
None None
...@@ -108,7 +108,7 @@ impl Chunk for EcmascriptChunk { ...@@ -108,7 +108,7 @@ impl Chunk for EcmascriptChunk {
path: if let Some(common_path) = common_path { path: if let Some(common_path) = common_path {
common_path common_path
} else { } else {
ServerFileSystem::new().root().await?.clone_value() ServerFileSystem::new().root().owned().await?
}, },
query: RcStr::default(), query: RcStr::default(),
fragment: RcStr::default(), fragment: RcStr::default(),
......
...@@ -34,7 +34,7 @@ pub trait EcmascriptChunkPlaceable: ChunkableModule + Module + Asset { ...@@ -34,7 +34,7 @@ pub trait EcmascriptChunkPlaceable: ChunkableModule + Module + Asset {
side_effect_free_packages: Vc<Glob>, side_effect_free_packages: Vc<Glob>,
) -> Result<Vc<bool>> { ) -> Result<Vc<bool>> {
Ok(is_marked_as_side_effect_free( Ok(is_marked_as_side_effect_free(
self.ident().path().await?.clone_value(), self.ident().path().owned().await?,
side_effect_free_packages, side_effect_free_packages,
)) ))
} }
......
...@@ -694,7 +694,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleAsset { ...@@ -694,7 +694,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleAsset {
) -> Result<Vc<bool>> { ) -> Result<Vc<bool>> {
// Check package.json first, so that we can skip parsing the module if it's marked that way. // Check package.json first, so that we can skip parsing the module if it's marked that way.
let pkg_side_effect_free = is_marked_as_side_effect_free( let pkg_side_effect_free = is_marked_as_side_effect_free(
self.ident().path().await?.clone_value(), self.ident().path().owned().await?,
side_effect_free_packages, side_effect_free_packages,
); );
Ok(if *pkg_side_effect_free.await? { Ok(if *pkg_side_effect_free.await? {
......
...@@ -32,7 +32,7 @@ impl ManifestChunkItem { ...@@ -32,7 +32,7 @@ impl ManifestChunkItem {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn chunks_data(&self) -> Result<Vc<ChunksData>> { async fn chunks_data(&self) -> Result<Vc<ChunksData>> {
Ok(ChunkData::from_assets( Ok(ChunkData::from_assets(
self.chunking_context.output_root().await?.clone_value(), self.chunking_context.output_root().owned().await?,
self.manifest.chunks(), self.manifest.chunks(),
)) ))
} }
......
...@@ -69,7 +69,7 @@ impl ManifestLoaderChunkItem { ...@@ -69,7 +69,7 @@ impl ManifestLoaderChunkItem {
pub async fn chunks_data(&self) -> Result<Vc<ChunksData>> { pub async fn chunks_data(&self) -> Result<Vc<ChunksData>> {
let chunks = self.manifest.manifest_chunks(); let chunks = self.manifest.manifest_chunks();
Ok(ChunkData::from_assets( Ok(ChunkData::from_assets(
self.chunking_context.output_root().await?.clone_value(), self.chunking_context.output_root().owned().await?,
chunks, chunks,
)) ))
} }
......
...@@ -218,7 +218,7 @@ async fn parse_internal( ...@@ -218,7 +218,7 @@ async fn parse_internal(
transforms: Vc<EcmascriptInputTransforms>, transforms: Vc<EcmascriptInputTransforms>,
) -> Result<Vc<ParseResult>> { ) -> Result<Vc<ParseResult>> {
let content = source.content(); let content = source.content();
let fs_path_vc = source.ident().path().await?.clone_value(); let fs_path_vc = source.ident().path().owned().await?;
let fs_path = fs_path_vc.clone(); let fs_path = fs_path_vc.clone();
let ident = &*source.ident().to_string().await?; let ident = &*source.ident().to_string().await?;
let file_path_hash = hash_xxh3_hash64(&*source.ident().to_string().await?) as u128; let file_path_hash = hash_xxh3_hash64(&*source.ident().to_string().await?) as u128;
......
...@@ -526,7 +526,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( ...@@ -526,7 +526,7 @@ pub(crate) async fn analyse_ecmascript_module_internal(
let origin = ResolvedVc::upcast::<Box<dyn ResolveOrigin>>(module); let origin = ResolvedVc::upcast::<Box<dyn ResolveOrigin>>(module);
let mut analysis = AnalyzeEcmascriptModuleResultBuilder::new(); let mut analysis = AnalyzeEcmascriptModuleResultBuilder::new();
let path = origin.origin_path().await?.clone_value(); let path = origin.origin_path().owned().await?;
// Is this a typescript file that requires analyzing type references? // Is this a typescript file that requires analyzing type references?
let analyze_types = match &ty { let analyze_types = match &ty {
...@@ -545,8 +545,8 @@ pub(crate) async fn analyse_ecmascript_module_internal( ...@@ -545,8 +545,8 @@ pub(crate) async fn analyse_ecmascript_module_internal(
let ModuleTypeResult { let ModuleTypeResult {
module_type: specified_type, module_type: specified_type,
referenced_package_json, ref referenced_package_json,
} = module.determine_module_type().await?.clone_value(); } = *module.determine_module_type().await?;
if let Some(package_json) = referenced_package_json { if let Some(package_json) = referenced_package_json {
let span = tracing::info_span!("package.json reference"); let span = tracing::info_span!("package.json reference");
...@@ -692,7 +692,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( ...@@ -692,7 +692,7 @@ pub(crate) async fn analyse_ecmascript_module_internal(
static JSON_DATA_URL_BASE64: LazyLock<Regex> = LazyLock::new(|| { static JSON_DATA_URL_BASE64: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"^data:application\/json;(?:charset=utf-8;)?base64").unwrap() Regex::new(r"^data:application\/json;(?:charset=utf-8;)?base64").unwrap()
}); });
let origin_path = origin.origin_path().await?.clone_value(); let origin_path = origin.origin_path().owned().await?;
if path.ends_with(".map") { if path.ends_with(".map") {
let source_map_origin = origin_path.parent().join(path)?; let source_map_origin = origin_path.parent().join(path)?;
let reference = SourceMapReference::new(origin_path, source_map_origin) let reference = SourceMapReference::new(origin_path, source_map_origin)
...@@ -1421,7 +1421,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( ...@@ -1421,7 +1421,7 @@ pub(crate) async fn analyse_ecmascript_module_internal(
if analysis_state.first_import_meta { if analysis_state.first_import_meta {
analysis_state.first_import_meta = false; analysis_state.first_import_meta = false;
analysis.add_code_gen(ImportMetaBinding::new( analysis.add_code_gen(ImportMetaBinding::new(
source.ident().path().await?.clone_value(), source.ident().path().owned().await?,
)); ));
} }
...@@ -1948,7 +1948,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>( ...@@ -1948,7 +1948,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
} }
JsValue::WellKnownFunction(WellKnownFunctionKind::PathResolve(..)) => { JsValue::WellKnownFunction(WellKnownFunctionKind::PathResolve(..)) => {
let parent_path = origin.origin_path().await?.clone_value().parent(); let parent_path = origin.origin_path().owned().await?.parent();
let args = linked_args(args).await?; let args = linked_args(args).await?;
let linked_func_call = state let linked_func_call = state
...@@ -2220,12 +2220,9 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>( ...@@ -2220,12 +2220,9 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
.await?; .await?;
if let Some(s) = first_arg.as_str() { if let Some(s) = first_arg.as_str() {
analysis.add_reference( analysis.add_reference(
NodeBindingsReference::new( NodeBindingsReference::new(origin.origin_path().owned().await?, s.into())
origin.origin_path().await?.clone_value(), .to_resolved()
s.into(), .await?,
)
.to_resolved()
.await?,
); );
return Ok(()); return Ok(());
} }
...@@ -2637,7 +2634,7 @@ async fn handle_free_var_reference( ...@@ -2637,7 +2634,7 @@ async fn handle_free_var_reference(
)); ));
} }
FreeVarReference::InputRelative(kind) => { FreeVarReference::InputRelative(kind) => {
let source_path = (*state.source).ident().path().await?.clone_value(); let source_path = (*state.source).ident().path().owned().await?;
let source_path = match kind { let source_path = match kind {
InputRelativeConstant::DirName => source_path.parent(), InputRelativeConstant::DirName => source_path.parent(),
InputRelativeConstant::FileName => source_path, InputRelativeConstant::FileName => source_path,
...@@ -2982,10 +2979,10 @@ async fn value_visitor_inner( ...@@ -2982,10 +2979,10 @@ async fn value_visitor_inner(
} }
} }
JsValue::FreeVar(ref kind) => match &**kind { JsValue::FreeVar(ref kind) => match &**kind {
"__dirname" => as_abs_path(origin.origin_path().await?.clone_value().parent()) "__dirname" => as_abs_path(origin.origin_path().owned().await?.parent())
.await? .await?
.into(), .into(),
"__filename" => as_abs_path(origin.origin_path().await?.clone_value()) "__filename" => as_abs_path(origin.origin_path().owned().await?)
.await? .await?
.into(), .into(),
...@@ -3050,7 +3047,7 @@ async fn require_resolve_visitor( ...@@ -3050,7 +3047,7 @@ async fn require_resolve_visitor(
.await? .await?
.iter() .iter()
.map(|&source| async move { .map(|&source| async move {
require_resolve(source.ident().path().await?.clone_value()) require_resolve(source.ident().path().owned().await?)
.await .await
.map(JsValue::from) .map(JsValue::from)
}) })
...@@ -3107,8 +3104,8 @@ async fn require_context_visitor( ...@@ -3107,8 +3104,8 @@ async fn require_context_visitor(
let dir = origin let dir = origin
.origin_path() .origin_path()
.owned()
.await? .await?
.clone_value()
.parent() .parent()
.join(options.dir.as_str())?; .join(options.dir.as_str())?;
......
...@@ -80,7 +80,7 @@ async fn resolve_reference_from_dir( ...@@ -80,7 +80,7 @@ async fn resolve_reference_from_dir(
let matches = match (abs_path, rel_path) { let matches = match (abs_path, rel_path) {
(Some(abs_path), Some(rel_path)) => Either::Right( (Some(abs_path), Some(rel_path)) => Either::Right(
read_matches( read_matches(
parent_path.root().await?.clone_value(), parent_path.root().owned().await?,
rcstr!("/ROOT/"), rcstr!("/ROOT/"),
true, true,
Pattern::new(abs_path.or_any_nested_file()), Pattern::new(abs_path.or_any_nested_file()),
...@@ -101,7 +101,7 @@ async fn resolve_reference_from_dir( ...@@ -101,7 +101,7 @@ async fn resolve_reference_from_dir(
(Some(abs_path), None) => Either::Left( (Some(abs_path), None) => Either::Left(
// absolute path only // absolute path only
read_matches( read_matches(
parent_path.root().await?.clone_value(), parent_path.root().owned().await?,
rcstr!("/ROOT/"), rcstr!("/ROOT/"),
true, true,
Pattern::new(abs_path.or_any_nested_file()), Pattern::new(abs_path.or_any_nested_file()),
......
...@@ -354,7 +354,7 @@ async fn to_single_pattern_mapping( ...@@ -354,7 +354,7 @@ async fn to_single_pattern_mapping(
.into(), .into(),
) )
.resolved_cell(), .resolved_cell(),
path: origin.origin_path().await?.clone_value(), path: origin.origin_path().owned().await?,
} }
.resolved_cell() .resolved_cell()
.emit(); .emit();
...@@ -380,7 +380,7 @@ async fn to_single_pattern_mapping( ...@@ -380,7 +380,7 @@ async fn to_single_pattern_mapping(
"asset is not placeable in ESM chunks, so it doesn't have a module id".into(), "asset is not placeable in ESM chunks, so it doesn't have a module id".into(),
) )
.resolved_cell(), .resolved_cell(),
path: origin.origin_path().await?.clone_value(), path: origin.origin_path().owned().await?,
} }
.resolved_cell() .resolved_cell()
.emit(); .emit();
......
...@@ -73,7 +73,7 @@ impl WorkerAssetReference { ...@@ -73,7 +73,7 @@ impl WorkerAssetReference {
title: StyledString::Text(rcstr!("non-ecmascript placeable asset")).resolved_cell(), title: StyledString::Text(rcstr!("non-ecmascript placeable asset")).resolved_cell(),
message: StyledString::Text(rcstr!("asset is not placeable in ESM chunks")) message: StyledString::Text(rcstr!("asset is not placeable in ESM chunks"))
.resolved_cell(), .resolved_cell(),
path: self.origin.origin_path().await?.clone_value(), path: self.origin.origin_path().owned().await?,
} }
.resolved_cell() .resolved_cell()
.emit(); .emit();
......
...@@ -48,7 +48,7 @@ impl WorkerLoaderChunkItem { ...@@ -48,7 +48,7 @@ impl WorkerLoaderChunkItem {
async fn chunks_data(self: Vc<Self>) -> Result<Vc<ChunksData>> { async fn chunks_data(self: Vc<Self>) -> Result<Vc<ChunksData>> {
let this = self.await?; let this = self.await?;
Ok(ChunkData::from_assets( Ok(ChunkData::from_assets(
this.chunking_context.output_root().await?.clone_value(), this.chunking_context.output_root().owned().await?,
self.chunks(), self.chunks(),
)) ))
} }
......
...@@ -120,10 +120,7 @@ impl Asset for MdxTransformedAsset { ...@@ -120,10 +120,7 @@ impl Asset for MdxTransformedAsset {
async fn content(self: ResolvedVc<Self>) -> Result<Vc<AssetContent>> { async fn content(self: ResolvedVc<Self>) -> Result<Vc<AssetContent>> {
let this = self.await?; let this = self.await?;
Ok(*transform_process_operation(self) Ok(*transform_process_operation(self)
.issue_file_path( .issue_file_path(this.source.ident().path().owned().await?, "MDX processing")
this.source.ident().path().await?.clone_value(),
"MDX processing",
)
.await? .await?
.connect() .connect()
.await? .await?
......
...@@ -100,9 +100,7 @@ async fn emit_evaluate_pool_assets_operation( ...@@ -100,9 +100,7 @@ async fn emit_evaluate_pool_assets_operation(
let runtime_asset = asset_context let runtime_asset = asset_context
.process( .process(
Vc::upcast(FileSource::new( Vc::upcast(FileSource::new(
embed_file_path(rcstr!("ipc/evaluate.ts")) embed_file_path(rcstr!("ipc/evaluate.ts")).owned().await?,
.await?
.clone_value(),
)), )),
ReferenceType::Internal(InnerAssets::empty().to_resolved().await?), ReferenceType::Internal(InnerAssets::empty().to_resolved().await?),
) )
...@@ -141,7 +139,7 @@ async fn emit_evaluate_pool_assets_operation( ...@@ -141,7 +139,7 @@ async fn emit_evaluate_pool_assets_operation(
let globals_module = asset_context let globals_module = asset_context
.process( .process(
Vc::upcast(FileSource::new( Vc::upcast(FileSource::new(
embed_file_path(rcstr!("globals.ts")).await?.clone_value(), embed_file_path(rcstr!("globals.ts")).owned().await?,
)), )),
ReferenceType::Internal(InnerAssets::empty().to_resolved().await?), ReferenceType::Internal(InnerAssets::empty().to_resolved().await?),
) )
...@@ -179,7 +177,7 @@ async fn emit_evaluate_pool_assets_operation( ...@@ -179,7 +177,7 @@ async fn emit_evaluate_pool_assets_operation(
OutputAssets::empty(), OutputAssets::empty(),
); );
let output_root = chunking_context.output_root().await?.clone_value(); let output_root = chunking_context.output_root().owned().await?;
emit_package_json(output_root.clone())? emit_package_json(output_root.clone())?
.as_side_effect() .as_side_effect()
.await?; .await?;
...@@ -289,7 +287,7 @@ pub async fn get_evaluate_pool( ...@@ -289,7 +287,7 @@ pub async fn get_evaluate_pool(
env.iter().map(|(k, v)| (k.clone(), v.clone())).collect(), env.iter().map(|(k, v)| (k.clone(), v.clone())).collect(),
assets_for_source_mapping, assets_for_source_mapping,
output_root.clone(), output_root.clone(),
chunking_context.root_path().await?.clone_value(), chunking_context.root_path().owned().await?,
available_parallelism().map_or(1, |v| v.get()), available_parallelism().map_or(1, |v| v.get()),
debug, debug,
); );
...@@ -664,7 +662,7 @@ impl EvaluateContext for BasicEvaluateContext { ...@@ -664,7 +662,7 @@ impl EvaluateContext for BasicEvaluateContext {
source: IssueSource::from_source_only(self.context_source_for_issue), source: IssueSource::from_source_only(self.context_source_for_issue),
assets_for_source_mapping: pool.assets_for_source_mapping, assets_for_source_mapping: pool.assets_for_source_mapping,
assets_root: pool.assets_root.clone(), assets_root: pool.assets_root.clone(),
root_path: self.chunking_context.root_path().await?.clone_value(), root_path: self.chunking_context.root_path().owned().await?,
} }
.resolved_cell() .resolved_cell()
.emit(); .emit();
...@@ -711,7 +709,7 @@ async fn print_error( ...@@ -711,7 +709,7 @@ async fn print_error(
.print( .print(
*pool.assets_for_source_mapping, *pool.assets_for_source_mapping,
pool.assets_root.clone(), pool.assets_root.clone(),
evaluate_context.cwd().await?.clone_value(), evaluate_context.cwd().owned().await?,
FormattingMode::Plain, FormattingMode::Plain,
) )
.await .await
......
...@@ -46,7 +46,7 @@ async fn emit( ...@@ -46,7 +46,7 @@ async fn emit(
for asset in internal_assets(intermediate_asset, intermediate_output_path).await? { for asset in internal_assets(intermediate_asset, intermediate_output_path).await? {
let _ = asset let _ = asset
.content() .content()
.write(asset.path().await?.clone_value()) .write(asset.path().owned().await?)
.resolve() .resolve()
.await?; .await?;
} }
...@@ -222,7 +222,7 @@ pub async fn get_renderer_pool_operation( ...@@ -222,7 +222,7 @@ pub async fn get_renderer_pool_operation(
let assets_for_source_mapping = let assets_for_source_mapping =
internal_assets_for_source_mapping(*intermediate_asset, output_root.clone()); internal_assets_for_source_mapping(*intermediate_asset, output_root.clone());
let entrypoint = intermediate_asset.path().await?.clone_value(); let entrypoint = intermediate_asset.path().owned().await?;
let Some(cwd) = to_sys_path(cwd.clone()).await? else { let Some(cwd) = to_sys_path(cwd.clone()).await? else {
bail!( bail!(
...@@ -267,8 +267,8 @@ pub async fn get_intermediate_asset( ...@@ -267,8 +267,8 @@ pub async fn get_intermediate_asset(
chunking_context.root_entry_chunk_group_asset( chunking_context.root_entry_chunk_group_asset(
chunking_context chunking_context
.chunk_path(None, main_entry.ident(), rcstr!(".js")) .chunk_path(None, main_entry.ident(), rcstr!(".js"))
.await? .owned()
.clone_value(), .await?,
other_entries.with_entry(*main_entry), other_entries.with_entry(*main_entry),
ModuleGraph::from_modules( ModuleGraph::from_modules(
Vc::cell(vec![ChunkGroupEntry::Entry( Vc::cell(vec![ChunkGroupEntry::Entry(
......
...@@ -207,7 +207,7 @@ impl GetContentSourceContent for NodeRenderContentSource { ...@@ -207,7 +207,7 @@ impl GetContentSourceContent for NodeRenderContentSource {
self.debug, self.debug,
) )
.issue_file_path( .issue_file_path(
entry.module.ident().path().await?.clone_value(), entry.module.ident().path().owned().await?,
format!("server-side rendering {pathname}"), format!("server-side rendering {pathname}"),
) )
.await?; .await?;
......
...@@ -65,7 +65,7 @@ pub async fn apply_source_mapping( ...@@ -65,7 +65,7 @@ pub async fn apply_source_mapping(
let resolved = resolve_source_mapping( let resolved = resolve_source_mapping(
assets_for_source_mapping, assets_for_source_mapping,
root.clone(), root.clone(),
project_dir.root().await?.clone_value(), project_dir.root().owned().await?,
&frame, &frame,
) )
.await; .await;
......
...@@ -169,7 +169,7 @@ impl Asset for PostCssTransformedAsset { ...@@ -169,7 +169,7 @@ impl Asset for PostCssTransformedAsset {
let this = self.await?; let this = self.await?;
Ok(*transform_process_operation(self) Ok(*transform_process_operation(self)
.issue_file_path( .issue_file_path(
this.source.ident().path().await?.clone_value(), this.source.ident().path().owned().await?,
"PostCSS processing", "PostCSS processing",
) )
.await? .await?
...@@ -403,8 +403,8 @@ async fn postcss_executor( ...@@ -403,8 +403,8 @@ async fn postcss_executor(
Ok(asset_context.process( Ok(asset_context.process(
Vc::upcast(FileSource::new( Vc::upcast(FileSource::new(
embed_file_path(rcstr!("transforms/postcss.ts")) embed_file_path(rcstr!("transforms/postcss.ts"))
.await? .owned()
.clone_value(), .await?,
)), )),
ReferenceType::Internal(ResolvedVc::cell(fxindexmap! { ReferenceType::Internal(ResolvedVc::cell(fxindexmap! {
rcstr!("CONFIG") => config_asset rcstr!("CONFIG") => config_asset
......
...@@ -192,8 +192,8 @@ async fn webpack_loaders_executor( ...@@ -192,8 +192,8 @@ async fn webpack_loaders_executor(
Ok(evaluate_context.process( Ok(evaluate_context.process(
Vc::upcast(FileSource::new( Vc::upcast(FileSource::new(
embed_file_path(rcstr!("transforms/webpack-loaders.ts")) embed_file_path(rcstr!("transforms/webpack-loaders.ts"))
.await? .owned()
.clone_value(), .await?,
)), )),
ReferenceType::Internal(InnerAssets::empty().to_resolved().await?), ReferenceType::Internal(InnerAssets::empty().to_resolved().await?),
)) ))
...@@ -243,7 +243,7 @@ impl WebpackLoadersProcessedAsset { ...@@ -243,7 +243,7 @@ impl WebpackLoadersProcessedAsset {
.to_resolved() .to_resolved()
.await?; .await?;
let resource_fs_path = this.source.ident().path().await?.clone_value(); let resource_fs_path = this.source.ident().path().owned().await?;
let resource_fs_path_ref = resource_fs_path.clone(); let resource_fs_path_ref = resource_fs_path.clone();
let Some(resource_path) = project_path.get_relative_path_to(&resource_fs_path_ref) else { let Some(resource_path) = project_path.get_relative_path_to(&resource_fs_path_ref) else {
bail!(format!( bail!(format!(
...@@ -472,7 +472,7 @@ impl EvaluateContext for WebpackLoaderContext { ...@@ -472,7 +472,7 @@ impl EvaluateContext for WebpackLoaderContext {
source: IssueSource::from_source_only(self.context_source_for_issue), source: IssueSource::from_source_only(self.context_source_for_issue),
assets_for_source_mapping: pool.assets_for_source_mapping, assets_for_source_mapping: pool.assets_for_source_mapping,
assets_root: pool.assets_root.clone(), assets_root: pool.assets_root.clone(),
root_path: self.chunking_context.root_path().await?.clone_value(), root_path: self.chunking_context.root_path().owned().await?,
} }
.resolved_cell() .resolved_cell()
.emit(); .emit();
...@@ -543,7 +543,7 @@ impl EvaluateContext for WebpackLoaderContext { ...@@ -543,7 +543,7 @@ impl EvaluateContext for WebpackLoaderContext {
severity, severity,
assets_for_source_mapping: pool.assets_for_source_mapping, assets_for_source_mapping: pool.assets_for_source_mapping,
assets_root: pool.assets_root.clone(), assets_root: pool.assets_root.clone(),
project_dir: self.chunking_context.root_path().await?.clone_value(), project_dir: self.chunking_context.root_path().owned().await?,
} }
.resolved_cell() .resolved_cell()
.emit(); .emit();
...@@ -635,7 +635,7 @@ impl EvaluateContext for WebpackLoaderContext { ...@@ -635,7 +635,7 @@ impl EvaluateContext for WebpackLoaderContext {
}, },
assets_for_source_mapping: pool.assets_for_source_mapping, assets_for_source_mapping: pool.assets_for_source_mapping,
assets_root: pool.assets_root.clone(), assets_root: pool.assets_root.clone(),
project_dir: self.chunking_context.root_path().await?.clone_value(), project_dir: self.chunking_context.root_path().owned().await?,
} }
.resolved_cell() .resolved_cell()
.emit(); .emit();
......
...@@ -87,8 +87,8 @@ impl EcmascriptBuildNodeChunkContent { ...@@ -87,8 +87,8 @@ impl EcmascriptBuildNodeChunkContent {
#[turbo_tasks::function] #[turbo_tasks::function]
pub(crate) async fn own_version(&self) -> Result<Vc<EcmascriptBuildNodeChunkVersion>> { pub(crate) async fn own_version(&self) -> Result<Vc<EcmascriptBuildNodeChunkVersion>> {
Ok(EcmascriptBuildNodeChunkVersion::new( Ok(EcmascriptBuildNodeChunkVersion::new(
self.chunking_context.output_root().await?.clone_value(), self.chunking_context.output_root().owned().await?,
self.chunk.path().await?.clone_value(), self.chunk.path().owned().await?,
*self.content, *self.content,
*self.chunking_context.minify_type().await?, *self.chunking_context.minify_type().await?,
)) ))
......
...@@ -57,10 +57,10 @@ impl EcmascriptBuildNodeEntryChunk { ...@@ -57,10 +57,10 @@ impl EcmascriptBuildNodeEntryChunk {
async fn code(self: Vc<Self>) -> Result<Vc<Code>> { async fn code(self: Vc<Self>) -> Result<Vc<Code>> {
let this = self.await?; let this = self.await?;
let output_root = this.chunking_context.output_root().await?.clone_value(); let output_root = this.chunking_context.output_root().owned().await?;
let chunk_path = self.path().await?.clone_value(); let chunk_path = self.path().owned().await?;
let chunk_directory = self.path().await?.parent(); let chunk_directory = self.path().await?.parent();
let runtime_path = self.runtime_chunk().path().await?.clone_value(); let runtime_path = self.runtime_chunk().path().owned().await?;
let runtime_relative_path = let runtime_relative_path =
if let Some(path) = chunk_directory.get_relative_path_to(&runtime_path) { if let Some(path) = chunk_directory.get_relative_path_to(&runtime_path) {
path path
......
...@@ -137,7 +137,7 @@ pub async fn cjs_resolve_source( ...@@ -137,7 +137,7 @@ pub async fn cjs_resolve_source(
handle_resolve_source_error( handle_resolve_source_error(
result, result,
ty, ty,
origin.origin_path().await?.clone_value(), origin.origin_path().owned().await?,
*request, *request,
options, options,
is_optional, is_optional,
...@@ -161,7 +161,7 @@ async fn specific_resolve( ...@@ -161,7 +161,7 @@ async fn specific_resolve(
handle_resolve_error( handle_resolve_error(
result, result,
reference_type, reference_type,
origin.origin_path().await?.clone_value(), origin.origin_path().owned().await?,
request, request,
options, options,
is_optional, is_optional,
......
...@@ -105,7 +105,7 @@ pub async fn resolve_node_pre_gyp_files( ...@@ -105,7 +105,7 @@ pub async fn resolve_node_pre_gyp_files(
&& let AssetContent::File(file) = &*config_asset.content().await? && let AssetContent::File(file) = &*config_asset.content().await?
&& let FileContent::Content(config_file) = &*file.await? && let FileContent::Content(config_file) = &*file.await?
{ {
let config_file_path = config_asset.ident().path().await?.clone_value(); let config_file_path = config_asset.ident().path().owned().await?;
let mut affecting_paths = vec![config_file_path.clone()]; let mut affecting_paths = vec![config_file_path.clone()];
let config_file_dir = config_file_path.parent(); let config_file_dir = config_file_path.parent();
let node_pre_gyp_config: NodePreGypConfigJson = let node_pre_gyp_config: NodePreGypConfigJson =
......
...@@ -91,7 +91,7 @@ async fn base_resolve_options( ...@@ -91,7 +91,7 @@ async fn base_resolve_options(
) -> Result<Vc<ResolveOptions>> { ) -> Result<Vc<ResolveOptions>> {
let opt = options_context.await?; let opt = options_context.await?;
let emulating = opt.emulate_environment; let emulating = opt.emulate_environment;
let root = fs.root().await?.clone_value(); let root = fs.root().owned().await?;
let mut direct_mappings = AliasMap::new(); let mut direct_mappings = AliasMap::new();
let node_externals = if let Some(environment) = emulating { let node_externals = if let Some(environment) = emulating {
environment.node_externals().owned().await? environment.node_externals().owned().await?
......
...@@ -267,7 +267,7 @@ pub async fn tsconfig_resolve_options( ...@@ -267,7 +267,7 @@ pub async fn tsconfig_resolve_options(
let configs = read_tsconfigs( let configs = read_tsconfigs(
tsconfig.read(), tsconfig.read(),
ResolvedVc::upcast(FileSource::new(tsconfig.clone()).to_resolved().await?), ResolvedVc::upcast(FileSource::new(tsconfig.clone()).to_resolved().await?),
node_cjs_resolve_options(tsconfig.root().await?.clone_value()), node_cjs_resolve_options(tsconfig.root().owned().await?),
) )
.await?; .await?;
...@@ -473,7 +473,7 @@ pub async fn type_resolve( ...@@ -473,7 +473,7 @@ pub async fn type_resolve(
handle_resolve_error( handle_resolve_error(
result, result,
ty, ty,
origin.origin_path().await?.clone_value(), origin.origin_path().owned().await?,
request, request,
options, options,
false, false,
......
...@@ -137,7 +137,7 @@ impl EcmascriptChunkItem for StaticUrlJsChunkItem { ...@@ -137,7 +137,7 @@ impl EcmascriptChunkItem for StaticUrlJsChunkItem {
path = StringifyJs( path = StringifyJs(
&self &self
.chunking_context .chunking_context
.asset_url(self.static_asset.path().await?.clone_value()) .asset_url(self.static_asset.path().owned().await?)
.await? .await?
) )
) )
......
...@@ -283,7 +283,7 @@ async fn prepare_test(resource: RcStr) -> Result<Vc<PreparedTest>> { ...@@ -283,7 +283,7 @@ async fn prepare_test(resource: RcStr) -> Result<Vc<PreparedTest>> {
let root_fs = DiskFileSystem::new(rcstr!("workspace"), REPO_ROOT.clone(), vec![]); let root_fs = DiskFileSystem::new(rcstr!("workspace"), REPO_ROOT.clone(), vec![]);
let project_fs = DiskFileSystem::new(rcstr!("project"), REPO_ROOT.clone(), vec![]); let project_fs = DiskFileSystem::new(rcstr!("project"), REPO_ROOT.clone(), vec![]);
let project_root = project_fs.root().await?.clone_value(); let project_root = project_fs.root().owned().await?;
let relative_path = resource_path.strip_prefix(&*REPO_ROOT).context(format!( let relative_path = resource_path.strip_prefix(&*REPO_ROOT).context(format!(
"stripping repo root {:?} from resource path {:?}", "stripping repo root {:?} from resource path {:?}",
......
...@@ -233,11 +233,7 @@ async fn run(resource: PathBuf) -> Result<()> { ...@@ -233,11 +233,7 @@ async fn run(resource: PathBuf) -> Result<()> {
#[turbo_tasks::function(operation)] #[turbo_tasks::function(operation)]
async fn run_inner_operation(resource: RcStr) -> Result<()> { async fn run_inner_operation(resource: RcStr) -> Result<()> {
let out_op = run_test_operation(resource); let out_op = run_test_operation(resource);
let out_vc = out_op let out_vc = out_op.resolve_strongly_consistent().await?.owned().await?;
.resolve_strongly_consistent()
.await?
.await?
.clone_value();
let captured_issues = out_op.peek_issues_with_path().await?; let captured_issues = out_op.peek_issues_with_path().await?;
let plain_issues = captured_issues.get_plain_issues().await?; let plain_issues = captured_issues.get_plain_issues().await?;
...@@ -265,7 +261,7 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> { ...@@ -265,7 +261,7 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
Ok(options_str) => parse_json_with_source_context(&options_str).unwrap(), Ok(options_str) => parse_json_with_source_context(&options_str).unwrap(),
}; };
let project_fs = DiskFileSystem::new(rcstr!("project"), REPO_ROOT.clone(), vec![]); let project_fs = DiskFileSystem::new(rcstr!("project"), REPO_ROOT.clone(), vec![]);
let project_root = project_fs.root().await?.clone_value(); let project_root = project_fs.root().owned().await?;
let relative_path = test_path.strip_prefix(&*REPO_ROOT)?; let relative_path = test_path.strip_prefix(&*REPO_ROOT)?;
let relative_path: RcStr = sys_to_unix(relative_path.to_str().unwrap()).into(); let relative_path: RcStr = sys_to_unix(relative_path.to_str().unwrap()).into();
...@@ -552,7 +548,7 @@ async fn walk_asset( ...@@ -552,7 +548,7 @@ async fn walk_asset(
seen: &mut FxHashSet<FileSystemPath>, seen: &mut FxHashSet<FileSystemPath>,
queue: &mut VecDeque<ResolvedVc<Box<dyn OutputAsset>>>, queue: &mut VecDeque<ResolvedVc<Box<dyn OutputAsset>>>,
) -> Result<()> { ) -> Result<()> {
let path = asset.path().await?.clone_value(); let path = asset.path().owned().await?;
if !seen.insert(path.clone()) { if !seen.insert(path.clone()) {
return Ok(()); return Ok(());
......
...@@ -84,7 +84,7 @@ fn bench_emit(b: &mut Bencher, bench_input: &BenchInput) { ...@@ -84,7 +84,7 @@ fn bench_emit(b: &mut Bencher, bench_input: &BenchInput) {
let input_dir = input.parent().parent(); let input_dir = input.parent().parent();
let output_fs: Vc<NullFileSystem> = NullFileSystem.into(); let output_fs: Vc<NullFileSystem> = NullFileSystem.into();
let output_dir = output_fs.root().await?.clone_value(); let output_dir = output_fs.root().owned().await?;
let source = FileSource::new(input); let source = FileSource::new(input);
let compile_time_info = CompileTimeInfo::builder( let compile_time_info = CompileTimeInfo::builder(
......
...@@ -56,7 +56,7 @@ async fn main() -> Result<()> { ...@@ -56,7 +56,7 @@ async fn main() -> Result<()> {
ResolveOptionsContext { ResolveOptionsContext {
enable_typescript: true, enable_typescript: true,
enable_react: true, enable_react: true,
enable_node_modules: Some(fs.root().await?.clone_value()), enable_node_modules: Some(fs.root().owned().await?),
custom_conditions: vec![rcstr!("development")], custom_conditions: vec![rcstr!("development")],
..Default::default() ..Default::default()
} }
......
...@@ -46,12 +46,7 @@ pub async fn node_evaluate_asset_context( ...@@ -46,12 +46,7 @@ pub async fn node_evaluate_asset_context(
"@vercel/turbopack-node/", "@vercel/turbopack-node/",
ImportMapping::PrimaryAlternative( ImportMapping::PrimaryAlternative(
rcstr!("./*"), rcstr!("./*"),
Some( Some(turbopack_node::embed_js::embed_fs().root().owned().await?),
turbopack_node::embed_js::embed_fs()
.root()
.await?
.clone_value(),
),
) )
.resolved_cell(), .resolved_cell(),
); );
...@@ -71,8 +66,8 @@ pub async fn node_evaluate_asset_context( ...@@ -71,8 +66,8 @@ pub async fn node_evaluate_asset_context(
.project_path() .project_path()
.await? .await?
.root() .root()
.await? .owned()
.clone_value(), .await?,
), ),
enable_node_externals: true, enable_node_externals: true,
enable_node_native_modules: true, enable_node_native_modules: true,
......
...@@ -935,7 +935,7 @@ async fn emit_aggregated_assets( ...@@ -935,7 +935,7 @@ async fn emit_aggregated_assets(
pub async fn emit_asset(asset: Vc<Box<dyn OutputAsset>>) -> Result<()> { pub async fn emit_asset(asset: Vc<Box<dyn OutputAsset>>) -> Result<()> {
asset asset
.content() .content()
.write(asset.path().await?.clone_value()) .write(asset.path().owned().await?)
.as_side_effect() .as_side_effect()
.await?; .await?;
......
...@@ -650,7 +650,7 @@ impl ModuleOptions { ...@@ -650,7 +650,7 @@ impl ModuleOptions {
match &condition.path { match &condition.path {
ConditionPath::Glob(glob) => RuleCondition::ResourcePathGlob { ConditionPath::Glob(glob) => RuleCondition::ResourcePathGlob {
base: execution_context.project_path().await?.clone_value(), base: execution_context.project_path().owned().await?,
glob: Glob::new(glob.clone()).await?, glob: Glob::new(glob.clone()).await?,
}, },
ConditionPath::Regex(regex) => { ConditionPath::Regex(regex) => {
...@@ -659,7 +659,7 @@ impl ModuleOptions { ...@@ -659,7 +659,7 @@ impl ModuleOptions {
} }
} else if key.contains('/') { } else if key.contains('/') {
RuleCondition::ResourcePathGlob { RuleCondition::ResourcePathGlob {
base: execution_context.project_path().await?.clone_value(), base: execution_context.project_path().owned().await?,
glob: Glob::new(key.clone()).await?, glob: Glob::new(key.clone()).await?,
} }
} else { } else {
......
...@@ -33,7 +33,7 @@ impl AfterResolvePlugin for UnsupportedSassResolvePlugin { ...@@ -33,7 +33,7 @@ impl AfterResolvePlugin for UnsupportedSassResolvePlugin {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn after_resolve_condition(&self) -> Result<Vc<AfterResolvePluginCondition>> { async fn after_resolve_condition(&self) -> Result<Vc<AfterResolvePluginCondition>> {
Ok(AfterResolvePluginCondition::new( Ok(AfterResolvePluginCondition::new(
self.root.root().await?.clone_value(), self.root.root().owned().await?,
Glob::new("**/*.{sass,scss}".into()), Glob::new("**/*.{sass,scss}".into()),
)) ))
} }
......
...@@ -339,11 +339,11 @@ async fn node_file_trace_operation( ...@@ -339,11 +339,11 @@ async fn node_file_trace_operation(
package_root.clone(), package_root.clone(),
vec![], vec![],
)); ));
let input_dir = workspace_fs.root().await?.clone_value(); let input_dir = workspace_fs.root().owned().await?;
let input = input_dir.join(&format!("tests/{input}"))?; let input = input_dir.join(&format!("tests/{input}"))?;
let output_fs = DiskFileSystem::new(rcstr!("output"), directory.clone(), vec![]); let output_fs = DiskFileSystem::new(rcstr!("output"), directory.clone(), vec![]);
let output_dir = output_fs.root().await?.clone_value(); let output_dir = output_fs.root().owned().await?;
let source = FileSource::new(input); let source = FileSource::new(input);
let environment = Environment::new(ExecutionEnvironment::NodeJsLambda( let environment = Environment::new(ExecutionEnvironment::NodeJsLambda(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment