Unverified Commit 8643014b authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

turbopack: Module Trait (#52401)

### What?

refactoring see https://github.com/vercel/turbo/pull/5477

---------
Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent 73e2979c
This diff is collapsed.
...@@ -42,11 +42,11 @@ swc_core = { version = "0.79.13" } ...@@ -42,11 +42,11 @@ swc_core = { version = "0.79.13" }
testing = { version = "0.33.20" } testing = { version = "0.33.20" }
# Turbo crates # Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230707.3" } turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230710.2" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros.. # [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-230707.3" } turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230710.2" }
# [TODO]: need to refactor embed_directory! macro usage in next-core # [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230707.3" } turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230710.2" }
# General Deps # General Deps
......
...@@ -11,7 +11,7 @@ use turbopack_binding::{ ...@@ -11,7 +11,7 @@ use turbopack_binding::{
turbopack::{ turbopack::{
core::{ core::{
asset::AssetVc, asset::AssetVc,
chunk::{ChunkableAsset, ChunkingContext, ChunkingContextVc}, chunk::{ChunkableModule, ChunkingContext, ChunkingContextVc},
context::{AssetContext, AssetContextVc}, context::{AssetContext, AssetContextVc},
reference_type::ReferenceType, reference_type::ReferenceType,
}, },
...@@ -70,8 +70,11 @@ impl PagesBuildClientContextVc { ...@@ -70,8 +70,11 @@ impl PagesBuildClientContextVc {
let this = self.await?; let this = self.await?;
let client_asset_page = this.client_asset_context.process(asset, reference_type); let client_asset_page = this.client_asset_context.process(asset, reference_type);
let client_asset_page = let client_asset_page = create_page_loader_entry_asset(
create_page_loader_entry_asset(this.client_asset_context, client_asset_page, pathname); this.client_asset_context,
client_asset_page.into(),
pathname,
);
let Some(client_module_asset) = let Some(client_module_asset) =
EcmascriptModuleAssetVc::resolve_from(client_asset_page).await? EcmascriptModuleAssetVc::resolve_from(client_asset_page).await?
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
"check": "tsc --noEmit" "check": "tsc --noEmit"
}, },
"dependencies": { "dependencies": {
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230707.3", "@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230710.2",
"@vercel/turbopack-node": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230707.3", "@vercel/turbopack-node": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230710.2",
"anser": "^2.1.1", "anser": "^2.1.1",
"css.escape": "^1.5.1", "css.escape": "^1.5.1",
"next": "*", "next": "*",
......
...@@ -2,7 +2,7 @@ use anyhow::{bail, Result}; ...@@ -2,7 +2,7 @@ use anyhow::{bail, Result};
use turbopack_binding::{ use turbopack_binding::{
turbo::tasks_fs::FileSystemPathVc, turbo::tasks_fs::FileSystemPathVc,
turbopack::{ turbopack::{
core::{asset::AssetVc, compile_time_info::CompileTimeInfoVc}, core::{compile_time_info::CompileTimeInfoVc, module::ModuleVc},
ecmascript::chunk::EcmascriptChunkPlaceableVc, ecmascript::chunk::EcmascriptChunkPlaceableVc,
turbopack::{ turbopack::{
module_options::ModuleOptionsContextVc, module_options::ModuleOptionsContextVc,
...@@ -55,10 +55,10 @@ impl Transition for NextServerComponentTransition { ...@@ -55,10 +55,10 @@ impl Transition for NextServerComponentTransition {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn process_module( async fn process_module(
&self, &self,
asset: AssetVc, module: ModuleVc,
_context: ModuleAssetContextVc, _context: ModuleAssetContextVc,
) -> Result<AssetVc> { ) -> Result<ModuleVc> {
let Some(asset) = EcmascriptChunkPlaceableVc::resolve_from(asset).await? else { let Some(asset) = EcmascriptChunkPlaceableVc::resolve_from(module).await? else {
bail!("Not an ecmascript module"); bail!("Not an ecmascript module");
}; };
......
...@@ -17,6 +17,7 @@ use turbopack_binding::turbopack::{ ...@@ -17,6 +17,7 @@ use turbopack_binding::turbopack::{
issue::{ issue::{
Issue, IssueSeverity, IssueSeverityVc, IssueSourceVc, IssueVc, OptionIssueSourceVc, Issue, IssueSeverity, IssueSeverityVc, IssueSourceVc, IssueVc, OptionIssueSourceVc,
}, },
module::ModuleVc,
reference_type::{EcmaScriptModulesReferenceSubType, ReferenceType}, reference_type::{EcmaScriptModulesReferenceSubType, ReferenceType},
source_asset::SourceAssetVc, source_asset::SourceAssetVc,
}, },
...@@ -211,7 +212,7 @@ impl Issue for NextSegmentConfigParsingIssue { ...@@ -211,7 +212,7 @@ impl Issue for NextSegmentConfigParsingIssue {
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn parse_segment_config_from_source( pub async fn parse_segment_config_from_source(
module_asset: AssetVc, module_asset: ModuleVc,
) -> Result<NextSegmentConfigVc> { ) -> Result<NextSegmentConfigVc> {
let Some(ecmascript_asset) = EcmascriptModuleAssetVc::resolve_from(module_asset).await? else { let Some(ecmascript_asset) = EcmascriptModuleAssetVc::resolve_from(module_asset).await? else {
return Ok(NextSegmentConfigVc::default()); return Ok(NextSegmentConfigVc::default());
...@@ -256,7 +257,7 @@ fn issue_source(source: AssetVc, span: Span) -> IssueSourceVc { ...@@ -256,7 +257,7 @@ fn issue_source(source: AssetVc, span: Span) -> IssueSourceVc {
} }
fn parse_config_value( fn parse_config_value(
module_asset: AssetVc, module: ModuleVc,
config: &mut NextSegmentConfig, config: &mut NextSegmentConfig,
ident: &Ident, ident: &Ident,
init: &Expr, init: &Expr,
...@@ -266,9 +267,9 @@ fn parse_config_value( ...@@ -266,9 +267,9 @@ fn parse_config_value(
let invalid_config = |detail: &str, value: &JsValue| { let invalid_config = |detail: &str, value: &JsValue| {
let (explainer, hints) = value.explain(2, 0); let (explainer, hints) = value.explain(2, 0);
NextSegmentConfigParsingIssue { NextSegmentConfigParsingIssue {
ident: module_asset.ident(), ident: module.ident(),
detail: StringVc::cell(format!("{detail} Got {explainer}.{hints}")), detail: StringVc::cell(format!("{detail} Got {explainer}.{hints}")),
source: issue_source(module_asset, span), source: issue_source(module.into(), span),
} }
.cell() .cell()
.as_issue() .as_issue()
......
...@@ -872,12 +872,16 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; ...@@ -872,12 +872,16 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}";
state.inner_assets.insert( state.inner_assets.insert(
format!("COMPONENT_{i}"), format!("COMPONENT_{i}"),
state.context.with_transition(state.rsc_transition).process( state
SourceAssetVc::new(component).into(), .context
Value::new(ReferenceType::EcmaScriptModules( .with_transition(state.rsc_transition)
EcmaScriptModulesReferenceSubType::Undefined, .process(
)), SourceAssetVc::new(component).into(),
), Value::new(ReferenceType::EcmaScriptModules(
EcmaScriptModulesReferenceSubType::Undefined,
)),
)
.into(),
); );
} }
Ok(()) Ok(())
...@@ -978,7 +982,8 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; ...@@ -978,7 +982,8 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}";
SourceAssetVc::new(*path).into(), SourceAssetVc::new(*path).into(),
BlurPlaceholderMode::None, BlurPlaceholderMode::None,
state.context, state.context,
), )
.into(),
); );
writeln!(state.loader_tree_code, "{s}(async (props) => [{{")?; writeln!(state.loader_tree_code, "{s}(async (props) => [{{")?;
writeln!(state.loader_tree_code, "{s} url: {identifier}.src,")?; writeln!(state.loader_tree_code, "{s} url: {identifier}.src,")?;
...@@ -1000,11 +1005,16 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; ...@@ -1000,11 +1005,16 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}";
.push(format!("import {identifier} from \"{inner_module_id}\";")); .push(format!("import {identifier} from \"{inner_module_id}\";"));
state.inner_assets.insert( state.inner_assets.insert(
inner_module_id, inner_module_id,
state.context.process( state
TextContentSourceAssetVc::new(SourceAssetVc::new(*alt_path).into()) .context
.process(
TextContentSourceAssetVc::new(
SourceAssetVc::new(*alt_path).into(),
)
.into(), .into(),
Value::new(ReferenceType::Internal(InnerAssetsVc::empty())), Value::new(ReferenceType::Internal(InnerAssetsVc::empty())),
), )
.into(),
); );
writeln!(state.loader_tree_code, "{s} alt: {identifier},")?; writeln!(state.loader_tree_code, "{s} alt: {identifier},")?;
} }
...@@ -1125,13 +1135,13 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; ...@@ -1125,13 +1135,13 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}";
"APP_ENTRY".to_string() => context.with_transition(rsc_transition).process( "APP_ENTRY".to_string() => context.with_transition(rsc_transition).process(
asset.into(), asset.into(),
Value::new(ReferenceType::Internal(InnerAssetsVc::cell(inner_assets))), Value::new(ReferenceType::Internal(InnerAssetsVc::cell(inner_assets))),
), ).into(),
"APP_BOOTSTRAP".to_string() => context.with_transition("next-client").process( "APP_BOOTSTRAP".to_string() => context.with_transition("next-client").process(
SourceAssetVc::new(next_js_file_path("entry/app/hydrate.tsx")).into(), SourceAssetVc::new(next_js_file_path("entry/app/hydrate.tsx")).into(),
Value::new(ReferenceType::EcmaScriptModules( Value::new(ReferenceType::EcmaScriptModules(
EcmaScriptModulesReferenceSubType::Undefined, EcmaScriptModulesReferenceSubType::Undefined,
)), )),
), ).into(),
}))), }))),
), ),
Some(NextRuntime::Edge) => Some(NextRuntime::Edge) =>
...@@ -1141,7 +1151,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; ...@@ -1141,7 +1151,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}";
"INNER_EDGE_CHUNK_GROUP".to_string() => context.with_transition("next-edge-page").process( "INNER_EDGE_CHUNK_GROUP".to_string() => context.with_transition("next-edge-page").process(
asset.into(), asset.into(),
Value::new(ReferenceType::Internal(InnerAssetsVc::cell(inner_assets))), Value::new(ReferenceType::Internal(InnerAssetsVc::cell(inner_assets))),
), ).into(),
}))), }))),
) )
}; };
...@@ -1225,7 +1235,7 @@ impl AppRouteVc { ...@@ -1225,7 +1235,7 @@ impl AppRouteVc {
let bootstrap_asset = next_asset("entry/app/route.ts"); let bootstrap_asset = next_asset("entry/app/route.ts");
route_bootstrap( route_bootstrap(
entry_asset, entry_asset.into(),
this.context.into(), this.context.into(),
this.project_path, this.project_path,
bootstrap_asset, bootstrap_asset,
...@@ -1243,7 +1253,7 @@ impl AppRouteVc { ...@@ -1243,7 +1253,7 @@ impl AppRouteVc {
let module = this.context.process( let module = this.context.process(
internal_asset, internal_asset,
Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap! { Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap! {
"ROUTE_CHUNK_GROUP".to_string() => entry "ROUTE_CHUNK_GROUP".to_string() => entry.into()
}))), }))),
); );
......
...@@ -122,7 +122,7 @@ pub async fn bootstrap( ...@@ -122,7 +122,7 @@ pub async fn bootstrap(
let mut inner_assets = inner_assets.await?.clone_value(); let mut inner_assets = inner_assets.await?.clone_value();
inner_assets.insert("ENTRY".to_string(), asset); inner_assets.insert("ENTRY".to_string(), asset);
inner_assets.insert("BOOTSTRAP_CONFIG".to_string(), config_asset); inner_assets.insert("BOOTSTRAP_CONFIG".to_string(), config_asset.into());
let asset = context.process( let asset = context.process(
bootstrap_asset, bootstrap_asset,
......
...@@ -3,10 +3,10 @@ use indexmap::indexmap; ...@@ -3,10 +3,10 @@ use indexmap::indexmap;
use turbo_tasks::Value; use turbo_tasks::Value;
use turbopack_binding::turbopack::{ use turbopack_binding::turbopack::{
core::{ core::{
asset::AssetVc,
chunk::{ChunkingContext, ChunkingContextVc}, chunk::{ChunkingContext, ChunkingContextVc},
compile_time_info::CompileTimeInfoVc, compile_time_info::CompileTimeInfoVc,
context::AssetContext, context::AssetContext,
module::ModuleVc,
reference_type::{InnerAssetsVc, ReferenceType}, reference_type::{InnerAssetsVc, ReferenceType},
}, },
ecmascript::chunk::EcmascriptChunkPlaceableVc, ecmascript::chunk::EcmascriptChunkPlaceableVc,
...@@ -66,16 +66,16 @@ impl Transition for NextClientTransition { ...@@ -66,16 +66,16 @@ impl Transition for NextClientTransition {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn process_module( async fn process_module(
&self, &self,
asset: AssetVc, asset: ModuleVc,
context: ModuleAssetContextVc, context: ModuleAssetContextVc,
) -> Result<AssetVc> { ) -> Result<ModuleVc> {
let asset = if !self.is_app { let asset = if !self.is_app {
let internal_asset = next_asset("entry/next-hydrate.tsx"); let internal_asset = next_asset("entry/next-hydrate.tsx");
context.process( context.process(
internal_asset, internal_asset,
Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap! { Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap! {
"PAGE".to_string() => asset "PAGE".to_string() => asset.into()
}))), }))),
) )
} else { } else {
...@@ -88,7 +88,7 @@ impl Transition for NextClientTransition { ...@@ -88,7 +88,7 @@ impl Transition for NextClientTransition {
let runtime_entries = self.runtime_entries.resolve_entries(context.into()); let runtime_entries = self.runtime_entries.resolve_entries(context.into());
let asset = ChunkGroupFilesAsset { let asset = ChunkGroupFilesAsset {
asset: asset.into(), module: asset.into(),
// This ensures that the chunk group files asset will strip out the _next prefix from // This ensures that the chunk group files asset will strip out the _next prefix from
// all chunk paths, which is what the Next.js renderer code expects. // all chunk paths, which is what the Next.js renderer code expects.
client_root: self.client_chunking_context.output_root().join("_next"), client_root: self.client_chunking_context.output_root().join("_next"),
......
...@@ -3,7 +3,7 @@ use turbo_tasks::Value; ...@@ -3,7 +3,7 @@ use turbo_tasks::Value;
use turbopack_binding::{ use turbopack_binding::{
turbo::tasks_fs::FileSystemPathVc, turbo::tasks_fs::FileSystemPathVc,
turbopack::{ turbopack::{
core::{asset::AssetVc, chunk::ChunkingContextVc, compile_time_info::CompileTimeInfoVc}, core::{chunk::ChunkingContextVc, compile_time_info::CompileTimeInfoVc, module::ModuleVc},
node::execution_context::ExecutionContextVc, node::execution_context::ExecutionContextVc,
turbopack::{ turbopack::{
ecmascript::chunk::EcmascriptChunkPlaceableVc, ecmascript::chunk::EcmascriptChunkPlaceableVc,
...@@ -106,9 +106,9 @@ impl Transition for NextClientChunksTransition { ...@@ -106,9 +106,9 @@ impl Transition for NextClientChunksTransition {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn process_module( async fn process_module(
&self, &self,
asset: AssetVc, asset: ModuleVc,
_context: ModuleAssetContextVc, _context: ModuleAssetContextVc,
) -> Result<AssetVc> { ) -> Result<ModuleVc> {
Ok( Ok(
if let Some(placeable) = EcmascriptChunkPlaceableVc::resolve_from(asset).await? { if let Some(placeable) = EcmascriptChunkPlaceableVc::resolve_from(asset).await? {
WithChunksAsset { WithChunksAsset {
......
...@@ -4,10 +4,11 @@ use turbopack_binding::turbopack::{ ...@@ -4,10 +4,11 @@ use turbopack_binding::turbopack::{
core::{ core::{
asset::{Asset, AssetContentVc, AssetVc}, asset::{Asset, AssetContentVc, AssetVc},
chunk::{ chunk::{
availability_info::AvailabilityInfo, ChunkVc, ChunkableAsset, ChunkableAssetVc, availability_info::AvailabilityInfo, ChunkVc, ChunkableModule, ChunkableModuleVc,
ChunkingContextVc, ChunkingContextVc,
}, },
ident::AssetIdentVc, ident::AssetIdentVc,
module::{Module, ModuleVc},
reference::AssetReferencesVc, reference::AssetReferencesVc,
}, },
ecmascript::chunk::EcmascriptChunkingContextVc, ecmascript::chunk::EcmascriptChunkingContextVc,
...@@ -47,7 +48,10 @@ impl Asset for InChunkingContextAsset { ...@@ -47,7 +48,10 @@ impl Asset for InChunkingContextAsset {
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ChunkableAsset for InChunkingContextAsset { impl Module for InChunkingContextAsset {}
#[turbo_tasks::value_impl]
impl ChunkableModule for InChunkingContextAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn as_chunk( fn as_chunk(
&self, &self,
......
...@@ -12,10 +12,11 @@ use turbopack_binding::{ ...@@ -12,10 +12,11 @@ use turbopack_binding::{
asset::{Asset, AssetContentVc, AssetVc, AssetsVc}, asset::{Asset, AssetContentVc, AssetVc, AssetsVc},
chunk::{ chunk::{
availability_info::AvailabilityInfo, ChunkDataVc, ChunkGroupReferenceVc, ChunkItem, availability_info::AvailabilityInfo, ChunkDataVc, ChunkGroupReferenceVc, ChunkItem,
ChunkItemVc, ChunkVc, ChunkableAsset, ChunkableAssetVc, ChunkingContext, ChunkItemVc, ChunkVc, ChunkableModule, ChunkableModuleVc, ChunkingContext,
ChunkingContextVc, ChunksDataVc, ChunkingContextVc, ChunksDataVc,
}, },
ident::AssetIdentVc, ident::AssetIdentVc,
module::{Module, ModuleVc},
reference::AssetReferencesVc, reference::AssetReferencesVc,
}, },
ecmascript::{ ecmascript::{
...@@ -67,7 +68,10 @@ impl Asset for WithChunksAsset { ...@@ -67,7 +68,10 @@ impl Asset for WithChunksAsset {
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ChunkableAsset for WithChunksAsset { impl Module for WithChunksAsset {}
#[turbo_tasks::value_impl]
impl ChunkableModule for WithChunksAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn as_chunk( fn as_chunk(
self_vc: WithChunksAssetVc, self_vc: WithChunksAssetVc,
......
...@@ -5,6 +5,7 @@ use turbopack_binding::turbopack::{ ...@@ -5,6 +5,7 @@ use turbopack_binding::turbopack::{
core::{ core::{
asset::AssetVc, asset::AssetVc,
context::AssetContext, context::AssetContext,
module::ModuleVc,
reference_type::{EntryReferenceSubType, InnerAssetsVc, ReferenceType}, reference_type::{EntryReferenceSubType, InnerAssetsVc, ReferenceType},
}, },
turbopack::{ turbopack::{
...@@ -28,7 +29,7 @@ impl Transition for NextServerToClientTransition { ...@@ -28,7 +29,7 @@ impl Transition for NextServerToClientTransition {
asset: AssetVc, asset: AssetVc,
context: ModuleAssetContextVc, context: ModuleAssetContextVc,
_reference_type: Value<ReferenceType>, _reference_type: Value<ReferenceType>,
) -> Result<AssetVc> { ) -> Result<ModuleVc> {
let internal_asset = next_asset(if self_vc.await?.ssr { let internal_asset = next_asset(if self_vc.await?.ssr {
"entry/app/server-to-client-ssr.tsx" "entry/app/server-to-client-ssr.tsx"
} else { } else {
...@@ -50,8 +51,8 @@ impl Transition for NextServerToClientTransition { ...@@ -50,8 +51,8 @@ impl Transition for NextServerToClientTransition {
Ok(context.process( Ok(context.process(
internal_asset, internal_asset,
Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap! { Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap! {
"CLIENT_MODULE".to_string() => client_module, "CLIENT_MODULE".to_string() => client_module.into(),
"CLIENT_CHUNKS".to_string() => client_chunks, "CLIENT_CHUNKS".to_string() => client_chunks.into(),
}))), }))),
)) ))
} }
......
use anyhow::Result; use anyhow::Result;
use turbopack_binding::turbopack::{ use turbopack_binding::turbopack::{
core::{asset::AssetVc, compile_time_info::CompileTimeInfoVc}, core::{compile_time_info::CompileTimeInfoVc, module::ModuleVc},
turbopack::{ turbopack::{
ecmascript::chunk::EcmascriptChunkPlaceableVc, ecmascript::chunk::EcmascriptChunkPlaceableVc,
module_options::ModuleOptionsContextVc, module_options::ModuleOptionsContextVc,
...@@ -48,9 +48,9 @@ impl Transition for NextSSRClientModuleTransition { ...@@ -48,9 +48,9 @@ impl Transition for NextSSRClientModuleTransition {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn process_module( async fn process_module(
&self, &self,
asset: AssetVc, asset: ModuleVc,
_context: ModuleAssetContextVc, _context: ModuleAssetContextVc,
) -> Result<AssetVc> { ) -> Result<ModuleVc> {
Ok( Ok(
if let Some(placeable) = EcmascriptChunkPlaceableVc::resolve_from(asset).await? { if let Some(placeable) = EcmascriptChunkPlaceableVc::resolve_from(asset).await? {
WithChunkingContextScopeAsset { WithChunkingContextScopeAsset {
......
...@@ -4,10 +4,11 @@ use turbopack_binding::turbopack::{ ...@@ -4,10 +4,11 @@ use turbopack_binding::turbopack::{
core::{ core::{
asset::{Asset, AssetContentVc, AssetVc}, asset::{Asset, AssetContentVc, AssetVc},
chunk::{ chunk::{
availability_info::AvailabilityInfo, ChunkVc, ChunkableAsset, ChunkableAssetVc, availability_info::AvailabilityInfo, ChunkVc, ChunkableModule, ChunkableModuleVc,
ChunkingContext, ChunkingContextVc, ChunkingContext, ChunkingContextVc,
}, },
ident::AssetIdentVc, ident::AssetIdentVc,
module::{Module, ModuleVc},
reference::AssetReferencesVc, reference::AssetReferencesVc,
}, },
ecmascript::chunk::EcmascriptChunkingContextVc, ecmascript::chunk::EcmascriptChunkingContextVc,
...@@ -47,7 +48,10 @@ impl Asset for WithChunkingContextScopeAsset { ...@@ -47,7 +48,10 @@ impl Asset for WithChunkingContextScopeAsset {
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ChunkableAsset for WithChunkingContextScopeAsset { impl Module for WithChunkingContextScopeAsset {}
#[turbo_tasks::value_impl]
impl ChunkableModule for WithChunkingContextScopeAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn as_chunk( fn as_chunk(
&self, &self,
......
...@@ -8,11 +8,12 @@ use turbopack_binding::{ ...@@ -8,11 +8,12 @@ use turbopack_binding::{
asset::{Asset, AssetContentVc, AssetVc, AssetsVc}, asset::{Asset, AssetContentVc, AssetVc, AssetsVc},
chunk::{ chunk::{
availability_info::AvailabilityInfo, ChunkDataVc, ChunkItem, ChunkItemVc, ChunkVc, availability_info::AvailabilityInfo, ChunkDataVc, ChunkItem, ChunkItemVc, ChunkVc,
ChunkableAsset, ChunkableAssetReference, ChunkableAssetReferenceVc, ChunkableModule, ChunkableModuleReference, ChunkableModuleReferenceVc,
ChunkableAssetVc, ChunkingContext, ChunkingContextVc, ChunkingType, ChunkableModuleVc, ChunkingContext, ChunkingContextVc, ChunkingType,
ChunkingTypeOptionVc, ChunksDataVc, ChunkingTypeOptionVc, ChunksDataVc,
}, },
ident::AssetIdentVc, ident::AssetIdentVc,
module::{Module, ModuleVc},
proxied_asset::ProxiedAssetVc, proxied_asset::ProxiedAssetVc,
reference::{ reference::{
AssetReference, AssetReferenceVc, AssetReferencesVc, SingleAssetReferenceVc, AssetReference, AssetReferenceVc, AssetReferencesVc, SingleAssetReferenceVc,
...@@ -66,7 +67,10 @@ impl Asset for WithClientChunksAsset { ...@@ -66,7 +67,10 @@ impl Asset for WithClientChunksAsset {
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ChunkableAsset for WithClientChunksAsset { impl Module for WithClientChunksAsset {}
#[turbo_tasks::value_impl]
impl ChunkableModule for WithClientChunksAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn as_chunk( fn as_chunk(
self_vc: WithClientChunksAssetVc, self_vc: WithClientChunksAssetVc,
...@@ -257,7 +261,7 @@ impl AssetReference for WithClientChunksAssetReference { ...@@ -257,7 +261,7 @@ impl AssetReference for WithClientChunksAssetReference {
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ChunkableAssetReference for WithClientChunksAssetReference { impl ChunkableModuleReference for WithClientChunksAssetReference {
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_type(&self) -> ChunkingTypeOptionVc { fn chunking_type(&self) -> ChunkingTypeOptionVc {
ChunkingTypeOptionVc::cell(Some(ChunkingType::IsolatedParallel)) ChunkingTypeOptionVc::cell(Some(ChunkingType::IsolatedParallel))
......
...@@ -684,14 +684,14 @@ pub async fn load_next_config_internal( ...@@ -684,14 +684,14 @@ pub async fn load_next_config_internal(
config_asset.into(), config_asset.into(),
Value::new(ReferenceType::Internal(InnerAssetsVc::empty())), Value::new(ReferenceType::Internal(InnerAssetsVc::empty())),
); );
any_content_changed(config_asset) any_content_changed(config_asset.into())
}); });
let load_next_config_asset = context.process( let load_next_config_asset = context.process(
next_asset("entry/config/next.js"), next_asset("entry/config/next.js"),
Value::new(ReferenceType::Entry(EntryReferenceSubType::Undefined)), Value::new(ReferenceType::Entry(EntryReferenceSubType::Undefined)),
); );
let config_value = evaluate( let config_value = evaluate(
load_next_config_asset, load_next_config_asset.into(),
project_path, project_path,
env, env,
config_asset.map_or_else(|| AssetIdentVc::from_path(project_path), |c| c.ident()), config_asset.map_or_else(|| AssetIdentVc::from_path(project_path), |c| c.ident()),
......
...@@ -6,9 +6,10 @@ use turbopack_binding::{ ...@@ -6,9 +6,10 @@ use turbopack_binding::{
turbopack::{ turbopack::{
core::{ core::{
asset::AssetVc, asset::AssetVc,
chunk::{ChunkableAssetVc, ChunkingContextVc}, chunk::{ChunkableModuleVc, ChunkingContextVc},
compile_time_info::CompileTimeInfoVc, compile_time_info::CompileTimeInfoVc,
context::AssetContext, context::AssetContext,
module::ModuleVc,
reference_type::{EcmaScriptModulesReferenceSubType, InnerAssetsVc, ReferenceType}, reference_type::{EcmaScriptModulesReferenceSubType, InnerAssetsVc, ReferenceType},
source_asset::SourceAssetVc, source_asset::SourceAssetVc,
}, },
...@@ -68,28 +69,28 @@ impl Transition for NextEdgePageTransition { ...@@ -68,28 +69,28 @@ impl Transition for NextEdgePageTransition {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn process_module( async fn process_module(
&self, &self,
asset: AssetVc, asset: ModuleVc,
context: ModuleAssetContextVc, context: ModuleAssetContextVc,
) -> Result<AssetVc> { ) -> Result<ModuleVc> {
let asset = context.process( let module = context.process(
self.bootstrap_asset, self.bootstrap_asset,
Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap! { Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap! {
"APP_ENTRY".to_string() => asset, "APP_ENTRY".to_string() => asset.into(),
"APP_BOOTSTRAP".to_string() => context.with_transition("next-client").process( "APP_BOOTSTRAP".to_string() => context.with_transition("next-client").process(
SourceAssetVc::new(next_js_file_path("entry/app/hydrate.tsx")).into(), SourceAssetVc::new(next_js_file_path("entry/app/hydrate.tsx")).into(),
Value::new(ReferenceType::EcmaScriptModules( Value::new(ReferenceType::EcmaScriptModules(
EcmaScriptModulesReferenceSubType::Undefined, EcmaScriptModulesReferenceSubType::Undefined,
)), )),
), ).into(),
}))), }))),
); );
let Some(asset) = ChunkableAssetVc::resolve_from(asset).await? else { let Some(module) = ChunkableModuleVc::resolve_from(module).await? else {
bail!("Internal module is not evaluatable"); bail!("Internal module is not chunkable");
}; };
let asset = ChunkGroupFilesAsset { let asset = ChunkGroupFilesAsset {
asset, module,
client_root: self.output_path, client_root: self.output_path,
chunking_context: self.edge_chunking_context, chunking_context: self.edge_chunking_context,
runtime_entries: None, runtime_entries: None,
......
...@@ -3,7 +3,10 @@ use indexmap::indexmap; ...@@ -3,7 +3,10 @@ use indexmap::indexmap;
use turbopack_binding::{ use turbopack_binding::{
turbo::tasks_fs::FileSystemPathVc, turbo::tasks_fs::FileSystemPathVc,
turbopack::{ turbopack::{
core::{asset::AssetVc, chunk::ChunkingContextVc, compile_time_info::CompileTimeInfoVc}, core::{
asset::AssetVc, chunk::ChunkingContextVc, compile_time_info::CompileTimeInfoVc,
module::ModuleVc,
},
ecmascript::chunk_group_files_asset::ChunkGroupFilesAsset, ecmascript::chunk_group_files_asset::ChunkGroupFilesAsset,
turbopack::{ turbopack::{
module_options::ModuleOptionsContextVc, module_options::ModuleOptionsContextVc,
...@@ -57,11 +60,11 @@ impl Transition for NextEdgeRouteTransition { ...@@ -57,11 +60,11 @@ impl Transition for NextEdgeRouteTransition {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn process_module( async fn process_module(
&self, &self,
asset: AssetVc, asset: ModuleVc,
context: ModuleAssetContextVc, context: ModuleAssetContextVc,
) -> Result<AssetVc> { ) -> Result<ModuleVc> {
let new_asset = route_bootstrap( let new_asset = route_bootstrap(
asset, asset.into(),
context.into(), context.into(),
self.base_path, self.base_path,
self.bootstrap_asset, self.bootstrap_asset,
...@@ -71,7 +74,7 @@ impl Transition for NextEdgeRouteTransition { ...@@ -71,7 +74,7 @@ impl Transition for NextEdgeRouteTransition {
); );
let asset = ChunkGroupFilesAsset { let asset = ChunkGroupFilesAsset {
asset: new_asset.into(), module: new_asset.into(),
client_root: self.output_path, client_root: self.output_path,
chunking_context: self.edge_chunking_context, chunking_context: self.edge_chunking_context,
runtime_entries: None, runtime_entries: None,
......
...@@ -458,7 +458,7 @@ async fn get_mock_stylesheet( ...@@ -458,7 +458,7 @@ async fn get_mock_stylesheet(
let root = mock_fs.root(); let root = mock_fs.root();
let val = evaluate( let val = evaluate(
mocked_response_asset, mocked_response_asset.into(),
root, root,
env, env,
AssetIdentVc::from_path(loader_path), AssetIdentVc::from_path(loader_path),
......
...@@ -6,6 +6,7 @@ use turbopack_binding::{ ...@@ -6,6 +6,7 @@ use turbopack_binding::{
core::{ core::{
asset::AssetVc, asset::AssetVc,
context::AssetContext, context::AssetContext,
module::ModuleVc,
reference_type::{InnerAssetsVc, ReferenceType}, reference_type::{InnerAssetsVc, ReferenceType},
resolve::ModulePartVc, resolve::ModulePartVc,
}, },
...@@ -47,7 +48,7 @@ impl StructuredImageModuleType { ...@@ -47,7 +48,7 @@ impl StructuredImageModuleType {
source: AssetVc, source: AssetVc,
blur_placeholder_mode: BlurPlaceholderMode, blur_placeholder_mode: BlurPlaceholderMode,
context: ModuleAssetContextVc, context: ModuleAssetContextVc,
) -> AssetVc { ) -> ModuleVc {
let static_asset = StaticModuleAssetVc::new(source, context.into()); let static_asset = StaticModuleAssetVc::new(source, context.into());
context.process( context.process(
StructuredImageSourceAsset { StructuredImageSourceAsset {
...@@ -81,7 +82,7 @@ impl CustomModuleType for StructuredImageModuleType { ...@@ -81,7 +82,7 @@ impl CustomModuleType for StructuredImageModuleType {
source: AssetVc, source: AssetVc,
context: ModuleAssetContextVc, context: ModuleAssetContextVc,
_part: Option<ModulePartVc>, _part: Option<ModulePartVc>,
) -> AssetVc { ) -> ModuleVc {
StructuredImageModuleType::create_module(source, self.blur_placeholder_mode, context) StructuredImageModuleType::create_module(source, self.blur_placeholder_mode, context)
} }
} }
...@@ -9,11 +9,12 @@ use turbopack_binding::{ ...@@ -9,11 +9,12 @@ use turbopack_binding::{
core::{ core::{
asset::{Asset, AssetContentVc, AssetVc, AssetsVc}, asset::{Asset, AssetContentVc, AssetVc, AssetsVc},
chunk::{ chunk::{
ChunkDataVc, ChunkableAsset, ChunkingContext, ChunkingContextVc, ChunksDataVc, ChunkDataVc, ChunkableModule, ChunkingContext, ChunkingContextVc, ChunksDataVc,
EvaluatableAssetVc, EvaluatableAssetsVc, EvaluatableAssetVc, EvaluatableAssetsVc,
}, },
context::{AssetContext, AssetContextVc}, context::{AssetContext, AssetContextVc},
ident::AssetIdentVc, ident::AssetIdentVc,
module::ModuleVc,
reference::{AssetReferencesVc, SingleAssetReferenceVc}, reference::{AssetReferencesVc, SingleAssetReferenceVc},
reference_type::{EntryReferenceSubType, InnerAssetsVc, ReferenceType}, reference_type::{EntryReferenceSubType, InnerAssetsVc, ReferenceType},
virtual_asset::VirtualAssetVc, virtual_asset::VirtualAssetVc,
...@@ -59,7 +60,7 @@ pub async fn create_page_loader_entry_asset( ...@@ -59,7 +60,7 @@ pub async fn create_page_loader_entry_asset(
client_context: AssetContextVc, client_context: AssetContextVc,
entry_asset: AssetVc, entry_asset: AssetVc,
pathname: StringVc, pathname: StringVc,
) -> Result<AssetVc> { ) -> Result<ModuleVc> {
let mut result = RopeBuilder::default(); let mut result = RopeBuilder::default();
writeln!( writeln!(
result, result,
...@@ -81,12 +82,13 @@ pub async fn create_page_loader_entry_asset( ...@@ -81,12 +82,13 @@ pub async fn create_page_loader_entry_asset(
Ok(client_context.process( Ok(client_context.process(
virtual_asset, virtual_asset,
Value::new(ReferenceType::Internal( Value::new(ReferenceType::Internal(InnerAssetsVc::cell(indexmap! {
InnerAssetsVc::cell(indexmap! { "PAGE".to_string() => client_context.process(
"PAGE".to_string() => client_context.process(entry_asset, Value::new(ReferenceType::Entry(EntryReferenceSubType::Page))) entry_asset,
}) Value::new(ReferenceType::Entry(EntryReferenceSubType::Page))
))) ).into(),
) }))),
))
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
......
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use indexmap::indexmap; use indexmap::{indexmap, IndexMap};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_tasks::{ use turbo_tasks::{
primitives::{JsonValueVc, StringVc, StringsVc}, primitives::{JsonValueVc, StringVc, StringsVc},
...@@ -536,10 +536,12 @@ async fn create_not_found_page_source( ...@@ -536,10 +536,12 @@ async fn create_not_found_page_source(
) )
}; };
let entry_asset = server_context.process( let entry_asset = server_context
page_asset, .process(
Value::new(ReferenceType::Entry(EntryReferenceSubType::Page)), page_asset,
); Value::new(ReferenceType::Entry(EntryReferenceSubType::Page)),
)
.into();
let ssr_entry = SsrEntry { let ssr_entry = SsrEntry {
runtime_entries, runtime_entries,
...@@ -802,12 +804,12 @@ impl SsrEntryVc { ...@@ -802,12 +804,12 @@ impl SsrEntryVc {
} else { } else {
this.ty this.ty
}; };
let (internal_asset, inner_assets) = match ty { let (internal_asset, inner_assets): (_, IndexMap<_, AssetVc>) = match ty {
SsrType::AutoApi => unreachable!(), SsrType::AutoApi => unreachable!(),
SsrType::Api => ( SsrType::Api => (
next_asset("entry/server-api.tsx"), next_asset("entry/server-api.tsx"),
indexmap! { indexmap! {
"INNER".to_string() => entry_asset_page, "INNER".to_string() => entry_asset_page.into(),
}, },
), ),
SsrType::EdgeApi => { SsrType::EdgeApi => {
...@@ -819,14 +821,14 @@ impl SsrEntryVc { ...@@ -819,14 +821,14 @@ impl SsrEntryVc {
( (
next_asset("entry/server-edge-api.tsx"), next_asset("entry/server-edge-api.tsx"),
indexmap! { indexmap! {
"INNER_EDGE_CHUNK_GROUP".to_string() => entry_asset_edge_chunk_group, "INNER_EDGE_CHUNK_GROUP".to_string() => entry_asset_edge_chunk_group.into(),
}, },
) )
} }
SsrType::Data => ( SsrType::Data => (
next_asset("entry/server-data.tsx"), next_asset("entry/server-data.tsx"),
indexmap! { indexmap! {
"INNER".to_string() => entry_asset_page, "INNER".to_string() => entry_asset_page.into(),
}, },
), ),
SsrType::Html => { SsrType::Html => {
...@@ -838,8 +840,8 @@ impl SsrEntryVc { ...@@ -838,8 +840,8 @@ impl SsrEntryVc {
( (
next_asset("entry/server-renderer.tsx"), next_asset("entry/server-renderer.tsx"),
indexmap! { indexmap! {
"INNER".to_string() => entry_asset_page, "INNER".to_string() => entry_asset_page.into(),
"INNER_CLIENT_CHUNK_GROUP".to_string() => entry_asset_client_chunk_group, "INNER_CLIENT_CHUNK_GROUP".to_string() => entry_asset_client_chunk_group.into(),
}, },
) )
} }
......
...@@ -16,13 +16,13 @@ use turbopack_binding::{ ...@@ -16,13 +16,13 @@ use turbopack_binding::{
}, },
turbopack::{ turbopack::{
core::{ core::{
asset::{AssetOptionVc, AssetVc},
changed::any_content_changed, changed::any_content_changed,
chunk::ChunkingContext, chunk::ChunkingContext,
context::{AssetContext, AssetContextVc}, context::{AssetContext, AssetContextVc},
environment::{ServerAddrVc, ServerInfo}, environment::{ServerAddrVc, ServerInfo},
ident::AssetIdentVc, ident::AssetIdentVc,
issue::IssueVc, issue::IssueVc,
module::ModuleVc,
reference_type::{EcmaScriptModulesReferenceSubType, InnerAssetsVc, ReferenceType}, reference_type::{EcmaScriptModulesReferenceSubType, InnerAssetsVc, ReferenceType},
resolve::{find_context_file, FindContextFileResult}, resolve::{find_context_file, FindContextFileResult},
source_asset::SourceAssetVc, source_asset::SourceAssetVc,
...@@ -137,33 +137,21 @@ pub enum RouterResult { ...@@ -137,33 +137,21 @@ pub enum RouterResult {
Error(#[turbo_tasks(trace_ignore)] SharedError), Error(#[turbo_tasks(trace_ignore)] SharedError),
} }
#[turbo_tasks::function]
async fn get_config(
context: AssetContextVc,
project_path: FileSystemPathVc,
configs: StringsVc,
) -> Result<AssetOptionVc> {
let find_config_result = find_context_file(project_path, configs);
let config_asset = match &*find_config_result.await? {
FindContextFileResult::Found(config_path, _) => Some(context.process(
SourceAssetVc::new(*config_path).as_asset(),
Value::new(ReferenceType::Internal(InnerAssetsVc::empty())),
)),
FindContextFileResult::NotFound(_) => None,
};
Ok(AssetOptionVc::cell(config_asset))
}
#[turbo_tasks::function] #[turbo_tasks::function]
async fn next_config_changed( async fn next_config_changed(
context: AssetContextVc, context: AssetContextVc,
project_path: FileSystemPathVc, project_path: FileSystemPathVc,
) -> Result<CompletionVc> { ) -> Result<CompletionVc> {
let next_config = get_config(context, project_path, next_configs()).await?; let find_config_result = find_context_file(project_path, next_configs());
Ok(if let Some(c) = *next_config { Ok(match *find_config_result.await? {
any_content_changed(c) FindContextFileResult::Found(config_path, _) => {
} else { let module = context.process(
CompletionVc::immutable() SourceAssetVc::new(config_path).as_asset(),
Value::new(ReferenceType::Internal(InnerAssetsVc::empty())),
);
any_content_changed(module.into())
}
FindContextFileResult::NotFound(_) => CompletionVc::immutable(),
}) })
} }
...@@ -173,25 +161,30 @@ async fn config_assets( ...@@ -173,25 +161,30 @@ async fn config_assets(
project_path: FileSystemPathVc, project_path: FileSystemPathVc,
page_extensions: StringsVc, page_extensions: StringsVc,
) -> Result<InnerAssetsVc> { ) -> Result<InnerAssetsVc> {
let middleware_config = let find_config_result = find_context_file(project_path, middleware_files(page_extensions));
get_config(context, project_path, middleware_files(page_extensions)).await?;
// The router.ts file expects a manifest of chunks for the middleware. If there // The router.ts file expects a manifest of chunks for the middleware. If there
// is no middleware file, then we need to generate a default empty manifest // is no middleware file, then we need to generate a default empty manifest
// and we cannot process it with the next-edge transition because it // and we cannot process it with the next-edge transition because it
// requires a real file for some reason. // requires a real file for some reason.
let (manifest, config) = match &*middleware_config { let (manifest, config) = match *find_config_result.await? {
Some(c) => { FindContextFileResult::Found(config_path, _) => {
let config = context.process(
SourceAssetVc::new(config_path).into(),
Value::new(ReferenceType::EcmaScriptModules(
EcmaScriptModulesReferenceSubType::Undefined,
)),
);
let config = parse_config_from_source(config);
let manifest = context.with_transition("next-edge").process( let manifest = context.with_transition("next-edge").process(
*c, SourceAssetVc::new(config_path).into(),
Value::new(ReferenceType::EcmaScriptModules( Value::new(ReferenceType::EcmaScriptModules(
EcmaScriptModulesReferenceSubType::Undefined, EcmaScriptModulesReferenceSubType::Undefined,
)), )),
); );
let config = parse_config_from_source(*c);
(manifest, config) (manifest, config)
} }
None => { FindContextFileResult::NotFound(_) => {
let manifest = context.process( let manifest = context.process(
VirtualAssetVc::new( VirtualAssetVc::new(
project_path.join("middleware.js"), project_path.join("middleware.js"),
...@@ -219,13 +212,13 @@ async fn config_assets( ...@@ -219,13 +212,13 @@ async fn config_assets(
); );
Ok(InnerAssetsVc::cell(indexmap! { Ok(InnerAssetsVc::cell(indexmap! {
"MIDDLEWARE_CHUNK_GROUP".to_string() => manifest, "MIDDLEWARE_CHUNK_GROUP".to_string() => manifest.into(),
"MIDDLEWARE_CONFIG".to_string() => config_asset, "MIDDLEWARE_CONFIG".to_string() => config_asset.into(),
})) }))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn route_executor(context: AssetContextVc, configs: InnerAssetsVc) -> AssetVc { fn route_executor(context: AssetContextVc, configs: InnerAssetsVc) -> ModuleVc {
context.process( context.process(
next_asset("entry/router.ts"), next_asset("entry/router.ts"),
Value::new(ReferenceType::Internal(configs)), Value::new(ReferenceType::Internal(configs)),
...@@ -363,7 +356,7 @@ async fn route_internal( ...@@ -363,7 +356,7 @@ async fn route_internal(
}; };
let server_addr = server_addr.await?; let server_addr = server_addr.await?;
let result = evaluate( let result = evaluate(
router_asset, router_asset.into(),
project_path, project_path,
env, env,
AssetIdentVc::from_path(project_path), AssetIdentVc::from_path(project_path),
...@@ -434,7 +427,7 @@ async fn route_internal( ...@@ -434,7 +427,7 @@ async fn route_internal(
RouterResult::Error(shared_anyhow!( RouterResult::Error(shared_anyhow!(
trace_stack( trace_stack(
error, error,
router_asset, router_asset.into(),
chunking_context.output_root(), chunking_context.output_root(),
project_path project_path
) )
......
...@@ -10,10 +10,11 @@ use turbopack_binding::{ ...@@ -10,10 +10,11 @@ use turbopack_binding::{
turbo::tasks_fs::{json::parse_json_rope_with_source_context, FileContent, FileSystemPathVc}, turbo::tasks_fs::{json::parse_json_rope_with_source_context, FileContent, FileSystemPathVc},
turbopack::{ turbopack::{
core::{ core::{
asset::{Asset, AssetVc}, asset::Asset,
environment::{ServerAddrVc, ServerInfo}, environment::{ServerAddrVc, ServerInfo},
ident::AssetIdentVc, ident::AssetIdentVc,
issue::{Issue, IssueSeverity, IssueSeverityVc, IssueVc, OptionIssueSourceVc}, issue::{Issue, IssueSeverity, IssueSeverityVc, IssueVc, OptionIssueSourceVc},
module::ModuleVc,
reference_type::{EcmaScriptModulesReferenceSubType, ReferenceType}, reference_type::{EcmaScriptModulesReferenceSubType, ReferenceType},
resolve::{ resolve::{
self, handle_resolve_error, node::node_cjs_resolve_options, parse::RequestVc, self, handle_resolve_error, node::node_cjs_resolve_options, parse::RequestVc,
...@@ -165,15 +166,15 @@ impl Issue for NextSourceConfigParsingIssue { ...@@ -165,15 +166,15 @@ impl Issue for NextSourceConfigParsingIssue {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn parse_config_from_source(module_asset: AssetVc) -> Result<NextSourceConfigVc> { pub async fn parse_config_from_source(module: ModuleVc) -> Result<NextSourceConfigVc> {
if let Some(ecmascript_asset) = EcmascriptModuleAssetVc::resolve_from(module_asset).await? { if let Some(ecmascript_asset) = EcmascriptModuleAssetVc::resolve_from(module).await? {
if let ParseResult::Ok { if let ParseResult::Ok {
program: Program::Module(module), program: Program::Module(module_ast),
eval_context, eval_context,
.. ..
} = &*ecmascript_asset.parse().await? } = &*ecmascript_asset.parse().await?
{ {
for item in &module.body { for item in &module_ast.body {
if let Some(decl) = item if let Some(decl) = item
.as_module_decl() .as_module_decl()
.and_then(|mod_decl| mod_decl.as_export_decl()) .and_then(|mod_decl| mod_decl.as_export_decl())
...@@ -188,10 +189,10 @@ pub async fn parse_config_from_source(module_asset: AssetVc) -> Result<NextSourc ...@@ -188,10 +189,10 @@ pub async fn parse_config_from_source(module_asset: AssetVc) -> Result<NextSourc
{ {
if let Some(init) = decl.init.as_ref() { if let Some(init) = decl.init.as_ref() {
let value = eval_context.eval(init); let value = eval_context.eval(init);
return Ok(parse_config_from_js_value(module_asset, &value).cell()); return Ok(parse_config_from_js_value(module, &value).cell());
} else { } else {
NextSourceConfigParsingIssue { NextSourceConfigParsingIssue {
ident: module_asset.ident(), ident: module.ident(),
detail: StringVc::cell( detail: StringVc::cell(
"The exported config object must contain an variable \ "The exported config object must contain an variable \
initializer." initializer."
...@@ -211,7 +212,7 @@ pub async fn parse_config_from_source(module_asset: AssetVc) -> Result<NextSourc ...@@ -211,7 +212,7 @@ pub async fn parse_config_from_source(module_asset: AssetVc) -> Result<NextSourc
Ok(NextSourceConfigVc::default()) Ok(NextSourceConfigVc::default())
} }
fn parse_config_from_js_value(module_asset: AssetVc, value: &JsValue) -> NextSourceConfig { fn parse_config_from_js_value(module_asset: ModuleVc, value: &JsValue) -> NextSourceConfig {
let mut config = NextSourceConfig::default(); let mut config = NextSourceConfig::default();
let invalid_config = |detail: &str, value: &JsValue| { let invalid_config = |detail: &str, value: &JsValue| {
let (explainer, hints) = value.explain(2, 0); let (explainer, hints) = value.explain(2, 0);
......
...@@ -6,7 +6,7 @@ use turbopack_binding::{ ...@@ -6,7 +6,7 @@ use turbopack_binding::{
}, },
turbopack::{ turbopack::{
core::{ core::{
chunk::{ChunkableAssetVc, ChunkingContextVc}, chunk::{ChunkableModuleVc, ChunkingContextVc},
compile_time_defines, compile_time_defines,
compile_time_info::{ compile_time_info::{
CompileTimeDefines, CompileTimeDefinesVc, CompileTimeInfo, CompileTimeInfoVc, CompileTimeDefines, CompileTimeDefinesVc, CompileTimeInfo, CompileTimeInfoVc,
...@@ -181,7 +181,7 @@ pub async fn create_web_entry_source( ...@@ -181,7 +181,7 @@ pub async fn create_web_entry_source(
chunking_context, chunking_context,
Some(runtime_entries.with_entry(ecmascript.into())), Some(runtime_entries.with_entry(ecmascript.into())),
)) ))
} else if let Some(chunkable) = ChunkableAssetVc::resolve_from(module).await? { } else if let Some(chunkable) = ChunkableModuleVc::resolve_from(module).await? {
// TODO this is missing runtime code, so it's probably broken and we should also // TODO this is missing runtime code, so it's probably broken and we should also
// add an ecmascript chunk with the runtime code // add an ecmascript chunk with the runtime code
Ok((chunkable, chunking_context, None)) Ok((chunkable, chunking_context, None))
......
...@@ -992,8 +992,8 @@ importers: ...@@ -992,8 +992,8 @@ importers:
'@types/react': 18.2.7 '@types/react': 18.2.7
'@types/react-dom': 18.2.4 '@types/react-dom': 18.2.4
'@vercel/ncc': ^0.36.0 '@vercel/ncc': ^0.36.0
'@vercel/turbopack-ecmascript-runtime': https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230707.3 '@vercel/turbopack-ecmascript-runtime': https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230710.2
'@vercel/turbopack-node': https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230707.3 '@vercel/turbopack-node': https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230710.2
anser: ^2.1.1 anser: ^2.1.1
css.escape: ^1.5.1 css.escape: ^1.5.1
find-up: ^6.3.0 find-up: ^6.3.0
...@@ -1005,8 +1005,8 @@ importers: ...@@ -1005,8 +1005,8 @@ importers:
stacktrace-parser: ^0.1.10 stacktrace-parser: ^0.1.10
strip-ansi: ^7.0.1 strip-ansi: ^7.0.1
dependencies: dependencies:
'@vercel/turbopack-ecmascript-runtime': '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230707.3_react-refresh@0.12.0' '@vercel/turbopack-ecmascript-runtime': '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230710.2_react-refresh@0.12.0'
'@vercel/turbopack-node': '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230707.3' '@vercel/turbopack-node': '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230710.2'
anser: 2.1.1 anser: 2.1.1
css.escape: 1.5.1 css.escape: 1.5.1
next: link:../../../../next next: link:../../../../next
...@@ -6136,7 +6136,7 @@ packages: ...@@ -6136,7 +6136,7 @@ packages:
dependencies: dependencies:
'@mdx-js/mdx': 2.2.1 '@mdx-js/mdx': 2.2.1
source-map: 0.7.3 source-map: 0.7.3
webpack: 5.86.0 webpack: 5.86.0_@swc+core@1.3.55
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -6810,7 +6810,6 @@ packages: ...@@ -6810,7 +6810,6 @@ packages:
cpu: [arm64] cpu: [arm64]
os: [darwin] os: [darwin]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-darwin-x64/1.3.55: /@swc/core-darwin-x64/1.3.55:
...@@ -6819,7 +6818,6 @@ packages: ...@@ -6819,7 +6818,6 @@ packages:
cpu: [x64] cpu: [x64]
os: [darwin] os: [darwin]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-linux-arm-gnueabihf/1.3.55: /@swc/core-linux-arm-gnueabihf/1.3.55:
...@@ -6828,7 +6826,6 @@ packages: ...@@ -6828,7 +6826,6 @@ packages:
cpu: [arm] cpu: [arm]
os: [linux] os: [linux]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-linux-arm64-gnu/1.3.55: /@swc/core-linux-arm64-gnu/1.3.55:
...@@ -6837,7 +6834,6 @@ packages: ...@@ -6837,7 +6834,6 @@ packages:
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-linux-arm64-musl/1.3.55: /@swc/core-linux-arm64-musl/1.3.55:
...@@ -6846,7 +6842,6 @@ packages: ...@@ -6846,7 +6842,6 @@ packages:
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-linux-x64-gnu/1.3.55: /@swc/core-linux-x64-gnu/1.3.55:
...@@ -6855,7 +6850,6 @@ packages: ...@@ -6855,7 +6850,6 @@ packages:
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-linux-x64-musl/1.3.55: /@swc/core-linux-x64-musl/1.3.55:
...@@ -6864,7 +6858,6 @@ packages: ...@@ -6864,7 +6858,6 @@ packages:
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-win32-arm64-msvc/1.3.55: /@swc/core-win32-arm64-msvc/1.3.55:
...@@ -6873,7 +6866,6 @@ packages: ...@@ -6873,7 +6866,6 @@ packages:
cpu: [arm64] cpu: [arm64]
os: [win32] os: [win32]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-win32-ia32-msvc/1.3.55: /@swc/core-win32-ia32-msvc/1.3.55:
...@@ -6882,7 +6874,6 @@ packages: ...@@ -6882,7 +6874,6 @@ packages:
cpu: [ia32] cpu: [ia32]
os: [win32] os: [win32]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-win32-x64-msvc/1.3.55: /@swc/core-win32-x64-msvc/1.3.55:
...@@ -6891,7 +6882,6 @@ packages: ...@@ -6891,7 +6882,6 @@ packages:
cpu: [x64] cpu: [x64]
os: [win32] os: [win32]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core/1.3.55_@swc+helpers@0.5.1: /@swc/core/1.3.55_@swc+helpers@0.5.1:
...@@ -6916,7 +6906,6 @@ packages: ...@@ -6916,7 +6906,6 @@ packages:
'@swc/core-win32-arm64-msvc': 1.3.55 '@swc/core-win32-arm64-msvc': 1.3.55
'@swc/core-win32-ia32-msvc': 1.3.55 '@swc/core-win32-ia32-msvc': 1.3.55
'@swc/core-win32-x64-msvc': 1.3.55 '@swc/core-win32-x64-msvc': 1.3.55
dev: true
/@swc/helpers/0.4.14: /@swc/helpers/0.4.14:
resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==} resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==}
...@@ -23814,7 +23803,6 @@ packages: ...@@ -23814,7 +23803,6 @@ packages:
serialize-javascript: 6.0.1 serialize-javascript: 6.0.1
terser: 5.17.7 terser: 5.17.7
webpack: 5.86.0_@swc+core@1.3.55 webpack: 5.86.0_@swc+core@1.3.55
dev: true
/terser/5.10.0: /terser/5.10.0:
resolution: {integrity: sha512-AMmF99DMfEDiRJfxfY5jj5wNH/bYO09cniSqhfoyxc8sFoYIgkJy86G04UoZU5VjlpnplVu0K6Tx6E9b5+DlHA==} resolution: {integrity: sha512-AMmF99DMfEDiRJfxfY5jj5wNH/bYO09cniSqhfoyxc8sFoYIgkJy86G04UoZU5VjlpnplVu0K6Tx6E9b5+DlHA==}
...@@ -25172,7 +25160,6 @@ packages: ...@@ -25172,7 +25160,6 @@ packages:
- '@swc/core' - '@swc/core'
- esbuild - esbuild
- uglify-js - uglify-js
dev: true
/websocket-driver/0.7.3: /websocket-driver/0.7.3:
resolution: {integrity: sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg==} resolution: {integrity: sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg==}
...@@ -25581,9 +25568,9 @@ packages: ...@@ -25581,9 +25568,9 @@ packages:
/zwitch/2.0.4: /zwitch/2.0.4:
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
'@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230707.3_react-refresh@0.12.0': '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230710.2_react-refresh@0.12.0':
resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230707.3} resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230710.2}
id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230707.3' id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230710.2'
name: '@vercel/turbopack-ecmascript-runtime' name: '@vercel/turbopack-ecmascript-runtime'
version: 0.0.0 version: 0.0.0
dependencies: dependencies:
...@@ -25594,8 +25581,8 @@ packages: ...@@ -25594,8 +25581,8 @@ packages:
- webpack - webpack
dev: false dev: false
'@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230707.3': '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230710.2':
resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230707.3} resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230710.2}
name: '@vercel/turbopack-node' name: '@vercel/turbopack-node'
version: 0.0.0 version: 0.0.0
dependencies: dependencies:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment