diff --git a/Cargo.lock b/Cargo.lock index 32fe2002a7d05..20fd7e67b2499 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -412,7 +412,7 @@ dependencies = [ [[package]] name = "auto-hash-map" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "serde", ] @@ -3602,7 +3602,7 @@ dependencies = [ [[package]] name = "node-file-trace" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "serde", @@ -7262,7 +7262,7 @@ dependencies = [ [[package]] name = "turbo-tasks" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "async-trait", @@ -7294,7 +7294,7 @@ dependencies = [ [[package]] name = "turbo-tasks-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "cargo-lock", @@ -7306,7 +7306,7 @@ dependencies = [ [[package]] name = "turbo-tasks-bytes" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "bytes", @@ -7321,7 +7321,7 @@ dependencies = [ [[package]] name = "turbo-tasks-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "dotenvs", @@ -7335,7 +7335,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fetch" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "indexmap", @@ -7352,7 +7352,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fs" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "auto-hash-map", @@ -7382,7 +7382,7 @@ dependencies = [ [[package]] name = "turbo-tasks-hash" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "base16", "hex", @@ -7394,7 +7394,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -7408,7 +7408,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros-shared" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "proc-macro2", "quote", @@ -7418,7 +7418,7 @@ dependencies = [ [[package]] name = "turbo-tasks-malloc" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "mimalloc", ] @@ -7426,7 +7426,7 @@ dependencies = [ [[package]] name = "turbo-tasks-memory" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "auto-hash-map", @@ -7449,7 +7449,7 @@ dependencies = [ [[package]] name = "turbo-tasks-testing" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "auto-hash-map", @@ -7462,7 +7462,7 @@ dependencies = [ [[package]] name = "turbopack" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "async-recursion", @@ -7492,7 +7492,7 @@ dependencies = [ [[package]] name = "turbopack-bench" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "chromiumoxide", @@ -7522,7 +7522,7 @@ dependencies = [ [[package]] name = "turbopack-binding" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "auto-hash-map", "mdxjs", @@ -7564,7 +7564,7 @@ dependencies = [ [[package]] name = "turbopack-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "indexmap", @@ -7584,7 +7584,7 @@ dependencies = [ [[package]] name = "turbopack-cli-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "clap 4.1.11", @@ -7608,7 +7608,7 @@ dependencies = [ [[package]] name = "turbopack-core" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "async-trait", @@ -7636,7 +7636,7 @@ dependencies = [ [[package]] name = "turbopack-create-test-app" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "clap 4.1.11", @@ -7649,7 +7649,7 @@ dependencies = [ [[package]] name = "turbopack-css" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "async-trait", @@ -7671,7 +7671,7 @@ dependencies = [ [[package]] name = "turbopack-dev" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "indexmap", @@ -7695,7 +7695,7 @@ dependencies = [ [[package]] name = "turbopack-dev-server" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "async-compression", @@ -7732,7 +7732,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "async-trait", @@ -7766,7 +7766,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-hmr-protocol" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "serde", "serde_json", @@ -7777,7 +7777,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-plugins" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "async-trait", @@ -7800,7 +7800,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-runtime" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "indoc", @@ -7817,7 +7817,7 @@ dependencies = [ [[package]] name = "turbopack-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "indexmap", @@ -7833,7 +7833,7 @@ dependencies = [ [[package]] name = "turbopack-image" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "base64 0.21.0", @@ -7853,7 +7853,7 @@ dependencies = [ [[package]] name = "turbopack-json" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "serde", @@ -7868,7 +7868,7 @@ dependencies = [ [[package]] name = "turbopack-mdx" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "mdxjs", @@ -7883,7 +7883,7 @@ dependencies = [ [[package]] name = "turbopack-node" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "async-stream", @@ -7918,7 +7918,7 @@ dependencies = [ [[package]] name = "turbopack-static" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "serde", @@ -7934,7 +7934,7 @@ dependencies = [ [[package]] name = "turbopack-swc-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "swc_core", "turbo-tasks", @@ -7945,7 +7945,7 @@ dependencies = [ [[package]] name = "turbopack-test-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.3#1a950b089e432b6479ac99f1eb042a890f837ff9" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230721.4#c4d1d3183af9382b6ff725b002354a9b85d8f7d0" dependencies = [ "anyhow", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 25ed7a2345808..f6eccbba653d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,11 +44,11 @@ swc_core = { version = "0.79.22" } testing = { version = "0.33.21" } # Turbo crates -turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230721.3" } +turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230721.4" } # [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-230721.3" } +turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230721.4" } # [TODO]: need to refactor embed_directory! macro usage in next-core -turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230721.3" } +turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230721.4" } # 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 9cc7965591e71..aaa3f7ab5c5f9 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-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230721.3", - "@vercel/turbopack-node": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230721.3", + "@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230721.4", + "@vercel/turbopack-node": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230721.4", "anser": "^2.1.1", "css.escape": "^1.5.1", "next": "*", diff --git a/packages/next-swc/crates/next-core/src/app_segment_config.rs b/packages/next-swc/crates/next-core/src/app_segment_config.rs index 7fb4d31de28d2..c23ca00ef07e4 100644 --- a/packages/next-swc/crates/next-core/src/app_segment_config.rs +++ b/packages/next-swc/crates/next-core/src/app_segment_config.rs @@ -210,17 +210,17 @@ impl Issue for NextSegmentConfigParsingIssue { #[turbo_tasks::function] pub async fn parse_segment_config_from_source( - module_asset: Vc>, + module: Vc>, source: Vc>, ) -> Result> { let Some(ecmascript_asset) = - Vc::try_resolve_downcast_type::(module_asset).await? + Vc::try_resolve_downcast_type::(module).await? else { return Ok(Default::default()); }; let ParseResult::Ok { - program: Program::Module(module), + program: Program::Module(module_ast), eval_context, .. } = &*ecmascript_asset.parse().await? @@ -230,7 +230,7 @@ pub async fn parse_segment_config_from_source( let mut config = NextSegmentConfig::default(); - for item in &module.body { + for item in &module_ast.body { let Some(decl) = item .as_module_decl() .and_then(|mod_decl| mod_decl.as_export_decl()) @@ -245,7 +245,7 @@ pub async fn parse_segment_config_from_source( }; if let Some(init) = decl.init.as_ref() { - parse_config_value(module_asset, source, &mut config, ident, init, eval_context); + parse_config_value(module, source, &mut config, ident, init, eval_context); } } } diff --git a/packages/next-swc/crates/next-core/src/babel.rs b/packages/next-swc/crates/next-core/src/babel.rs index dc6ac06c111d2..8ff35fd20c6c2 100644 --- a/packages/next-swc/crates/next-core/src/babel.rs +++ b/packages/next-swc/crates/next-core/src/babel.rs @@ -135,7 +135,7 @@ pub async fn is_babel_loader_available(project_path: Vc) -> Resu .cell(), ), ); - let assets = result.primary_assets().await?; + let assets = result.primary_sources().await?; Ok(Vc::cell(!assets.is_empty())) } diff --git a/packages/next-swc/crates/next-core/src/bootstrap.rs b/packages/next-swc/crates/next-core/src/bootstrap.rs index 5634951d442d9..2fc8ca3366213 100644 --- a/packages/next-swc/crates/next-core/src/bootstrap.rs +++ b/packages/next-swc/crates/next-core/src/bootstrap.rs @@ -8,7 +8,7 @@ use turbopack_binding::turbopack::{ chunk::EvaluatableAsset, context::AssetContext, issue::{IssueSeverity, OptionIssueSource}, - module::{convert_asset_to_module, Module}, + module::Module, reference_type::{EcmaScriptModulesReferenceSubType, InnerAssets, ReferenceType}, resolve::parse::Request, source::Source, @@ -35,7 +35,7 @@ pub async fn route_bootstrap( // TODO: this is where you'd switch the route kind to the one you need let route_module_kind = "app-route"; - let resolved_route_module_asset = esm_resolve( + let resolved_route_module = esm_resolve( resolve_origin, Request::parse_string(format!( "next/dist/server/future/route-modules/{}/module", @@ -45,8 +45,8 @@ pub async fn route_bootstrap( OptionIssueSource::none(), IssueSeverity::Error.cell(), ); - let route_module_asset = match *resolved_route_module_asset.first_asset().await? { - Some(a) => convert_asset_to_module(a), + let route_module = match *resolved_route_module.first_module().await? { + Some(module) => module, None => bail!("could not find app asset"), }; @@ -56,7 +56,7 @@ pub async fn route_bootstrap( base_path, bootstrap_asset, Vc::cell(indexmap! { - "ROUTE_MODULE".to_string() => route_module_asset, + "ROUTE_MODULE".to_string() => route_module, }), config, )) diff --git a/packages/next-swc/crates/next-core/src/next_client/runtime_entry.rs b/packages/next-swc/crates/next-core/src/next_client/runtime_entry.rs index b2a4b4ba96cb6..ea3f7cab5c0c1 100644 --- a/packages/next-swc/crates/next-core/src/next_client/runtime_entry.rs +++ b/packages/next-swc/crates/next-core/src/next_client/runtime_entry.rs @@ -7,7 +7,7 @@ use turbopack_binding::{ chunk::{EvaluatableAsset, EvaluatableAssetExt, EvaluatableAssets}, context::AssetContext, issue::{IssueSeverity, OptionIssueSource}, - module::{convert_asset_to_module, Module}, + module::Module, resolve::{origin::PlainResolveOrigin, parse::Request}, source::Source, }, @@ -37,26 +37,25 @@ impl RuntimeEntry { RuntimeEntry::Request(r, path) => (r, path), }; - let assets = cjs_resolve( + let modules = cjs_resolve( Vc::upcast(PlainResolveOrigin::new(context, path)), request, OptionIssueSource::none(), IssueSeverity::Error.cell(), ) - .primary_assets() + .primary_modules() .await?; - let mut runtime_entries = Vec::with_capacity(assets.len()); - for &asset in &assets { + let mut runtime_entries = Vec::with_capacity(modules.len()); + for &module in &modules { if let Some(entry) = - Vc::try_resolve_downcast::>(asset).await? + Vc::try_resolve_downcast::>(module).await? { runtime_entries.push(entry); } else { - let asset = convert_asset_to_module(asset); bail!( "runtime reference resolved to an asset ({}) that cannot be evaluated", - asset.ident().to_string().await? + module.ident().to_string().await? ); } } diff --git a/packages/next-swc/crates/next-core/src/next_client_chunks/in_chunking_context_asset.rs b/packages/next-swc/crates/next-core/src/next_client_chunks/in_chunking_context_asset.rs index a26ac909f08a5..380f26b1481e5 100644 --- a/packages/next-swc/crates/next-core/src/next_client_chunks/in_chunking_context_asset.rs +++ b/packages/next-swc/crates/next-core/src/next_client_chunks/in_chunking_context_asset.rs @@ -6,7 +6,7 @@ use turbopack_binding::turbopack::{ chunk::{availability_info::AvailabilityInfo, Chunk, ChunkableModule, ChunkingContext}, ident::AssetIdent, module::Module, - reference::AssetReferences, + reference::ModuleReferences, }, ecmascript::chunk::EcmascriptChunkingContext, turbopack::ecmascript::chunk::{ @@ -33,7 +33,7 @@ impl Module for InChunkingContextAsset { } #[turbo_tasks::function] - fn references(&self) -> Vc { + fn references(&self) -> Vc { self.asset.references() } } diff --git a/packages/next-swc/crates/next-core/src/next_client_chunks/with_chunks.rs b/packages/next-swc/crates/next-core/src/next_client_chunks/with_chunks.rs index 90be1cea6547d..d68cef31f0bba 100644 --- a/packages/next-swc/crates/next-core/src/next_client_chunks/with_chunks.rs +++ b/packages/next-swc/crates/next-core/src/next_client_chunks/with_chunks.rs @@ -18,7 +18,7 @@ use turbopack_binding::{ ident::AssetIdent, module::Module, output::OutputAssets, - reference::{AssetReferences, SingleAssetReference}, + reference::{ModuleReferences, SingleOutputAssetReference}, }, ecmascript::{ chunk::{ @@ -82,7 +82,7 @@ impl Module for WithChunksAsset { } #[turbo_tasks::function] - async fn references(self: Vc) -> Result> { + async fn references(self: Vc) -> Result> { let this = self.await?; let entry_chunk = self.entry_chunk(); @@ -215,14 +215,14 @@ impl ChunkItem for WithChunksChunkItem { } #[turbo_tasks::function] - async fn references(self: Vc) -> Result> { + async fn references(self: Vc) -> Result> { let mut references = self.await?.inner.references().await?.clone_value(); let chunk_data_key = Vc::cell("chunk data".to_string()); for chunk_data in &*self.chunks_data().await? { references.extend(chunk_data.references().await?.iter().map(|&output_asset| { - Vc::upcast(SingleAssetReference::new( - Vc::upcast(output_asset), + Vc::upcast(SingleOutputAssetReference::new( + output_asset, chunk_data_key, )) })); diff --git a/packages/next-swc/crates/next-core/src/next_client_component/with_chunking_context_scope_asset.rs b/packages/next-swc/crates/next-core/src/next_client_component/with_chunking_context_scope_asset.rs index b27d1a17c49e4..f8cede2ba285c 100644 --- a/packages/next-swc/crates/next-core/src/next_client_component/with_chunking_context_scope_asset.rs +++ b/packages/next-swc/crates/next-core/src/next_client_component/with_chunking_context_scope_asset.rs @@ -6,7 +6,7 @@ use turbopack_binding::turbopack::{ chunk::{availability_info::AvailabilityInfo, Chunk, ChunkableModule, ChunkingContext}, ident::AssetIdent, module::Module, - reference::AssetReferences, + reference::ModuleReferences, }, ecmascript::chunk::EcmascriptChunkingContext, turbopack::ecmascript::chunk::{ @@ -33,7 +33,7 @@ impl Module for WithChunkingContextScopeAsset { } #[turbo_tasks::function] - fn references(&self) -> Vc { + fn references(&self) -> Vc { self.asset.references() } } diff --git a/packages/next-swc/crates/next-core/src/next_client_component/with_client_chunks.rs b/packages/next-swc/crates/next-core/src/next_client_component/with_client_chunks.rs index b704d081d0510..87779c061e8b5 100644 --- a/packages/next-swc/crates/next-core/src/next_client_component/with_client_chunks.rs +++ b/packages/next-swc/crates/next-core/src/next_client_component/with_client_chunks.rs @@ -15,8 +15,8 @@ use turbopack_binding::{ module::Module, output::{OutputAsset, OutputAssets}, proxied_asset::ProxiedAsset, - reference::{AssetReference, AssetReferences, SingleAssetReference}, - resolve::ResolveResult, + reference::{ModuleReference, ModuleReferences, SingleOutputAssetReference}, + resolve::ModuleResolveResult, }, ecmascript::chunk::{EcmascriptChunkData, EcmascriptChunkItemExt}, turbopack::ecmascript::{ @@ -48,7 +48,7 @@ impl Module for WithClientChunksAsset { } #[turbo_tasks::function] - fn references(&self) -> Vc { + fn references(&self) -> Vc { Vc::cell(vec![Vc::upcast( WithClientChunksAssetReference { asset: Vc::upcast(self.asset), @@ -213,7 +213,7 @@ impl ChunkItem for WithClientChunksChunkItem { } #[turbo_tasks::function] - async fn references(self: Vc) -> Result> { + async fn references(self: Vc) -> Result> { let this = self.await?; let inner = this.inner.await?; let mut references = Vec::new(); @@ -227,16 +227,16 @@ impl ChunkItem for WithClientChunksChunkItem { let client_chunks = client_chunks.await?; let client_chunk = Vc::cell("client chunk".to_string()); for &chunk in client_chunks.iter() { - references.push(Vc::upcast(SingleAssetReference::new( - Vc::upcast(chunk), + references.push(Vc::upcast(SingleOutputAssetReference::new( + chunk, client_chunk, ))); } let chunk_data_key = Vc::cell("chunk data".to_string()); for chunk_data in &*self.chunks_data().await? { references.extend(chunk_data.references().await?.iter().map(|&output_asset| { - Vc::upcast(SingleAssetReference::new( - Vc::upcast(output_asset), + Vc::upcast(SingleOutputAssetReference::new( + output_asset, chunk_data_key, )) })); @@ -262,10 +262,10 @@ impl ValueToString for WithClientChunksAssetReference { } #[turbo_tasks::value_impl] -impl AssetReference for WithClientChunksAssetReference { +impl ModuleReference for WithClientChunksAssetReference { #[turbo_tasks::function] - fn resolve_reference(&self) -> Vc { - ResolveResult::asset(Vc::upcast(self.asset)).cell() + fn resolve_reference(&self) -> Vc { + ModuleResolveResult::module(self.asset).cell() } } diff --git a/packages/next-swc/crates/next-core/src/next_client_reference/css_client_reference/css_client_reference_module.rs b/packages/next-swc/crates/next-core/src/next_client_reference/css_client_reference/css_client_reference_module.rs index 35e289d19e7bf..3b4bef4c7dea5 100644 --- a/packages/next-swc/crates/next-core/src/next_client_reference/css_client_reference/css_client_reference_module.rs +++ b/packages/next-swc/crates/next-core/src/next_client_reference/css_client_reference/css_client_reference_module.rs @@ -5,7 +5,6 @@ use turbopack_binding::turbopack::{ asset::{Asset, AssetContent}, ident::AssetIdent, module::Module, - reference::AssetReferences, }, turbopack::css::{chunk::CssChunkPlaceable, ParseCss, ParseCssResult}, }; @@ -40,11 +39,6 @@ impl Module for CssClientReferenceModule { .ident() .with_modifier(css_client_reference_modifier()) } - - #[turbo_tasks::function] - fn references(self: Vc) -> Vc { - AssetReferences::empty() - } } #[turbo_tasks::value_impl] diff --git a/packages/next-swc/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_module.rs b/packages/next-swc/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_module.rs index 9e383e6e327ac..617da43431a53 100644 --- a/packages/next-swc/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_module.rs +++ b/packages/next-swc/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_module.rs @@ -5,7 +5,6 @@ use turbopack_binding::turbopack::{ asset::{Asset, AssetContent}, ident::AssetIdent, module::Module, - reference::AssetReferences, }, ecmascript::chunk::EcmascriptChunkPlaceable, }; @@ -57,11 +56,6 @@ impl Module for EcmascriptClientReferenceModule { self.server_ident .with_modifier(ecmascript_client_reference_modifier()) } - - #[turbo_tasks::function] - fn references(self: Vc) -> Vc { - AssetReferences::empty() - } } #[turbo_tasks::value_impl] diff --git a/packages/next-swc/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_proxy_module.rs b/packages/next-swc/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_proxy_module.rs index 10b2e23d44081..b4adf43c325e8 100644 --- a/packages/next-swc/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_proxy_module.rs +++ b/packages/next-swc/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_proxy_module.rs @@ -14,7 +14,7 @@ use turbopack_binding::turbopack::{ context::AssetContext, ident::AssetIdent, module::Module, - reference::{AssetReferences, SingleAssetReference}, + reference::{ModuleReferences, SingleModuleReference}, reference_type::ReferenceType, virtual_source::VirtualSource, }, @@ -67,7 +67,7 @@ impl EcmascriptClientReferenceProxyModule { } #[turbo_tasks::function] - async fn proxy_module_asset(self: Vc) -> Result> { + async fn proxy_module(self: Vc) -> Result> { let this = self.await?; let mut code = CodeBuilder::default(); @@ -93,12 +93,12 @@ impl EcmascriptClientReferenceProxyModule { )?; let code = code.build(); - let proxy_module_asset_content = + let proxy_module_content = AssetContent::file(File::from(code.source_code().clone()).into()); let proxy_source = VirtualSource::new( this.server_module_ident.path().join("proxy.ts".to_string()), - proxy_module_asset_content, + proxy_module_content, ); let proxy_module = this.server_asset_context.process( @@ -125,7 +125,7 @@ impl Module for EcmascriptClientReferenceProxyModule { } #[turbo_tasks::function] - async fn references(self: Vc) -> Result> { + async fn references(self: Vc) -> Result> { let EcmascriptClientReferenceProxyModule { server_module_ident, server_asset_context: _, @@ -134,12 +134,12 @@ impl Module for EcmascriptClientReferenceProxyModule { } = &*self.await?; let references: Vec<_> = self - .proxy_module_asset() + .proxy_module() .references() .await? .iter() .copied() - .chain(once(Vc::upcast(SingleAssetReference::new( + .chain(once(Vc::upcast(SingleModuleReference::new( Vc::upcast(EcmascriptClientReferenceModule::new( *server_module_ident, *client_module, @@ -187,9 +187,7 @@ impl EcmascriptChunkPlaceable for EcmascriptClientReferenceProxyModule { Vc::upcast( ProxyModuleChunkItem { client_proxy_asset: self, - inner_proxy_module_chunk_item: self - .proxy_module_asset() - .as_chunk_item(chunking_context), + inner_proxy_module_chunk_item: self.proxy_module().as_chunk_item(chunking_context), chunking_context, } .cell(), @@ -198,7 +196,7 @@ impl EcmascriptChunkPlaceable for EcmascriptClientReferenceProxyModule { #[turbo_tasks::function] fn get_exports(self: Vc) -> Vc { - self.proxy_module_asset().get_exports() + self.proxy_module().get_exports() } } @@ -231,7 +229,7 @@ impl ChunkItem for ProxyModuleChunkItem { } #[turbo_tasks::function] - fn references(&self) -> Vc { + fn references(&self) -> Vc { self.client_proxy_asset.references() } } diff --git a/packages/next-swc/crates/next-core/src/next_client_reference/visit_client_reference.rs b/packages/next-swc/crates/next-core/src/next_client_reference/visit_client_reference.rs index 1d578be147f33..ebe67160d1900 100644 --- a/packages/next-swc/crates/next-core/src/next_client_reference/visit_client_reference.rs +++ b/packages/next-swc/crates/next-core/src/next_client_reference/visit_client_reference.rs @@ -10,8 +10,8 @@ use turbo_tasks::{ TryJoinIterExt, Vc, }; use turbopack_binding::turbopack::core::{ - module::{convert_asset_to_module, Module, Modules}, - reference::AssetReference, + module::{Module, Modules}, + reference::ModuleReference, }; use super::{ @@ -175,12 +175,8 @@ impl Visit for VisitClientReference { .copied() .map(|reference| async move { let resolve_result = reference.resolve_reference(); - let assets = resolve_result.primary_assets().await?; - Ok(assets - .iter() - .copied() - .map(convert_asset_to_module) - .collect::>()) + let assets = resolve_result.primary_modules().await?; + Ok(assets.clone_value()) }) .try_join() .await?; diff --git a/packages/next-swc/crates/next-core/src/next_dynamic/dynamic_module.rs b/packages/next-swc/crates/next-core/src/next_dynamic/dynamic_module.rs index 568c0b9ac6f68..b4fe032aa82d6 100644 --- a/packages/next-swc/crates/next-core/src/next_dynamic/dynamic_module.rs +++ b/packages/next-swc/crates/next-core/src/next_dynamic/dynamic_module.rs @@ -6,7 +6,7 @@ use turbopack_binding::turbopack::core::{ ident::AssetIdent, module::Module, output::OutputAssets, - reference::AssetReferences, + reference::ModuleReferences, }; /// A [`NextDynamicEntryModule`] is a marker asset used to indicate which @@ -61,8 +61,8 @@ impl Module for NextDynamicEntryModule { } #[turbo_tasks::function] - fn references(self: Vc) -> Vc { - AssetReferences::empty() + fn references(self: Vc) -> Vc { + ModuleReferences::empty() } } diff --git a/packages/next-swc/crates/next-core/src/next_dynamic/visit_dynamic.rs b/packages/next-swc/crates/next-core/src/next_dynamic/visit_dynamic.rs index ba0c661ec1562..d94a2772ef122 100644 --- a/packages/next-swc/crates/next-core/src/next_dynamic/visit_dynamic.rs +++ b/packages/next-swc/crates/next-core/src/next_dynamic/visit_dynamic.rs @@ -6,8 +6,8 @@ use turbo_tasks::{ TryJoinIterExt, Vc, }; use turbopack_binding::turbopack::core::{ - module::{convert_asset_to_module, Module, Modules}, - reference::AssetReference, + module::{Module, Modules}, + reference::ModuleReference, }; use super::NextDynamicEntryModule; @@ -88,12 +88,8 @@ impl Visit for VisitDynamic { .copied() .map(|reference| async move { let resolve_result = reference.resolve_reference(); - let assets = resolve_result.primary_assets().await?; - Ok(assets - .iter() - .copied() - .map(convert_asset_to_module) - .collect::>()) + let assets = resolve_result.primary_modules().await?; + Ok(assets.clone_value()) }) .try_join() .await?; 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 aba8555a3c7f0..437b9d710d6e4 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 @@ -154,7 +154,7 @@ impl ImportMappingReplacement for NextFontGoogleReplacer { .into()), ); - Ok(ImportMapResult::Result(ResolveResult::asset(Vc::upcast(js_asset)).into()).into()) + Ok(ImportMapResult::Result(ResolveResult::source(Vc::upcast(js_asset)).into()).into()) } } @@ -260,7 +260,7 @@ impl ImportMappingReplacement for NextFontGoogleCssModuleReplacer { ), ); - Ok(ImportMapResult::Result(ResolveResult::asset(Vc::upcast(css_asset)).into()).into()) + Ok(ImportMapResult::Result(ResolveResult::source(Vc::upcast(css_asset)).into()).into()) } } diff --git a/packages/next-swc/crates/next-core/src/next_font/local/mod.rs b/packages/next-swc/crates/next-core/src/next_font/local/mod.rs index 576a938cc0b2b..e2d01ea873d6f 100644 --- a/packages/next-swc/crates/next-core/src/next_font/local/mod.rs +++ b/packages/next-swc/crates/next-core/src/next_font/local/mod.rs @@ -120,7 +120,7 @@ impl ImportMappingReplacement for NextFontLocalReplacer { AssetContent::file(FileContent::Content(file_content.into()).into()), ); - Ok(ImportMapResult::Result(ResolveResult::asset(Vc::upcast(js_asset)).into()).into()) + Ok(ImportMapResult::Result(ResolveResult::source(Vc::upcast(js_asset)).into()).into()) } } @@ -185,7 +185,7 @@ impl ImportMappingReplacement for NextFontLocalCssModuleReplacer { AssetContent::file(FileContent::Content(stylesheet.into()).into()), ); - Ok(ImportMapResult::Result(ResolveResult::asset(Vc::upcast(css_asset)).into()).into()) + Ok(ImportMapResult::Result(ResolveResult::source(Vc::upcast(css_asset)).into()).into()) } } diff --git a/packages/next-swc/crates/next-core/src/next_import_map.rs b/packages/next-swc/crates/next-core/src/next_import_map.rs index ddcbc6b71d5c5..16564705bcf15 100644 --- a/packages/next-swc/crates/next-core/src/next_import_map.rs +++ b/packages/next-swc/crates/next-core/src/next_import_map.rs @@ -12,7 +12,7 @@ use turbopack_binding::{ pattern::Pattern, resolve, AliasPattern, ResolveAliasMap, SubpathValue, }, - source::{asset_to_source, Source}, + source::Source, }, node::execution_context::ExecutionContext, turbopack::{resolve_options, resolve_options_context::ResolveOptionsContext}, @@ -628,9 +628,8 @@ pub async fn get_next_package(project_path: Vc) -> Result, ) -> Result> { let node_resolve_result = resolve(context, request, node_cjs_resolve_options(context.root())); - let primary_node_assets = node_resolve_result.primary_assets().await?; + let primary_node_assets = node_resolve_result.primary_sources().await?; let Some(&node_asset) = primary_node_assets.first() else { // can't resolve request with node.js options return Ok(Vc::cell(false)); }; - let node_asset = asset_to_source(node_asset); if node_asset.ident().path().resolve().await? != expected.resolve().await? { // node.js resolves to a different file @@ -146,7 +144,7 @@ impl ResolvePlugin for ExternalCjsModulesResolvePlugin { if *is_node_resolveable(self.root.root(), request, fs_path).await? { // mark as external return Ok(ResolveResultOption::some( - ResolveResult::primary(PrimaryResolveResult::OriginalReferenceExternal).cell(), + ResolveResult::primary(ResolveResultItem::OriginalReferenceExternal).cell(), )); } @@ -163,11 +161,9 @@ impl ResolvePlugin for ExternalCjsModulesResolvePlugin { if *is_node_resolveable(context, request, fs_path).await? { // mark as external return Ok(ResolveResultOption::some( - ResolveResult::primary( - PrimaryResolveResult::OriginalReferenceTypeExternal( - import_path.as_str().to_string(), - ), - ) + ResolveResult::primary(ResolveResultItem::OriginalReferenceTypeExternal( + import_path.as_str().to_string(), + )) .cell(), )); } diff --git a/packages/next-swc/crates/next-core/src/next_server_component/server_component_module.rs b/packages/next-swc/crates/next-core/src/next_server_component/server_component_module.rs index c895efcf26a0b..f5253735faa9a 100644 --- a/packages/next-swc/crates/next-core/src/next_server_component/server_component_module.rs +++ b/packages/next-swc/crates/next-core/src/next_server_component/server_component_module.rs @@ -10,7 +10,7 @@ use turbopack_binding::turbopack::{ }, ident::AssetIdent, module::Module, - reference::{AssetReference, AssetReferences}, + reference::ModuleReferences, }, ecmascript::chunk::EcmascriptChunkItemExt, turbopack::ecmascript::{ @@ -56,11 +56,10 @@ impl Module for NextServerComponentModule { } #[turbo_tasks::function] - fn references(&self) -> Vc { - let references: Vec>> = vec![Vc::upcast( - NextServerComponentModuleReference::new(Vc::upcast(self.module)), - )]; - Vc::cell(references) + fn references(&self) -> Vc { + Vc::cell(vec![Vc::upcast(NextServerComponentModuleReference::new( + Vc::upcast(self.module), + ))]) } } @@ -154,7 +153,7 @@ impl ChunkItem for BuildServerComponentChunkItem { } #[turbo_tasks::function] - fn references(&self) -> Vc { + fn references(&self) -> Vc { self.inner.references() } } diff --git a/packages/next-swc/crates/next-core/src/next_server_component/server_component_reference.rs b/packages/next-swc/crates/next-core/src/next_server_component/server_component_reference.rs index fe843cf881e5c..f1466de9e95e6 100644 --- a/packages/next-swc/crates/next-core/src/next_server_component/server_component_reference.rs +++ b/packages/next-swc/crates/next-core/src/next_server_component/server_component_reference.rs @@ -3,8 +3,8 @@ use turbo_tasks::{ValueToString, Vc}; use turbopack_binding::turbopack::core::{ chunk::{ChunkableModuleReference, ChunkingType, ChunkingTypeOption}, module::Module, - reference::AssetReference, - resolve::ResolveResult, + reference::ModuleReference, + resolve::ModuleResolveResult, }; #[turbo_tasks::value] @@ -32,10 +32,10 @@ impl ValueToString for NextServerComponentModuleReference { } #[turbo_tasks::value_impl] -impl AssetReference for NextServerComponentModuleReference { +impl ModuleReference for NextServerComponentModuleReference { #[turbo_tasks::function] - fn resolve_reference(&self) -> Vc { - ResolveResult::asset(Vc::upcast(self.asset)).cell() + fn resolve_reference(&self) -> Vc { + ModuleResolveResult::module(self.asset).cell() } } diff --git a/packages/next-swc/crates/next-core/src/next_shared/transforms/swc_ecma_transform_plugins.rs b/packages/next-swc/crates/next-core/src/next_shared/transforms/swc_ecma_transform_plugins.rs index 3f627cf7783da..473618d1a1f9d 100644 --- a/packages/next-swc/crates/next-core/src/next_shared/transforms/swc_ecma_transform_plugins.rs +++ b/packages/next-swc/crates/next-core/src/next_shared/transforms/swc_ecma_transform_plugins.rs @@ -43,7 +43,7 @@ pub async fn get_swc_ecma_transform_plugin_impl( reference_type::ReferenceType, resolve::{ handle_resolve_error, parse::Request, pattern::Pattern, resolve, - PrimaryResolveResult, + ModuleResolveResultItem, }, }, ecmascript_plugin::transform::swc_ecma_transform_plugins::{ @@ -71,7 +71,7 @@ pub async fn get_swc_ecma_transform_plugin_impl( ); let plugin_wasm_module_resolve_result = handle_resolve_error( - resolve(project_path, request, resolve_options), + resolve(project_path, request, resolve_options).as_raw_module_result(), Value::new(ReferenceType::Undefined), project_path, request, @@ -80,18 +80,11 @@ pub async fn get_swc_ecma_transform_plugin_impl( IssueSeverity::Error.cell(), ) .await?; - let plugin_wasm_module_resolve_result = &*plugin_wasm_module_resolve_result.await?; - - let primary = plugin_wasm_module_resolve_result - .primary - .first() - .context("Unable to resolve primary context")?; - - let PrimaryResolveResult::Asset(plugin_module_asset) = primary else { - bail!("Expected to find asset"); + let Some(plugin_module) = *plugin_wasm_module_resolve_result.first_module().await? else { + bail!("Expected to find module"); }; - let content = &*plugin_module_asset.content().file_content().await?; + let content = &*plugin_module.content().file_content().await?; let FileContent::Content(file) = content else { bail!("Expected file content for plugin module"); diff --git a/packages/next-swc/crates/next-core/src/runtime.rs b/packages/next-swc/crates/next-core/src/runtime.rs index a1639324bfa90..65581b1be25bd 100644 --- a/packages/next-swc/crates/next-core/src/runtime.rs +++ b/packages/next-swc/crates/next-core/src/runtime.rs @@ -24,7 +24,7 @@ pub async fn resolve_runtime_request( OptionIssueSource::none(), IssueSeverity::Error.cell(), ) - .first_asset() + .first_module() .await? { if let Some(placeable) = diff --git a/packages/next-swc/crates/next-core/src/util.rs b/packages/next-swc/crates/next-core/src/util.rs index b62becd7e236e..9dcb8900b3c34 100644 --- a/packages/next-swc/crates/next-core/src/util.rs +++ b/packages/next-swc/crates/next-core/src/util.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Context, Result}; +use anyhow::{bail, Result}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde_json::Value as JsonValue; use swc_core::ecma::ast::Program; @@ -13,12 +13,7 @@ use turbopack_binding::{ issue::{Issue, IssueExt, IssueSeverity, OptionIssueSource}, module::Module, reference_type::{EcmaScriptModulesReferenceSubType, ReferenceType}, - resolve::{ - handle_resolve_error, - node::node_cjs_resolve_options, - parse::Request, - PrimaryResolveResult, {self}, - }, + resolve::{self, handle_resolve_error, node::node_cjs_resolve_options, parse::Request}, }, ecmascript::{ analyzer::{JsValue, ObjectPart}, @@ -228,15 +223,12 @@ pub async fn parse_config_from_source(module: Vc>) -> Result>, - value: &JsValue, -) -> NextSourceConfig { +fn parse_config_from_js_value(module: Vc>, value: &JsValue) -> NextSourceConfig { let mut config = NextSourceConfig::default(); let invalid_config = |detail: &str, value: &JsValue| { let (explainer, hints) = value.explain(2, 0); NextSourceConfigParsingIssue { - ident: module_asset.ident(), + ident: module.ident(), detail: Vc::cell(format!("{detail} Got {explainer}.{hints}")), } .cell() @@ -342,7 +334,7 @@ pub async fn load_next_json( let resolve_options = node_cjs_resolve_options(context.root()); let resolve_result = handle_resolve_error( - resolve::resolve(context, request, resolve_options), + resolve::resolve(context, request, resolve_options).as_raw_module_result(), Value::new(ReferenceType::EcmaScriptModules( EcmaScriptModulesReferenceSubType::Undefined, )), @@ -353,15 +345,8 @@ pub async fn load_next_json( IssueSeverity::Error.cell(), ) .await?; - let resolve_result = &*resolve_result.await?; - - let primary = resolve_result - .primary - .first() - .context("Unable to resolve primary asset")?; - - let PrimaryResolveResult::Asset(metrics_asset) = primary else { - bail!("Expected to find asset"); + let Some(metrics_asset) = *resolve_result.first_module().await? else { + bail!("Expected to find module"); }; let content = &*metrics_asset.content().file_content().await?; diff --git a/packages/next-swc/crates/next-core/src/web_entry_source.rs b/packages/next-swc/crates/next-core/src/web_entry_source.rs index c6278f41d1116..7bd7244e68671 100644 --- a/packages/next-swc/crates/next-core/src/web_entry_source.rs +++ b/packages/next-swc/crates/next-core/src/web_entry_source.rs @@ -201,7 +201,7 @@ pub async fn create_web_entry_source( let ty = Value::new(ReferenceType::Entry(EntryReferenceSubType::Web)); Ok(origin .resolve_asset(request, origin.resolve_options(ty.clone()), ty) - .primary_assets() + .primary_modules() .await? .first() .copied()) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1b3263c7a441a..a5b5165a92a92 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -994,8 +994,8 @@ importers: '@types/react': 18.2.7 '@types/react-dom': 18.2.4 '@vercel/ncc': ^0.36.0 - '@vercel/turbopack-ecmascript-runtime': https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230721.3 - '@vercel/turbopack-node': https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230721.3 + '@vercel/turbopack-ecmascript-runtime': https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230721.4 + '@vercel/turbopack-node': https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230721.4 anser: ^2.1.1 css.escape: ^1.5.1 find-up: ^6.3.0 @@ -1007,8 +1007,8 @@ importers: stacktrace-parser: ^0.1.10 strip-ansi: ^7.0.1 dependencies: - '@vercel/turbopack-ecmascript-runtime': '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230721.3_react-refresh@0.12.0' - '@vercel/turbopack-node': '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230721.3' + '@vercel/turbopack-ecmascript-runtime': '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230721.4_react-refresh@0.12.0' + '@vercel/turbopack-node': '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230721.4' anser: 2.1.1 css.escape: 1.5.1 next: link:../../../../next @@ -25518,9 +25518,9 @@ packages: /zwitch/2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} - '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230721.3_react-refresh@0.12.0': - resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230721.3} - id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230721.3' + '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230721.4_react-refresh@0.12.0': + resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230721.4} + id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230721.4' name: '@vercel/turbopack-ecmascript-runtime' version: 0.0.0 dependencies: @@ -25531,8 +25531,8 @@ packages: - webpack dev: false - '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230721.3': - resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230721.3} + '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230721.4': + resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230721.4} name: '@vercel/turbopack-node' version: 0.0.0 dependencies: