From 363c16ef72105df2bfa07448fa636dc73a497351 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 25 May 2023 13:54:48 +0000 Subject: [PATCH 1/9] replace EcmascriptModuleAssetVc::new_with_internal_assets with ReferenceType::Internal --- .../crates/next-core/src/app_source.rs | 65 +++++++------------ .../crates/next-core/src/bootstrap.rs | 28 ++++---- .../next-core/src/next_client/transition.rs | 38 +++-------- .../server_to_client_transition.rs | 34 ++-------- .../crates/next-core/src/next_image/module.rs | 22 ++----- .../next-core/src/next_image/source_asset.rs | 5 +- .../crates/next-core/src/page_loader.rs | 30 ++++----- .../crates/next-core/src/page_source.rs | 38 ++++------- .../next-swc/crates/next-core/src/router.rs | 25 +++---- 9 files changed, 92 insertions(+), 193 deletions(-) diff --git a/packages/next-swc/crates/next-core/src/app_source.rs b/packages/next-swc/crates/next-core/src/app_source.rs index fd54ba0d9be6c..0ef4b3f4a9422 100644 --- a/packages/next-swc/crates/next-core/src/app_source.rs +++ b/packages/next-swc/crates/next-core/src/app_source.rs @@ -1,15 +1,12 @@ use std::{collections::HashMap, io::Write, iter::once}; -use anyhow::Result; +use anyhow::{bail, Result}; use async_recursion::async_recursion; use indexmap::{indexmap, IndexMap}; use turbo_tasks::{primitives::JsonValueVc, TryJoinIterExt, ValueToString}; use turbopack_binding::{ turbo::{ - tasks::{ - primitives::{OptionStringVc, StringVc}, - Value, - }, + tasks::{primitives::StringVc, Value}, tasks_env::{CustomProcessEnvVc, EnvMapVc, ProcessEnvVc}, tasks_fs::{rope::RopeBuilder, File, FileContent, FileSystemPathVc}, }, @@ -22,7 +19,8 @@ use turbopack_binding::{ environment::{EnvironmentIntention, ServerAddrVc}, issue::{Issue, IssueSeverity, IssueSeverityVc, IssueVc}, reference_type::{ - EcmaScriptModulesReferenceSubType, EntryReferenceSubType, ReferenceType, + EcmaScriptModulesReferenceSubType, EntryReferenceSubType, InnerAssetsVc, + ReferenceType, }, source_asset::SourceAssetVc, virtual_asset::VirtualAssetVc, @@ -41,8 +39,6 @@ use turbopack_binding::{ magic_identifier, text::TextContentSourceAssetVc, utils::{FormatIter, StringifyJs}, - EcmascriptInputTransformsVc, EcmascriptModuleAssetType, EcmascriptModuleAssetVc, - InnerAssetsVc, }, env::ProcessEnvAssetVc, node::{ @@ -55,7 +51,6 @@ use turbopack_binding::{ }, r#static::{fixed::FixedStaticAssetVc, StaticModuleAssetVc}, turbopack::{ - ecmascript::EcmascriptInputTransform, transition::{TransitionVc, TransitionsByNameVc}, ModuleAssetContextVc, }, @@ -1026,6 +1021,15 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; .reference_chunk_source_maps(false) .build(); + let module = context.process( + asset.into(), + Value::new(ReferenceType::Internal(InnerAssetsVc::cell(inner_assets))), + ); + + let Some(module) = EvaluatableAssetVc::resolve_from(module).await? else { + bail!("Internal module is not evaluatable"); + }; + Ok(NodeRenderingEntry { runtime_entries: EvaluatableAssetsVc::cell( runtime_entries @@ -1034,26 +1038,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; .map(|entry| EvaluatableAssetVc::from_asset(*entry, context)) .collect(), ), - module: EcmascriptModuleAssetVc::new_with_inner_assets( - asset.into(), - context, - Value::new(EcmascriptModuleAssetType::Typescript), - EcmascriptInputTransformsVc::cell(vec![ - EcmascriptInputTransform::React { - // The App source is currently only used in the development mode. - development: true, - refresh: false, - import_source: OptionStringVc::cell(None), - runtime: OptionStringVc::cell(None), - }, - EcmascriptInputTransform::TypeScript { - use_define_for_class_fields: false, - }, - ]), - Default::default(), - context.compile_time_info(), - InnerAssetsVc::cell(inner_assets), - ), + module, chunking_context, intermediate_output_path, output_root: intermediate_output_path.root(), @@ -1131,6 +1116,7 @@ impl AppRouteVc { bootstrap_asset, BootstrapConfigVc::empty(), ) + .into() } NextRuntime::Edge => { let internal_asset = next_asset("entry/app/edge-route.ts"); @@ -1140,19 +1126,18 @@ impl AppRouteVc { Value::new(ReferenceType::Entry(EntryReferenceSubType::AppRoute)), ); - EcmascriptModuleAssetVc::new_with_inner_assets( + let module = this.context.process( internal_asset, - this.context, - Value::new(EcmascriptModuleAssetType::Typescript), - EcmascriptInputTransformsVc::cell(vec![EcmascriptInputTransform::TypeScript { - use_define_for_class_fields: false, - }]), - Default::default(), - this.context.compile_time_info(), - InnerAssetsVc::cell(indexmap! { + Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap! { "ROUTE_CHUNK_GROUP".to_string() => entry - }), - ) + }))), + ); + + let Some(module) = EvaluatableAssetVc::resolve_from(module).await? else { + bail!("Internal module must be evaluatable"); + }; + + module } }; diff --git a/packages/next-swc/crates/next-core/src/bootstrap.rs b/packages/next-swc/crates/next-core/src/bootstrap.rs index efc7472fc7f73..3868dd8a4b5c8 100644 --- a/packages/next-swc/crates/next-core/src/bootstrap.rs +++ b/packages/next-swc/crates/next-core/src/bootstrap.rs @@ -5,17 +5,14 @@ use turbo_tasks_fs::{File, FileSystemPathVc}; use turbopack_binding::turbopack::{ core::{ asset::{Asset, AssetVc}, + chunk::EvaluatableAssetVc, context::{AssetContext, AssetContextVc}, issue::{IssueSeverity, OptionIssueSourceVc}, - reference_type::EcmaScriptModulesReferenceSubType, + reference_type::{EcmaScriptModulesReferenceSubType, InnerAssetsVc, ReferenceType}, resolve::parse::RequestVc, virtual_asset::VirtualAssetVc, }, - ecmascript::{ - resolve::esm_resolve, utils::StringifyJs, EcmascriptInputTransform, - EcmascriptInputTransformsVc, EcmascriptModuleAssetType, EcmascriptModuleAssetVc, - InnerAssetsVc, - }, + ecmascript::{resolve::esm_resolve, utils::StringifyJs, EcmascriptModuleAssetVc}, }; use crate::asset_helpers::as_es_module_asset; @@ -27,7 +24,7 @@ pub async fn route_bootstrap( base_path: FileSystemPathVc, bootstrap_asset: AssetVc, config: BootstrapConfigVc, -) -> Result { +) -> Result { let resolve_origin = if let Some(m) = EcmascriptModuleAssetVc::resolve_from(asset).await? { m.as_resolve_origin() } else { @@ -83,7 +80,7 @@ pub async fn bootstrap( bootstrap_asset: AssetVc, inner_assets: InnerAssetsVc, config: BootstrapConfigVc, -) -> Result { +) -> Result { let path = asset.ident().path().await?; let path = base_path .await? @@ -126,18 +123,15 @@ pub async fn bootstrap( inner_assets.insert("ENTRY".to_string(), asset); inner_assets.insert("BOOTSTRAP_CONFIG".to_string(), config_asset); - let asset = EcmascriptModuleAssetVc::new_with_inner_assets( + let asset = context.process( bootstrap_asset, - context, - Value::new(EcmascriptModuleAssetType::Typescript), - EcmascriptInputTransformsVc::cell(vec![EcmascriptInputTransform::TypeScript { - use_define_for_class_fields: false, - }]), - Default::default(), - context.compile_time_info(), - InnerAssetsVc::cell(inner_assets), + Value::new(ReferenceType::Internal(InnerAssetsVc::cell(inner_assets))), ); + let Some(asset) = EvaluatableAssetVc::resolve_from(asset).await? else { + bail!("internal asset is not evaluatable"); + }; + Ok(asset) } diff --git a/packages/next-swc/crates/next-core/src/next_client/transition.rs b/packages/next-swc/crates/next-core/src/next_client/transition.rs index 767ebbbaadfe3..5418da8778f51 100644 --- a/packages/next-swc/crates/next-core/src/next_client/transition.rs +++ b/packages/next-swc/crates/next-core/src/next_client/transition.rs @@ -1,17 +1,15 @@ use anyhow::{bail, Result}; use indexmap::indexmap; -use turbo_tasks::{primitives::OptionStringVc, Value}; +use turbo_tasks::Value; use turbopack_binding::turbopack::{ core::{ asset::AssetVc, chunk::{ChunkingContext, ChunkingContextVc}, compile_time_info::CompileTimeInfoVc, context::AssetContext, + reference_type::{InnerAssetsVc, ReferenceType}, }, - ecmascript::{ - chunk::EcmascriptChunkPlaceableVc, EcmascriptInputTransform, EcmascriptInputTransformsVc, - EcmascriptModuleAssetType, EcmascriptModuleAssetVc, InnerAssetsVc, - }, + ecmascript::chunk::EcmascriptChunkPlaceableVc, turbopack::{ ecmascript::chunk_group_files_asset::ChunkGroupFilesAsset, module_options::ModuleOptionsContextVc, @@ -74,36 +72,18 @@ impl Transition for NextClientTransition { let asset = if !self.is_app { let internal_asset = next_asset("entry/next-hydrate.tsx"); - EcmascriptModuleAssetVc::new_with_inner_assets( + context.process( internal_asset, - context.into(), - Value::new(EcmascriptModuleAssetType::Typescript), - EcmascriptInputTransformsVc::cell(vec![ - EcmascriptInputTransform::TypeScript { - use_define_for_class_fields: false, - }, - EcmascriptInputTransform::React { - // The Next Client transition is currently only used from the App and Page - // sources, which are only used in the development mode. - development: true, - refresh: false, - import_source: OptionStringVc::cell(None), - runtime: OptionStringVc::cell(None), - }, - ]), - Default::default(), - context.compile_time_info(), - InnerAssetsVc::cell(indexmap! { + Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap! { "PAGE".to_string() => asset - }), + }))), ) - .into() } else { - let Some(asset) = EcmascriptChunkPlaceableVc::resolve_from(asset).await? else { - bail!("Not an ecmascript module"); - }; asset }; + let Some(asset) = EcmascriptChunkPlaceableVc::resolve_from(asset).await? else { + bail!("Not an ecmascript placeable module"); + }; let runtime_entries = self.runtime_entries.resolve_entries(context.into()); diff --git a/packages/next-swc/crates/next-core/src/next_client_component/server_to_client_transition.rs b/packages/next-swc/crates/next-core/src/next_client_component/server_to_client_transition.rs index 0a4dac047de19..938c7fa184c0f 100644 --- a/packages/next-swc/crates/next-core/src/next_client_component/server_to_client_transition.rs +++ b/packages/next-swc/crates/next-core/src/next_client_component/server_to_client_transition.rs @@ -1,15 +1,11 @@ use anyhow::Result; use indexmap::indexmap; -use turbo_tasks::{primitives::OptionStringVc, Value}; +use turbo_tasks::Value; use turbopack_binding::turbopack::{ core::{ asset::AssetVc, context::AssetContext, - reference_type::{EntryReferenceSubType, ReferenceType}, - }, - ecmascript::{ - EcmascriptInputTransform, EcmascriptInputTransformsVc, EcmascriptModuleAssetType, - EcmascriptModuleAssetVc, InnerAssetsVc, + reference_type::{EntryReferenceSubType, InnerAssetsVc, ReferenceType}, }, turbopack::{ transition::{Transition, TransitionVc}, @@ -51,30 +47,12 @@ impl Transition for NextServerToClientTransition { EntryReferenceSubType::AppClientComponent, )), ); - Ok(EcmascriptModuleAssetVc::new_with_inner_assets( + Ok(context.process( internal_asset, - context.into(), - Value::new(EcmascriptModuleAssetType::Typescript), - EcmascriptInputTransformsVc::cell(vec![ - EcmascriptInputTransform::TypeScript { - use_define_for_class_fields: false, - }, - EcmascriptInputTransform::React { - // The server-to-client transition is currently only used from the App source, - // which are only used in the development mode. - development: true, - refresh: false, - import_source: OptionStringVc::cell(None), - runtime: OptionStringVc::cell(None), - }, - ]), - Default::default(), - context.compile_time_info(), - InnerAssetsVc::cell(indexmap! { + Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap! { "CLIENT_MODULE".to_string() => client_module, "CLIENT_CHUNKS".to_string() => client_chunks, - }), - ) - .into()) + }))), + )) } } diff --git a/packages/next-swc/crates/next-core/src/next_image/module.rs b/packages/next-swc/crates/next-core/src/next_image/module.rs index 263602d7804b1..e0699f69acf33 100644 --- a/packages/next-swc/crates/next-core/src/next_image/module.rs +++ b/packages/next-swc/crates/next-core/src/next_image/module.rs @@ -7,12 +7,9 @@ use turbopack_binding::{ asset::AssetVc, context::{AssetContext, AssetContextVc}, plugin::{CustomModuleType, CustomModuleTypeVc}, + reference_type::{InnerAssetsVc, ReferenceType}, resolve::ModulePartVc, }, - ecmascript::{ - EcmascriptInputTransformsVc, EcmascriptModuleAssetType, EcmascriptModuleAssetVc, - EcmascriptOptions, InnerAssetsVc, - }, r#static::StaticModuleAssetVc, }, }; @@ -47,25 +44,18 @@ impl StructuredImageModuleType { source: AssetVc, blur_placeholder_mode: BlurPlaceholderMode, context: AssetContextVc, - ) -> EcmascriptModuleAssetVc { + ) -> AssetVc { let static_asset = StaticModuleAssetVc::new(source, context); - EcmascriptModuleAssetVc::new_with_inner_assets( + context.process( StructuredImageSourceAsset { image: source, blur_placeholder_mode, } .cell() .into(), - context, - Value::new(EcmascriptModuleAssetType::Ecmascript), - EcmascriptInputTransformsVc::empty(), - Value::new(EcmascriptOptions { - ..Default::default() - }), - context.compile_time_info(), - InnerAssetsVc::cell(indexmap!( + Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap!( "IMAGE".to_string() => static_asset.into() - )), + )))), ) } } @@ -89,6 +79,6 @@ impl CustomModuleType for StructuredImageModuleType { context: AssetContextVc, _part: Option, ) -> AssetVc { - StructuredImageModuleType::create_module(source, self.blur_placeholder_mode, context).into() + StructuredImageModuleType::create_module(source, self.blur_placeholder_mode, context) } } diff --git a/packages/next-swc/crates/next-core/src/next_image/source_asset.rs b/packages/next-swc/crates/next-core/src/next_image/source_asset.rs index 0910aa8037249..2d6e7ff9c6f0a 100644 --- a/packages/next-swc/crates/next-core/src/next_image/source_asset.rs +++ b/packages/next-swc/crates/next-core/src/next_image/source_asset.rs @@ -43,7 +43,10 @@ pub struct StructuredImageSourceAsset { impl Asset for StructuredImageSourceAsset { #[turbo_tasks::function] fn ident(&self) -> AssetIdentVc { - self.image.ident().with_modifier(modifier()) + self.image + .ident() + .with_modifier(modifier()) + .rename_as("*.mjs") } #[turbo_tasks::function] diff --git a/packages/next-swc/crates/next-core/src/page_loader.rs b/packages/next-swc/crates/next-core/src/page_loader.rs index f8108a4172f92..1654a5ce427ca 100644 --- a/packages/next-swc/crates/next-core/src/page_loader.rs +++ b/packages/next-swc/crates/next-core/src/page_loader.rs @@ -10,20 +10,16 @@ use turbopack_binding::{ asset::{Asset, AssetContentVc, AssetVc, AssetsVc}, chunk::{ ChunkDataVc, ChunkableAsset, ChunkingContext, ChunkingContextVc, ChunksDataVc, - EvaluatableAssetsVc, + EvaluatableAssetVc, EvaluatableAssetsVc, }, context::{AssetContext, AssetContextVc}, ident::AssetIdentVc, reference::{AssetReferencesVc, SingleAssetReferenceVc}, - reference_type::{EntryReferenceSubType, ReferenceType}, + reference_type::{EntryReferenceSubType, InnerAssetsVc, ReferenceType}, virtual_asset::VirtualAssetVc, }, dev_server::source::{asset_graph::AssetGraphContentSourceVc, ContentSourceVc}, - ecmascript::{ - chunk::EcmascriptChunkData, utils::StringifyJs, EcmascriptInputTransform, - EcmascriptInputTransformsVc, EcmascriptModuleAssetType, EcmascriptModuleAssetVc, - InnerAssetsVc, - }, + ecmascript::{chunk::EcmascriptChunkData, utils::StringifyJs}, }, }; @@ -90,23 +86,21 @@ impl PageLoaderAssetVc { let loader_entry_asset = self.get_loader_entry_asset(); - let asset = EcmascriptModuleAssetVc::new_with_inner_assets( + let module = this.client_context.process( loader_entry_asset, - this.client_context, - Value::new(EcmascriptModuleAssetType::Typescript), - EcmascriptInputTransformsVc::cell(vec![EcmascriptInputTransform::TypeScript { - use_define_for_class_fields: false, - }]), - Default::default(), - this.client_context.compile_time_info(), + Value::new(ReferenceType::Internal( InnerAssetsVc::cell(indexmap! { "PAGE".to_string() => this.client_context.process(this.entry_asset, Value::new(ReferenceType::Entry(EntryReferenceSubType::Page))) - }), + }))), ); + let Some(module) = EvaluatableAssetVc::resolve_from(module).await? else { + bail!("internal asset is not evaluatable"); + }; + Ok(this.client_chunking_context.evaluated_chunk_group( - asset.as_root_chunk(this.client_chunking_context), - EvaluatableAssetsVc::one(asset.into()), + module.as_root_chunk(this.client_chunking_context), + EvaluatableAssetsVc::one(module), )) } diff --git a/packages/next-swc/crates/next-core/src/page_source.rs b/packages/next-swc/crates/next-core/src/page_source.rs index 3ab755caa9c16..596484e4623e6 100644 --- a/packages/next-swc/crates/next-core/src/page_source.rs +++ b/packages/next-swc/crates/next-core/src/page_source.rs @@ -1,8 +1,8 @@ -use anyhow::Result; +use anyhow::{bail, Result}; use indexmap::indexmap; use serde::{Deserialize, Serialize}; use turbo_tasks::{ - primitives::{JsonValueVc, OptionStringVc, StringVc, StringsVc}, + primitives::{JsonValueVc, StringVc, StringsVc}, trace::TraceRawVcs, Value, }; @@ -17,7 +17,7 @@ use turbopack_binding::{ chunk::{ChunkingContextVc, EvaluatableAssetVc, EvaluatableAssetsVc}, context::{AssetContext, AssetContextVc}, environment::{EnvironmentIntention, ServerAddrVc}, - reference_type::{EntryReferenceSubType, ReferenceType}, + reference_type::{EntryReferenceSubType, InnerAssetsVc, ReferenceType}, source_asset::SourceAssetVc, }, dev::DevChunkingContextVc, @@ -30,10 +30,6 @@ use turbopack_binding::{ ContentSourceData, ContentSourceVc, }, }, - ecmascript::{ - EcmascriptInputTransform, EcmascriptInputTransformsVc, EcmascriptModuleAssetType, - EcmascriptModuleAssetVc, InnerAssetsVc, - }, env::ProcessEnvAssetVc, node::{ execution_context::ExecutionContextVc, @@ -833,6 +829,13 @@ impl SsrEntryVc { } }; + let module = this.context.process( + internal_asset, + Value::new(ReferenceType::Internal(InnerAssetsVc::cell(inner_assets))), + ); + let Some(module) = EvaluatableAssetVc::resolve_from(module).await? else { + bail!("Internal module was not processed into an evaluatable asset"); + }; Ok(NodeRenderingEntry { runtime_entries: EvaluatableAssetsVc::cell( this.runtime_entries @@ -841,26 +844,7 @@ impl SsrEntryVc { .map(|entry| EvaluatableAssetVc::from_asset(*entry, this.context)) .collect(), ), - module: EcmascriptModuleAssetVc::new_with_inner_assets( - internal_asset, - this.context, - Value::new(EcmascriptModuleAssetType::Typescript), - EcmascriptInputTransformsVc::cell(vec![ - EcmascriptInputTransform::TypeScript { - use_define_for_class_fields: false, - }, - EcmascriptInputTransform::React { - // The Page source is currently only used in the development mode. - development: true, - refresh: false, - import_source: OptionStringVc::cell(None), - runtime: OptionStringVc::cell(None), - }, - ]), - Default::default(), - this.context.compile_time_info(), - InnerAssetsVc::cell(inner_assets), - ), + module, chunking_context: this.chunking_context, intermediate_output_path: this.node_path, output_root: this.node_root, diff --git a/packages/next-swc/crates/next-core/src/router.rs b/packages/next-swc/crates/next-core/src/router.rs index 7f3d9f36f2719..fd3ea74c0e9ed 100644 --- a/packages/next-swc/crates/next-core/src/router.rs +++ b/packages/next-swc/crates/next-core/src/router.rs @@ -23,16 +23,13 @@ use turbopack_binding::{ environment::{EnvironmentIntention::Middleware, ServerAddrVc, ServerInfo}, ident::AssetIdentVc, issue::IssueVc, - reference_type::{EcmaScriptModulesReferenceSubType, ReferenceType}, + reference_type::{EcmaScriptModulesReferenceSubType, InnerAssetsVc, ReferenceType}, resolve::{find_context_file, FindContextFileResult}, source_asset::SourceAssetVc, virtual_asset::VirtualAssetVc, }, dev::DevChunkingContextVc, - ecmascript::{ - EcmascriptInputTransform, EcmascriptInputTransformsVc, EcmascriptModuleAssetType, - EcmascriptModuleAssetVc, InnerAssetsVc, OptionEcmascriptModuleAssetVc, - }, + ecmascript::OptionEcmascriptModuleAssetVc, node::{ evaluate::evaluate, execution_context::{ExecutionContext, ExecutionContextVc}, @@ -232,18 +229,12 @@ async fn config_assets( #[turbo_tasks::function] fn route_executor(context: AssetContextVc, configs: InnerAssetsVc) -> AssetVc { - EcmascriptModuleAssetVc::new_with_inner_assets( - next_asset("entry/router.ts"), - context, - Value::new(EcmascriptModuleAssetType::Typescript), - EcmascriptInputTransformsVc::cell(vec![EcmascriptInputTransform::TypeScript { - use_define_for_class_fields: false, - }]), - Default::default(), - context.compile_time_info(), - configs, - ) - .into() + context + .process( + next_asset("entry/router.ts"), + Value::new(ReferenceType::Internal(configs)), + ) + .into() } #[turbo_tasks::function] From f5cfa9a8268016f2a461a140b474c39972e71cfa Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 25 May 2023 13:48:22 +0000 Subject: [PATCH 2/9] replace EcmascriptModuleAssetVc::new with ReferenceType::Internal --- .../crates/next-core/src/app_source.rs | 8 ++-- .../crates/next-core/src/asset_helpers.rs | 27 ------------- .../crates/next-core/src/bootstrap.rs | 9 ++--- packages/next-swc/crates/next-core/src/lib.rs | 1 - .../crates/next-core/src/next_config.rs | 15 ++----- .../next-core/src/next_font/google/mod.rs | 39 ++++++++++--------- .../crates/next-core/src/page_loader.rs | 7 ++-- .../next-swc/crates/next-core/src/router.rs | 30 +++++++------- 8 files changed, 47 insertions(+), 89 deletions(-) delete mode 100644 packages/next-swc/crates/next-core/src/asset_helpers.rs diff --git a/packages/next-swc/crates/next-core/src/app_source.rs b/packages/next-swc/crates/next-core/src/app_source.rs index 0ef4b3f4a9422..ce0ca5ccc18ae 100644 --- a/packages/next-swc/crates/next-core/src/app_source.rs +++ b/packages/next-swc/crates/next-core/src/app_source.rs @@ -64,7 +64,6 @@ use crate::{ get_entrypoints, get_global_metadata, Components, Entrypoint, GlobalMetadataVc, LoaderTree, LoaderTreeVc, Metadata, MetadataItem, MetadataWithAltItem, OptionAppDirVc, }, - asset_helpers::as_es_module_asset, bootstrap::{route_bootstrap, BootstrapConfigVc}, embed_js::{next_asset, next_js_file, next_js_file_path}, env::env_for_js, @@ -890,12 +889,11 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; .push(format!("import {identifier} from \"{inner_module_id}\";")); state.inner_assets.insert( inner_module_id, - as_es_module_asset( + state.context.process( TextContentSourceAssetVc::new(SourceAssetVc::new(*alt_path).into()) .into(), - state.context, - ) - .into(), + Value::new(ReferenceType::Internal(InnerAssetsVc::empty())), + ), ); writeln!(state.loader_tree_code, "{s} alt: {identifier},")?; } diff --git a/packages/next-swc/crates/next-core/src/asset_helpers.rs b/packages/next-swc/crates/next-core/src/asset_helpers.rs deleted file mode 100644 index d6d37bb3c60c5..0000000000000 --- a/packages/next-swc/crates/next-core/src/asset_helpers.rs +++ /dev/null @@ -1,27 +0,0 @@ -use turbo_tasks::Value; -use turbopack_binding::turbopack::{ - core::{ - asset::AssetVc, - context::{AssetContext, AssetContextVc}, - }, - ecmascript::{ - EcmascriptInputTransform, EcmascriptInputTransformsVc, EcmascriptModuleAssetType, - EcmascriptModuleAssetVc, - }, -}; - -pub(crate) fn as_es_module_asset( - asset: AssetVc, - context: AssetContextVc, -) -> EcmascriptModuleAssetVc { - EcmascriptModuleAssetVc::new( - asset, - context, - Value::new(EcmascriptModuleAssetType::Typescript), - EcmascriptInputTransformsVc::cell(vec![EcmascriptInputTransform::TypeScript { - use_define_for_class_fields: false, - }]), - Default::default(), - context.compile_time_info(), - ) -} diff --git a/packages/next-swc/crates/next-core/src/bootstrap.rs b/packages/next-swc/crates/next-core/src/bootstrap.rs index 3868dd8a4b5c8..2143c9c35c5be 100644 --- a/packages/next-swc/crates/next-core/src/bootstrap.rs +++ b/packages/next-swc/crates/next-core/src/bootstrap.rs @@ -15,8 +15,6 @@ use turbopack_binding::turbopack::{ ecmascript::{resolve::esm_resolve, utils::StringifyJs, EcmascriptModuleAssetVc}, }; -use crate::asset_helpers::as_es_module_asset; - #[turbo_tasks::function] pub async fn route_bootstrap( asset: AssetVc, @@ -102,7 +100,7 @@ pub async fn bootstrap( config.insert("PAGE".to_string(), path.to_string()); config.insert("PATHNAME".to_string(), pathname); - let config_asset = as_es_module_asset( + let config_asset = context.process( VirtualAssetVc::new( asset.ident().path().join("bootstrap-config.ts"), File::from( @@ -115,9 +113,8 @@ pub async fn bootstrap( .into(), ) .as_asset(), - context, - ) - .as_asset(); + Value::new(ReferenceType::Internal(InnerAssetsVc::empty())), + ); let mut inner_assets = inner_assets.await?.clone_value(); inner_assets.insert("ENTRY".to_string(), asset); diff --git a/packages/next-swc/crates/next-core/src/lib.rs b/packages/next-swc/crates/next-core/src/lib.rs index 4b6ed291f529c..41cdb7e6460c8 100644 --- a/packages/next-swc/crates/next-core/src/lib.rs +++ b/packages/next-swc/crates/next-core/src/lib.rs @@ -6,7 +6,6 @@ mod app_render; mod app_segment_config; mod app_source; pub mod app_structure; -mod asset_helpers; mod babel; mod bootstrap; mod embed_js; diff --git a/packages/next-swc/crates/next-core/src/next_config.rs b/packages/next-swc/crates/next-core/src/next_config.rs index 6e23aefb6f32c..497cd6eec872e 100644 --- a/packages/next-swc/crates/next-core/src/next_config.rs +++ b/packages/next-swc/crates/next-core/src/next_config.rs @@ -18,7 +18,7 @@ use turbopack_binding::{ context::AssetContext, ident::AssetIdentVc, issue::{Issue, IssueContextExt, IssueSeverity, IssueSeverityVc, IssueVc}, - reference_type::{EntryReferenceSubType, ReferenceType}, + reference_type::{EntryReferenceSubType, InnerAssetsVc, ReferenceType}, resolve::{ find_context_file, options::{ImportMap, ImportMapping}, @@ -26,9 +26,6 @@ use turbopack_binding::{ }, source_asset::SourceAssetVc, }, - ecmascript::{ - EcmascriptInputTransformsVc, EcmascriptModuleAssetType, EcmascriptModuleAssetVc, - }, ecmascript_plugin::transform::{ emotion::EmotionTransformConfig, relay::RelayConfig, styled_components::StyledComponentsTransformConfig, @@ -670,15 +667,11 @@ pub async fn load_next_config_internal( let config_changed = config_asset.map_or_else(CompletionVc::immutable, |config_asset| { // This invalidates the execution when anything referenced by the config file // changes - let config_asset = EcmascriptModuleAssetVc::new( + let config_asset = context.process( config_asset.into(), - context, - Value::new(EcmascriptModuleAssetType::Ecmascript), - EcmascriptInputTransformsVc::cell(vec![]), - Default::default(), - context.compile_time_info(), + Value::new(ReferenceType::Internal(InnerAssetsVc::empty())), ); - any_content_changed(config_asset.into()) + any_content_changed(config_asset) }); let load_next_config_asset = context.process( next_asset("entry/config/next.js"), diff --git a/packages/next-swc/crates/next-core/src/next_font/google/mod.rs b/packages/next-swc/crates/next-core/src/next_font/google/mod.rs index 7cd9722160fff..356339dcae2e3 100644 --- a/packages/next-swc/crates/next-core/src/next_font/google/mod.rs +++ b/packages/next-swc/crates/next-core/src/next_font/google/mod.rs @@ -406,7 +406,11 @@ async fn get_mock_stylesheet( tasks_fs::{DiskFileSystemVc, File, FileSystem}, }, turbopack::{ - core::{context::AssetContext, ident::AssetIdentVc}, + core::{ + context::AssetContext, + ident::AssetIdentVc, + reference_type::{InnerAssetsVc, ReferenceType}, + }, ecmascript::{ EcmascriptInputTransformsVc, EcmascriptModuleAssetType, EcmascriptModuleAssetVc, }, @@ -440,26 +444,23 @@ async fn get_mock_stylesheet( } = *execution_context.await?; let context = node_evaluate_asset_context(execution_context, None, None); let loader_path = mock_fs.root().join("loader.js"); - let mocked_response_asset = EcmascriptModuleAssetVc::new( - VirtualAssetVc::new( - loader_path, - File::from(format!( - "import data from './{}'; export default function load() {{ return data; }};", - response_path - .file_name() - .context("Must exist")? - .to_string_lossy(), - )) + let mocked_response_asset = context + .process( + VirtualAssetVc::new( + loader_path, + File::from(format!( + "import data from './{}'; export default function load() {{ return data; }};", + response_path + .file_name() + .context("Must exist")? + .to_string_lossy(), + )) + .into(), + ) .into(), + Value::new(ReferenceType::Internal(InnerAssetsVc::empty())), ) - .into(), - context, - Value::new(EcmascriptModuleAssetType::Ecmascript), - EcmascriptInputTransformsVc::cell(vec![]), - Default::default(), - context.compile_time_info(), - ) - .into(); + .into(); let root = mock_fs.root(); let val = evaluate( diff --git a/packages/next-swc/crates/next-core/src/page_loader.rs b/packages/next-swc/crates/next-core/src/page_loader.rs index 1654a5ce427ca..9dbba20396f07 100644 --- a/packages/next-swc/crates/next-core/src/page_loader.rs +++ b/packages/next-swc/crates/next-core/src/page_loader.rs @@ -89,9 +89,10 @@ impl PageLoaderAssetVc { let module = this.client_context.process( loader_entry_asset, Value::new(ReferenceType::Internal( - InnerAssetsVc::cell(indexmap! { - "PAGE".to_string() => this.client_context.process(this.entry_asset, Value::new(ReferenceType::Entry(EntryReferenceSubType::Page))) - }))), + InnerAssetsVc::cell(indexmap! { + "PAGE".to_string() => this.client_context.process(this.entry_asset, Value::new(ReferenceType::Entry(EntryReferenceSubType::Page))) + }) + )), ); let Some(module) = EvaluatableAssetVc::resolve_from(module).await? else { diff --git a/packages/next-swc/crates/next-core/src/router.rs b/packages/next-swc/crates/next-core/src/router.rs index fd3ea74c0e9ed..8e73b5f8d493e 100644 --- a/packages/next-swc/crates/next-core/src/router.rs +++ b/packages/next-swc/crates/next-core/src/router.rs @@ -16,7 +16,7 @@ use turbopack_binding::{ }, turbopack::{ core::{ - asset::AssetVc, + asset::{AssetOptionVc, AssetVc}, changed::any_content_changed, chunk::ChunkingContext, context::{AssetContext, AssetContextVc}, @@ -29,7 +29,6 @@ use turbopack_binding::{ virtual_asset::VirtualAssetVc, }, dev::DevChunkingContextVc, - ecmascript::OptionEcmascriptModuleAssetVc, node::{ evaluate::evaluate, execution_context::{ExecutionContext, ExecutionContextVc}, @@ -42,7 +41,6 @@ use turbopack_binding::{ }; use crate::{ - asset_helpers::as_es_module_asset, embed_js::next_asset, mode::NextMode, next_config::NextConfigVc, @@ -143,16 +141,16 @@ async fn get_config( context: AssetContextVc, project_path: FileSystemPathVc, configs: StringsVc, -) -> Result { +) -> Result { let find_config_result = find_context_file(project_path, configs); let config_asset = match &*find_config_result.await? { - FindContextFileResult::Found(config_path, _) => Some(as_es_module_asset( + FindContextFileResult::Found(config_path, _) => Some(context.process( SourceAssetVc::new(*config_path).as_asset(), - context, + Value::new(ReferenceType::Internal(InnerAssetsVc::empty())), )), FindContextFileResult::NotFound(_) => None, }; - Ok(OptionEcmascriptModuleAssetVc::cell(config_asset)) + Ok(AssetOptionVc::cell(config_asset)) } #[turbo_tasks::function] @@ -184,30 +182,29 @@ async fn config_assets( let (manifest, config) = match &*middleware_config { Some(c) => { let manifest = context.with_transition("next-edge").process( - c.as_asset(), + *c, Value::new(ReferenceType::EcmaScriptModules( EcmaScriptModulesReferenceSubType::Undefined, )), ); - let config = parse_config_from_source(c.as_asset()); + let config = parse_config_from_source(*c); (manifest, config) } None => { - let manifest = as_es_module_asset( + let manifest = context.process( VirtualAssetVc::new( project_path.join("middleware.js"), File::from("export default [];").into(), ) .as_asset(), - context, - ) - .as_asset(); + Value::new(ReferenceType::Internal(InnerAssetsVc::empty())), + ); let config = NextSourceConfigVc::default(); (manifest, config) } }; - let config_asset = as_es_module_asset( + let config_asset = context.process( VirtualAssetVc::new( project_path.join("middleware_config.js"), File::from(format!( @@ -217,9 +214,8 @@ async fn config_assets( .into(), ) .as_asset(), - context, - ) - .as_asset(); + Value::new(ReferenceType::Internal(InnerAssetsVc::empty())), + ); Ok(InnerAssetsVc::cell(indexmap! { "MIDDLEWARE_CHUNK_GROUP".to_string() => manifest, From 847d7a22f2b89c08c748a0d126fc042f276addeb Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 26 May 2023 15:04:01 +0200 Subject: [PATCH 3/9] Apply suggestions from code review Co-authored-by: Alex Kirszenberg --- packages/next-swc/crates/next-core/src/app_source.rs | 4 ++-- packages/next-swc/crates/next-core/src/bootstrap.rs | 2 +- .../next-swc/crates/next-core/src/next_client/transition.rs | 2 +- packages/next-swc/crates/next-core/src/page_loader.rs | 2 +- packages/next-swc/crates/next-core/src/page_source.rs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/next-swc/crates/next-core/src/app_source.rs b/packages/next-swc/crates/next-core/src/app_source.rs index ce0ca5ccc18ae..a0318d7b61516 100644 --- a/packages/next-swc/crates/next-core/src/app_source.rs +++ b/packages/next-swc/crates/next-core/src/app_source.rs @@ -1025,7 +1025,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; ); let Some(module) = EvaluatableAssetVc::resolve_from(module).await? else { - bail!("Internal module is not evaluatable"); + bail!("internal module must be evaluatable"); }; Ok(NodeRenderingEntry { @@ -1132,7 +1132,7 @@ impl AppRouteVc { ); let Some(module) = EvaluatableAssetVc::resolve_from(module).await? else { - bail!("Internal module must be evaluatable"); + bail!("internal module must be evaluatable"); }; module diff --git a/packages/next-swc/crates/next-core/src/bootstrap.rs b/packages/next-swc/crates/next-core/src/bootstrap.rs index 2143c9c35c5be..80573b76e9e5b 100644 --- a/packages/next-swc/crates/next-core/src/bootstrap.rs +++ b/packages/next-swc/crates/next-core/src/bootstrap.rs @@ -126,7 +126,7 @@ pub async fn bootstrap( ); let Some(asset) = EvaluatableAssetVc::resolve_from(asset).await? else { - bail!("internal asset is not evaluatable"); + bail!("internal module must be evaluatable"); }; Ok(asset) diff --git a/packages/next-swc/crates/next-core/src/next_client/transition.rs b/packages/next-swc/crates/next-core/src/next_client/transition.rs index 5418da8778f51..2211b566f7847 100644 --- a/packages/next-swc/crates/next-core/src/next_client/transition.rs +++ b/packages/next-swc/crates/next-core/src/next_client/transition.rs @@ -82,7 +82,7 @@ impl Transition for NextClientTransition { asset }; let Some(asset) = EcmascriptChunkPlaceableVc::resolve_from(asset).await? else { - bail!("Not an ecmascript placeable module"); + bail!("not an ecmascript placeable module"); }; let runtime_entries = self.runtime_entries.resolve_entries(context.into()); diff --git a/packages/next-swc/crates/next-core/src/page_loader.rs b/packages/next-swc/crates/next-core/src/page_loader.rs index 9dbba20396f07..585d5093f5989 100644 --- a/packages/next-swc/crates/next-core/src/page_loader.rs +++ b/packages/next-swc/crates/next-core/src/page_loader.rs @@ -96,7 +96,7 @@ impl PageLoaderAssetVc { ); let Some(module) = EvaluatableAssetVc::resolve_from(module).await? else { - bail!("internal asset is not evaluatable"); + bail!("internal module must be evaluatable"); }; Ok(this.client_chunking_context.evaluated_chunk_group( diff --git a/packages/next-swc/crates/next-core/src/page_source.rs b/packages/next-swc/crates/next-core/src/page_source.rs index 596484e4623e6..e83dec33b7e3f 100644 --- a/packages/next-swc/crates/next-core/src/page_source.rs +++ b/packages/next-swc/crates/next-core/src/page_source.rs @@ -834,7 +834,7 @@ impl SsrEntryVc { Value::new(ReferenceType::Internal(InnerAssetsVc::cell(inner_assets))), ); let Some(module) = EvaluatableAssetVc::resolve_from(module).await? else { - bail!("Internal module was not processed into an evaluatable asset"); + bail!("internal module must be evaluatable"); }; Ok(NodeRenderingEntry { runtime_entries: EvaluatableAssetsVc::cell( From d33f2dfd0bdb82f8f220663cbc5b8d2328631531 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 26 May 2023 14:11:10 +0000 Subject: [PATCH 4/9] clippy --- packages/next-swc/crates/next-core/src/app_source.rs | 4 +--- packages/next-swc/crates/next-core/src/router.rs | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/next-swc/crates/next-core/src/app_source.rs b/packages/next-swc/crates/next-core/src/app_source.rs index a0318d7b61516..e34da0cbb58cc 100644 --- a/packages/next-swc/crates/next-core/src/app_source.rs +++ b/packages/next-swc/crates/next-core/src/app_source.rs @@ -866,8 +866,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; SourceAssetVc::new(*path).into(), BlurPlaceholderMode::None, state.context, - ) - .into(), + ), ); writeln!(state.loader_tree_code, "{s}(async (props) => [{{")?; writeln!(state.loader_tree_code, "{s} url: {identifier}.src,")?; @@ -1114,7 +1113,6 @@ impl AppRouteVc { bootstrap_asset, BootstrapConfigVc::empty(), ) - .into() } NextRuntime::Edge => { let internal_asset = next_asset("entry/app/edge-route.ts"); diff --git a/packages/next-swc/crates/next-core/src/router.rs b/packages/next-swc/crates/next-core/src/router.rs index 8e73b5f8d493e..adf2838d21ec2 100644 --- a/packages/next-swc/crates/next-core/src/router.rs +++ b/packages/next-swc/crates/next-core/src/router.rs @@ -160,7 +160,7 @@ async fn next_config_changed( ) -> Result { let next_config = get_config(context, project_path, next_configs()).await?; Ok(if let Some(c) = *next_config { - any_content_changed(c.into()) + any_content_changed(c) } else { CompletionVc::immutable() }) @@ -230,7 +230,6 @@ fn route_executor(context: AssetContextVc, configs: InnerAssetsVc) -> AssetVc { next_asset("entry/router.ts"), Value::new(ReferenceType::Internal(configs)), ) - .into() } #[turbo_tasks::function] From 29bf0b2c97b2ad0d91766881060ca9b8409c221c Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 26 May 2023 14:48:41 +0000 Subject: [PATCH 5/9] update turbopack --- Cargo.lock | 68 +++++++++---------- Cargo.toml | 6 +- .../next-swc/crates/next-core/js/package.json | 4 +- pnpm-lock.yaml | 18 ++--- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c1ddfbb447c8..c6265d7bf4c52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -394,7 +394,7 @@ dependencies = [ [[package]] name = "auto-hash-map" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "serde", ] @@ -3426,7 +3426,7 @@ dependencies = [ [[package]] name = "node-file-trace" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "serde", @@ -7036,7 +7036,7 @@ dependencies = [ [[package]] name = "turbo-tasks" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "auto-hash-map", @@ -7067,7 +7067,7 @@ dependencies = [ [[package]] name = "turbo-tasks-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "cargo-lock", @@ -7079,7 +7079,7 @@ dependencies = [ [[package]] name = "turbo-tasks-bytes" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "bytes", @@ -7094,7 +7094,7 @@ dependencies = [ [[package]] name = "turbo-tasks-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "dotenvy", @@ -7108,7 +7108,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fetch" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "indexmap", @@ -7125,7 +7125,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fs" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "auto-hash-map", @@ -7155,7 +7155,7 @@ dependencies = [ [[package]] name = "turbo-tasks-hash" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "base16", "hex", @@ -7167,7 +7167,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -7181,7 +7181,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros-shared" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "proc-macro2", "quote", @@ -7191,7 +7191,7 @@ dependencies = [ [[package]] name = "turbo-tasks-malloc" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "mimalloc", ] @@ -7199,7 +7199,7 @@ dependencies = [ [[package]] name = "turbo-tasks-memory" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "auto-hash-map", @@ -7222,7 +7222,7 @@ dependencies = [ [[package]] name = "turbo-tasks-testing" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "auto-hash-map", @@ -7234,7 +7234,7 @@ dependencies = [ [[package]] name = "turbopack" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "async-recursion", @@ -7264,7 +7264,7 @@ dependencies = [ [[package]] name = "turbopack-bench" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "chromiumoxide", @@ -7294,7 +7294,7 @@ dependencies = [ [[package]] name = "turbopack-binding" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "auto-hash-map", "mdxjs", @@ -7335,7 +7335,7 @@ dependencies = [ [[package]] name = "turbopack-cli-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "clap 4.1.11", @@ -7359,7 +7359,7 @@ dependencies = [ [[package]] name = "turbopack-core" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "async-trait", @@ -7387,7 +7387,7 @@ dependencies = [ [[package]] name = "turbopack-create-test-app" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "clap 4.1.11", @@ -7400,7 +7400,7 @@ dependencies = [ [[package]] name = "turbopack-css" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "async-trait", @@ -7422,7 +7422,7 @@ dependencies = [ [[package]] name = "turbopack-dev" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "indexmap", @@ -7446,7 +7446,7 @@ dependencies = [ [[package]] name = "turbopack-dev-server" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "async-compression", @@ -7481,7 +7481,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "async-trait", @@ -7514,7 +7514,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-plugins" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "async-trait", @@ -7535,7 +7535,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-runtime" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "indoc", @@ -7552,7 +7552,7 @@ dependencies = [ [[package]] name = "turbopack-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "indexmap", @@ -7568,7 +7568,7 @@ dependencies = [ [[package]] name = "turbopack-image" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "base64 0.21.0", @@ -7588,7 +7588,7 @@ dependencies = [ [[package]] name = "turbopack-json" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "serde", @@ -7603,7 +7603,7 @@ dependencies = [ [[package]] name = "turbopack-mdx" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "mdxjs", @@ -7618,7 +7618,7 @@ dependencies = [ [[package]] name = "turbopack-node" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "async-stream", @@ -7653,7 +7653,7 @@ dependencies = [ [[package]] name = "turbopack-static" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "serde", @@ -7669,7 +7669,7 @@ dependencies = [ [[package]] name = "turbopack-swc-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "swc_core", "turbo-tasks", @@ -7680,7 +7680,7 @@ dependencies = [ [[package]] name = "turbopack-test-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.2#a066e12989dcc8f7dd4ba1d3c4bd111be1d33a6a" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230526.5#e1f7c46fff2ee6deaa191e00ace412781c328023" dependencies = [ "anyhow", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index ea5a136824ac4..30600a4ae1fd3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,11 +42,11 @@ swc_core = { version = "0.76.18" } testing = { version = "0.33.11" } # Turbo crates -turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230526.2" } +turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230526.5" } # [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros.. -turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230526.2" } +turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230526.5" } # [TODO]: need to refactor embed_directory! macro usage in next-core -turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230526.2" } +turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230526.5" } # General Deps diff --git a/packages/next-swc/crates/next-core/js/package.json b/packages/next-swc/crates/next-core/js/package.json index 4c6eb7945a402..3ceb2486bf929 100644 --- a/packages/next-swc/crates/next-core/js/package.json +++ b/packages/next-swc/crates/next-core/js/package.json @@ -10,8 +10,8 @@ "check": "tsc --noEmit" }, "dependencies": { - "@vercel/turbopack-ecmascript-runtime": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230526.2", - "@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230526.2", + "@vercel/turbopack-ecmascript-runtime": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230526.5", + "@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230526.5", "anser": "^2.1.1", "css.escape": "^1.5.1", "next": "*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec4dd68d0730e..9e9cee42bb71a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1012,8 +1012,8 @@ importers: '@types/react': 18.2.5 '@types/react-dom': 18.2.3 '@vercel/ncc': ^0.36.0 - '@vercel/turbopack-ecmascript-runtime': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230526.2 - '@vercel/turbopack-node': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230526.2 + '@vercel/turbopack-ecmascript-runtime': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230526.5 + '@vercel/turbopack-node': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230526.5 anser: ^2.1.1 css.escape: ^1.5.1 find-up: ^6.3.0 @@ -1025,8 +1025,8 @@ importers: stacktrace-parser: ^0.1.10 strip-ansi: ^7.0.1 dependencies: - '@vercel/turbopack-ecmascript-runtime': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230526.2_react-refresh@0.12.0' - '@vercel/turbopack-node': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230526.2' + '@vercel/turbopack-ecmascript-runtime': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230526.5_react-refresh@0.12.0' + '@vercel/turbopack-node': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230526.5' anser: 2.1.1 css.escape: 1.5.1 next: link:../../../../next @@ -25477,9 +25477,9 @@ packages: /zwitch/2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} - '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230526.2_react-refresh@0.12.0': - resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230526.2} - id: '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230526.2' + '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230526.5_react-refresh@0.12.0': + resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230526.5} + id: '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230526.5' name: '@vercel/turbopack-ecmascript-runtime' version: 0.0.0 dependencies: @@ -25490,8 +25490,8 @@ packages: - webpack dev: false - '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230526.2': - resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230526.2} + '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230526.5': + resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230526.5} name: '@vercel/turbopack-node' version: 0.0.0 dependencies: From 6a7ac06ddb77bbd7dc72b8d25efa417bc5259746 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 26 May 2023 14:55:44 +0000 Subject: [PATCH 6/9] fmt --- packages/next-swc/crates/next-core/src/router.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/next-swc/crates/next-core/src/router.rs b/packages/next-swc/crates/next-core/src/router.rs index adf2838d21ec2..23a0243868575 100644 --- a/packages/next-swc/crates/next-core/src/router.rs +++ b/packages/next-swc/crates/next-core/src/router.rs @@ -225,11 +225,10 @@ async fn config_assets( #[turbo_tasks::function] fn route_executor(context: AssetContextVc, configs: InnerAssetsVc) -> AssetVc { - context - .process( - next_asset("entry/router.ts"), - Value::new(ReferenceType::Internal(configs)), - ) + context.process( + next_asset("entry/router.ts"), + Value::new(ReferenceType::Internal(configs)), + ) } #[turbo_tasks::function] From 1e8f9cc3ea625a12bb202b8af32d821f1c2043f8 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 26 May 2023 21:34:19 +0000 Subject: [PATCH 7/9] fix test case --- test/development/jsconfig-path-reloading/index.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/development/jsconfig-path-reloading/index.test.ts b/test/development/jsconfig-path-reloading/index.test.ts index a24b0a435a589..e00192b659111 100644 --- a/test/development/jsconfig-path-reloading/index.test.ts +++ b/test/development/jsconfig-path-reloading/index.test.ts @@ -114,7 +114,8 @@ describe('jsconfig-path-reloading', () => { await next.patchFile(tsConfigFile, tsconfigContent) await check(async () => { const html3 = await browser.eval('document.documentElement.innerHTML') - return html3.includes('first-data') && !html3.includes('second-data') + return html3.includes('id="first-data"') && + !html3.includes('id="second-data"') ? 'success' : html3 }, 'success') From af36214fe1d46caa5ad8253ad461fb6a82b1910a Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 26 May 2023 22:02:52 +0000 Subject: [PATCH 8/9] fix test case --- test/development/tsconfig-path-reloading/index.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/development/tsconfig-path-reloading/index.test.ts b/test/development/tsconfig-path-reloading/index.test.ts index ef679796d489d..6b6579171917e 100644 --- a/test/development/tsconfig-path-reloading/index.test.ts +++ b/test/development/tsconfig-path-reloading/index.test.ts @@ -114,7 +114,8 @@ describe('tsconfig-path-reloading', () => { await next.patchFile(tsConfigFile, tsconfigContent) await check(async () => { const html3 = await browser.eval('document.documentElement.innerHTML') - return html3.includes('first-data') && !html3.includes('second-data') + return html3.includes('id="first-data"') && + !html3.includes('id="second-data"') ? 'success' : html3 }, 'success') From aab29dd695d918dc46f0d9ff22e28265a1762c16 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 26 May 2023 22:36:11 +0000 Subject: [PATCH 9/9] improve test case --- test/development/jsconfig-path-reloading/index.test.ts | 4 ++-- test/development/tsconfig-path-reloading/index.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/development/jsconfig-path-reloading/index.test.ts b/test/development/jsconfig-path-reloading/index.test.ts index e00192b659111..699db37a9706b 100644 --- a/test/development/jsconfig-path-reloading/index.test.ts +++ b/test/development/jsconfig-path-reloading/index.test.ts @@ -70,8 +70,8 @@ describe('jsconfig-path-reloading', () => { const html = await browser.eval('document.documentElement.innerHTML') expect(html).toContain('first button') expect(html).toContain('second button') - expect(html).toContain('first-data') - expect(html).not.toContain('second-data') + expect(html).toContain('id="first-data"') + expect(html).not.toContain('id="second-data"') await next.patchFile( indexPage, diff --git a/test/development/tsconfig-path-reloading/index.test.ts b/test/development/tsconfig-path-reloading/index.test.ts index 6b6579171917e..551adc459d4a1 100644 --- a/test/development/tsconfig-path-reloading/index.test.ts +++ b/test/development/tsconfig-path-reloading/index.test.ts @@ -70,8 +70,8 @@ describe('tsconfig-path-reloading', () => { const html = await browser.eval('document.documentElement.innerHTML') expect(html).toContain('first button') expect(html).toContain('second button') - expect(html).toContain('first-data') - expect(html).not.toContain('second-data') + expect(html).toContain('id="first-data"') + expect(html).not.toContain('id="second-data"') await next.patchFile( indexPage,