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/packages/next-swc/crates/next-core/src/app_source.rs b/packages/next-swc/crates/next-core/src/app_source.rs index fd54ba0d9be6c..e34da0cbb58cc 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, }, @@ -69,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, @@ -872,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,")?; @@ -895,12 +888,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},")?; } @@ -1026,6 +1018,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 must be evaluatable"); + }; + Ok(NodeRenderingEntry { runtime_entries: EvaluatableAssetsVc::cell( runtime_entries @@ -1034,26 +1035,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(), @@ -1140,19 +1122,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/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 5a60c8af0391d..9dc833f153d6d 100644 --- a/packages/next-swc/crates/next-core/src/bootstrap.rs +++ b/packages/next-swc/crates/next-core/src/bootstrap.rs @@ -5,21 +5,16 @@ 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; - #[turbo_tasks::function] pub async fn route_bootstrap( asset: AssetVc, @@ -27,7 +22,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 +78,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? @@ -106,7 +101,7 @@ pub async fn bootstrap( config.insert("PATHNAME".to_string(), pathname); config.insert("KIND".to_string(), "APP_ROUTE".to_string()); - let config_asset = as_es_module_asset( + let config_asset = context.process( VirtualAssetVc::new( asset.ident().path().join("bootstrap-config.ts"), File::from( @@ -119,26 +114,22 @@ 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); 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 module must be evaluatable"); + }; + Ok(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_client/transition.rs b/packages/next-swc/crates/next-core/src/next_client/transition.rs index 767ebbbaadfe3..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 @@ -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_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/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..585d5093f5989 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,22 @@ 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(), - InnerAssetsVc::cell(indexmap! { - "PAGE".to_string() => this.client_context.process(this.entry_asset, Value::new(ReferenceType::Entry(EntryReferenceSubType::Page))) - }), + 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 module must be 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..e83dec33b7e3f 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 must be evaluatable"); + }; 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..23a0243868575 100644 --- a/packages/next-swc/crates/next-core/src/router.rs +++ b/packages/next-swc/crates/next-core/src/router.rs @@ -16,23 +16,19 @@ use turbopack_binding::{ }, turbopack::{ core::{ - asset::AssetVc, + asset::{AssetOptionVc, AssetVc}, changed::any_content_changed, chunk::ChunkingContext, context::{AssetContext, AssetContextVc}, 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, - }, node::{ evaluate::evaluate, execution_context::{ExecutionContext, ExecutionContextVc}, @@ -45,7 +41,6 @@ use turbopack_binding::{ }; use crate::{ - asset_helpers::as_es_module_asset, embed_js::next_asset, mode::NextMode, next_config::NextConfigVc, @@ -146,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] @@ -165,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() }) @@ -187,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!( @@ -220,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, @@ -232,18 +225,10 @@ async fn config_assets( #[turbo_tasks::function] fn route_executor(context: AssetContextVc, configs: InnerAssetsVc) -> AssetVc { - EcmascriptModuleAssetVc::new_with_inner_assets( + context.process( 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, + Value::new(ReferenceType::Internal(configs)), ) - .into() } #[turbo_tasks::function] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f838224561c2f..3847b0c54bbdd 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 @@ -25490,9 +25490,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: @@ -25503,8 +25503,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: diff --git a/test/development/jsconfig-path-reloading/index.test.ts b/test/development/jsconfig-path-reloading/index.test.ts index a24b0a435a589..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, @@ -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') diff --git a/test/development/tsconfig-path-reloading/index.test.ts b/test/development/tsconfig-path-reloading/index.test.ts index ef679796d489d..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, @@ -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')