Unverified Commit 6be8c590 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

app dir fixes (#48025)

### What?

* fix app dir chunking
* fix app dir 404s
* improve app dir performance
* rerender shadowportal on errors to re-add nextjs-portal to avoid empty
page
* inject polyfills before user code
* fix manifest generation

see also https://github.com/vercel/turbo/pull/4488

### Why?

App dir was very slow and lead to 404 errors

### How?

add included metadata to chunks to allow deduplicate chunk loads at
runtime
parent da8a82d6
This diff is collapsed.
...@@ -47,11 +47,11 @@ swc_emotion = { version = "0.29.10" } ...@@ -47,11 +47,11 @@ swc_emotion = { version = "0.29.10" }
testing = { version = "0.31.31" } testing = { version = "0.31.31" }
# Turbo crates # Turbo crates
turbo-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230414.4" } turbo-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230417.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-230414.4" } turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230417.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-230414.4" } turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230417.2" }
# General Deps # General Deps
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
"check": "tsc --noEmit" "check": "tsc --noEmit"
}, },
"dependencies": { "dependencies": {
"@vercel/turbopack-dev": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230414.4", "@vercel/turbopack-dev": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230417.2",
"@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230414.4", "@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230417.2",
"anser": "^2.1.1", "anser": "^2.1.1",
"css.escape": "^1.5.1", "css.escape": "^1.5.1",
"next": "*", "next": "*",
......
...@@ -23,9 +23,6 @@ import type { ...@@ -23,9 +23,6 @@ import type {
import type { RenderData } from 'types/turbopack' import type { RenderData } from 'types/turbopack'
import type { RenderOpts } from 'next/dist/server/app-render/types' import type { RenderOpts } from 'next/dist/server/app-render/types'
import 'next/dist/server/node-polyfill-fetch'
import 'next/dist/server/node-polyfill-web-streams'
import '../polyfill/async-local-storage'
import { renderToHTMLOrFlight } from 'next/dist/server/app-render/app-render' import { renderToHTMLOrFlight } from 'next/dist/server/app-render/app-render'
import { RSC_VARY_HEADER } from 'next/dist/client/components/app-router-headers' import { RSC_VARY_HEADER } from 'next/dist/client/components/app-router-headers'
import { ServerResponseShim } from '../internal/http' import { ServerResponseShim } from '../internal/http'
...@@ -127,7 +124,6 @@ type LoaderTree = [ ...@@ -127,7 +124,6 @@ type LoaderTree = [
] ]
async function runOperation(renderData: RenderData) { async function runOperation(renderData: RenderData) {
const layoutInfoChunks: Record<string, string[]> = {}
let tree: LoaderTree = LOADER_TREE let tree: LoaderTree = LOADER_TREE
const proxyMethodsForModule = ( const proxyMethodsForModule = (
...@@ -167,7 +163,7 @@ async function runOperation(renderData: RenderData) { ...@@ -167,7 +163,7 @@ async function runOperation(renderData: RenderData) {
id = key.slice(0, pos) id = key.slice(0, pos)
name = key.slice(pos + 1) name = key.slice(pos + 1)
} else { } else {
throw new Error('key need to be in format of ${file}#${name}') throw new Error('keys need to be formatted as {file}#{name}')
} }
return { return {
...@@ -203,19 +199,45 @@ async function runOperation(renderData: RenderData) { ...@@ -203,19 +199,45 @@ async function runOperation(renderData: RenderData) {
}, },
} }
} }
const availableModules = new Set()
const toPath = (chunk: ChunkData) =>
typeof chunk === 'string' ? chunk : chunk.path
/// determines if a chunk is needed based on the current available modules
const filterAvailable = (chunk: ChunkData) => {
if (typeof chunk === 'string') {
return true
} else {
let includedList = chunk.included || []
if (includedList.length === 0) {
return true
}
let needed = false
for (const item of includedList) {
if (!availableModules.has(item)) {
availableModules.add(item)
needed = true
}
}
return needed
}
}
const cssFilesProxyMethods = { const cssFilesProxyMethods = {
get(_target: any, prop: string) { get(_target: any, prop: string) {
const chunks = JSON.parse(prop) const cssChunks = JSON.parse(prop)
const cssChunks = chunks.filter((path: string) => path.endsWith('.css')) // TODO(WEB-856) subscribe to changes
return cssChunks return cssChunks.map(toPath)
}, },
} }
const cssImportProxyMethods = { const cssImportProxyMethods = {
get(_target: any, prop: string) { get(_target: any, prop: string) {
const chunks = JSON.parse(prop.replace(/\.js$/, '')) const cssChunks = JSON.parse(prop.replace(/\.js$/, ''))
// TODO(WEB-856) subscribe to changes
const cssChunks = chunks.filter((path: string) => path.endsWith('.css')) // This return value is passed to proxyMethodsNested for clientModules
return cssChunks.map((chunk: string) => JSON.stringify([chunk, [chunk]])) return cssChunks
.filter(filterAvailable)
.map(toPath)
.map((chunk: string) => JSON.stringify([chunk, [chunk]]))
}, },
} }
const manifest: ClientReferenceManifest = new Proxy({} as any, proxyMethods()) const manifest: ClientReferenceManifest = new Proxy({} as any, proxyMethods())
...@@ -241,10 +263,7 @@ async function runOperation(renderData: RenderData) { ...@@ -241,10 +263,7 @@ async function runOperation(renderData: RenderData) {
dev: true, dev: true,
buildManifest: { buildManifest: {
polyfillFiles: [], polyfillFiles: [],
rootMainFiles: Object.values(layoutInfoChunks) rootMainFiles: BOOTSTRAP.filter((path) => path.endsWith('.js')),
.flat()
.concat(BOOTSTRAP)
.filter((path) => path.endsWith('.js')),
devFiles: [], devFiles: [],
ampDevFiles: [], ampDevFiles: [],
lowPriorityFiles: [], lowPriorityFiles: [],
......
...@@ -13,10 +13,19 @@ import { subscribeToUpdate } from '@vercel/turbopack-dev/client/hmr-client' ...@@ -13,10 +13,19 @@ import { subscribeToUpdate } from '@vercel/turbopack-dev/client/hmr-client'
import * as _app from '@vercel/turbopack-next/pages/_app' import * as _app from '@vercel/turbopack-next/pages/_app'
import * as page from 'PAGE' import * as page from 'PAGE'
async function loadPageChunk(assetPrefix: string, chunkPath: string) { async function loadPageChunk(assetPrefix: string, chunkData: ChunkData) {
const fullPath = assetPrefix + chunkPath if (typeof chunkData === 'string') {
const fullPath = assetPrefix + chunkData
await __turbopack_load__(fullPath)
} else {
let fullChunkData = {
...chunkData,
path: assetPrefix + chunkData.path,
}
await __turbopack_load__(fullPath) await __turbopack_load__(fullChunkData)
}
} }
;(async () => { ;(async () => {
...@@ -43,8 +52,8 @@ async function loadPageChunk(assetPrefix: string, chunkPath: string) { ...@@ -43,8 +52,8 @@ async function loadPageChunk(assetPrefix: string, chunkPath: string) {
}) })
// for the page loader // for the page loader
window.__turbopack_load_page_chunks__ = (page, paths) => { window.__turbopack_load_page_chunks__ = (page, chunksData) => {
const chunkPromises = paths.map(loadPageChunk.bind(null, assetPrefix)) const chunkPromises = chunksData.map(loadPageChunk.bind(null, assetPrefix))
Promise.all(chunkPromises).catch((err) => Promise.all(chunkPromises).catch((err) =>
console.error('failed to load chunks for page ' + page, err) console.error('failed to load chunks for page ' + page, err)
......
...@@ -102,7 +102,9 @@ export default async function route( ...@@ -102,7 +102,9 @@ export default async function route(
routerRequest.rawHeaders routerRequest.rawHeaders
) )
const body = Buffer.concat(routerRequest.body.map((arr) => Buffer.from(arr))); const body = Buffer.concat(
routerRequest.body.map((arr) => Buffer.from(arr))
)
// Send the clientRequest, so the server parses everything. We can then pass // Send the clientRequest, so the server parses everything. We can then pass
// the serverRequest to Next.js to handle. // the serverRequest to Next.js to handle.
......
...@@ -346,7 +346,7 @@ function createNotFoundResponse(isDataReq: boolean): IpcOutgoingMessage { ...@@ -346,7 +346,7 @@ function createNotFoundResponse(isDataReq: boolean): IpcOutgoingMessage {
type ManifestItem = { type ManifestItem = {
id: string id: string
chunks: string[] chunks: ChunkData[]
} }
/** /**
...@@ -380,12 +380,13 @@ function createReactLoadableManifestProxy(): ReactLoadableManifest { ...@@ -380,12 +380,13 @@ function createReactLoadableManifestProxy(): ReactLoadableManifest {
return { return {
id, id,
files: chunks.map((chunk) => { files: chunks.map((chunk) => {
let path = typeof chunk === 'string' ? chunk : chunk.path
// Turbopack prefixes chunks with "_next/", but Next.js expects // Turbopack prefixes chunks with "_next/", but Next.js expects
// them to be relative to the build directory. // them to be relative to the build directory.
if (chunk.startsWith('_next/')) { if (path.startsWith('_next/')) {
return chunk.slice('_next/'.length) path = path.slice('_next/'.length)
} }
return chunk return path
}), }),
} }
}, },
......
...@@ -223,7 +223,12 @@ export default function ReactDevOverlay({ ...@@ -223,7 +223,12 @@ export default function ReactDevOverlay({
{children ?? null} {children ?? null}
</ErrorBoundary> </ErrorBoundary>
{isMounted ? ( {isMounted ? (
<ShadowPortal globalOverlay={globalOverlay}> <ShadowPortal
// setting key ensures that ShadowPortal is re-mounted when the error changes
// this is necessary as nextjs-portal need to be reinjected when we re-render <body>
key={'' + !state.reactError}
globalOverlay={globalOverlay}
>
<CssReset /> <CssReset />
<Base /> <Base />
<ComponentStyles /> <ComponentStyles />
......
...@@ -157,6 +157,7 @@ function isRuntimeWarning(error: ReadyRuntimeError) { ...@@ -157,6 +157,7 @@ function isRuntimeWarning(error: ReadyRuntimeError) {
'This Suspense boundary received an update before it finished hydrating.', 'This Suspense boundary received an update before it finished hydrating.',
'Hydration failed because the initial UI does not match what was rendered on the server.', 'Hydration failed because the initial UI does not match what was rendered on the server.',
'There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.', 'There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.',
'There was an error while hydrating this Suspense boundary. Switched to client rendering.',
].some((message) => error.error.message.includes(message)) ].some((message) => error.error.message.includes(message))
} }
......
import 'next/dist/server/node-polyfill-fetch'
import 'next/dist/server/node-polyfill-web-streams'
import 'next/dist/server/node-polyfill-headers'
import './async-local-storage'
;(globalThis as any).__NEXT_USE_UNDICI = true
declare global { declare global {
function __turbopack_require__(name: any): any; type ChunkData =
function __turbopack_load__(path: string): any; | string
function __webpack_require__(name: any): any; | {
var __webpack_public_path__: string | undefined; path: string
var __DEV_MIDDLEWARE_MATCHERS: any[]; included: (string | number)[]
excluded: (string | number)[]
}
function __turbopack_require__(name: any): any
function __turbopack_load__(path: ChunkData): any
function __webpack_require__(name: any): any
var __webpack_public_path__: string | undefined
var __DEV_MIDDLEWARE_MATCHERS: any[]
var __next_require__: (id: string) => any; var __next_require__: (id: string) => any
var __next_chunk_load__: (id: string) => Promise; var __next_chunk_load__: (id: string) => Promise
var __next_f: ( var __next_f: (
| [isBootStrap: 0] | [isBootStrap: 0]
| [isNotBootstrap: 1, responsePartial: string] | [isNotBootstrap: 1, responsePartial: string]
)[]; )[]
var next: { var next: {
version: string; version: string
appDir: boolean; appDir: boolean
}; }
function __turbopack_load_page_chunks__( function __turbopack_load_page_chunks__(
page: string, page: string,
paths: string[] paths: string[]
): unknown; ): unknown
var AsyncLocalStorage = class AsyncLocalStorage<T> { var AsyncLocalStorage = class AsyncLocalStorage<T> {
getStore(): T | undefined; getStore(): T | undefined
run<R, TArgs extends any[]>( run<R, TArgs extends any[]>(
store: T, store: T,
callback: (...args: TArgs) => R, callback: (...args: TArgs) => R,
...args: TArgs ...args: TArgs
): R; ): R
}; }
} }
export {}; export {}
...@@ -709,6 +709,12 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; ...@@ -709,6 +709,12 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}";
let mut result = let mut result =
RopeBuilder::from("import { IPC } from \"@vercel/turbopack-node/ipc/index\";\n"); RopeBuilder::from("import { IPC } from \"@vercel/turbopack-node/ipc/index\";\n");
let import_path = next_js_file_path("entry")
.await?
.get_relative_path_to(&*next_js_file_path("polyfill/app-polyfills.ts").await?)
.unwrap();
writeln!(result, "import \"{import_path}\";\n",)?;
for import in imports { for import in imports {
writeln!(result, "{import}")?; writeln!(result, "{import}")?;
} }
......
...@@ -17,7 +17,7 @@ use turbo_binding::{ ...@@ -17,7 +17,7 @@ use turbo_binding::{
}; };
use turbo_tasks::{ use turbo_tasks::{
graph::{GraphTraversal, NonDeterministic}, graph::{GraphTraversal, NonDeterministic},
primitives::{StringVc, StringsVc}, primitives::{StringReadRef, StringVc, StringsVc},
}; };
use crate::{ use crate::{
...@@ -43,16 +43,16 @@ impl DevManifestContentSourceVc { ...@@ -43,16 +43,16 @@ impl DevManifestContentSourceVc {
async fn content_source_to_pathname( async fn content_source_to_pathname(
content_source: ContentSourceVc, content_source: ContentSourceVc,
) -> Result<Option<String>> { ) -> Result<Option<StringReadRef>> {
// TODO This shouldn't use casts but an public api instead // TODO This shouldn't use casts but an public api instead
if let Some(api_source) = NodeApiContentSourceVc::resolve_from(content_source).await? { if let Some(api_source) = NodeApiContentSourceVc::resolve_from(content_source).await? {
return Ok(Some(format!("/{}", api_source.get_pathname().await?))); return Ok(Some(api_source.get_pathname().await?));
} }
if let Some(page_source) = if let Some(page_source) =
NodeRenderContentSourceVc::resolve_from(content_source).await? NodeRenderContentSourceVc::resolve_from(content_source).await?
{ {
return Ok(Some(format!("/{}", page_source.get_pathname().await?))); return Ok(Some(page_source.get_pathname().await?));
} }
Ok(None) Ok(None)
...@@ -64,7 +64,7 @@ impl DevManifestContentSourceVc { ...@@ -64,7 +64,7 @@ impl DevManifestContentSourceVc {
Ok(content_source.get_children().await?.clone_value()) Ok(content_source.get_children().await?.clone_value())
} }
let mut routes = GraphTraversal::<NonDeterministic<_>>::visit( let routes = GraphTraversal::<NonDeterministic<_>>::visit(
this.page_roots.iter().copied(), this.page_roots.iter().copied(),
get_content_source_children, get_content_source_children,
) )
...@@ -73,10 +73,12 @@ impl DevManifestContentSourceVc { ...@@ -73,10 +73,12 @@ impl DevManifestContentSourceVc {
.into_iter() .into_iter()
.map(content_source_to_pathname) .map(content_source_to_pathname)
.try_join() .try_join()
.await? .await?;
.into_iter() let mut routes = routes
.flatten() .into_iter()
.collect::<Vec<_>>(); .flatten()
.map(|s| s.to_string())
.collect::<Vec<_>>();
routes.sort_by_cached_key(|s| s.split('/').map(PageSortKey::from).collect::<Vec<_>>()); routes.sort_by_cached_key(|s| s.split('/').map(PageSortKey::from).collect::<Vec<_>>());
...@@ -112,7 +114,7 @@ impl DevManifestContentSourceVc { ...@@ -112,7 +114,7 @@ impl DevManifestContentSourceVc {
p, p,
vec![format!( vec![format!(
"_next/static/chunks/pages/{}", "_next/static/chunks/pages/{}",
get_asset_path_from_route(p.split_at(1).1, ".js") get_asset_path_from_route(p, ".js")
)], )],
) )
}) })
......
...@@ -17,6 +17,7 @@ use turbo_binding::{ ...@@ -17,6 +17,7 @@ use turbo_binding::{
ident::AssetIdentVc, ident::AssetIdentVc,
reference::AssetReferencesVc, reference::AssetReferencesVc,
}, },
dev::ChunkData,
ecmascript::{ ecmascript::{
chunk::{ chunk::{
EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkItemContentVc, EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkItemContentVc,
...@@ -141,18 +142,16 @@ impl EcmascriptChunkItem for WithChunksChunkItem { ...@@ -141,18 +142,16 @@ impl EcmascriptChunkItem for WithChunksChunkItem {
let chunks = self.inner.chunks().await?; let chunks = self.inner.chunks().await?;
let server_root = inner_chunking_context.output_root().await?; let server_root = inner_chunking_context.output_root().await?;
let mut client_chunks = Vec::new();
for chunk_path in chunks let chunks_data = chunks
.iter() .iter()
.map(|chunk| chunk.ident().path()) .map(|&chunk| ChunkData::from_asset(&server_root, chunk))
.try_join() .try_join()
.await? .await?
{ .into_iter()
if let Some(path) = server_root.get_path_to(&chunk_path) { .flatten()
client_chunks.push(serde_json::Value::String(path.to_string())); .collect::<Vec<_>>();
}
}
let module_id = &*inner let module_id = &*inner
.asset .asset
.as_chunk_item(inner_chunking_context) .as_chunk_item(inner_chunking_context)
...@@ -171,7 +170,7 @@ impl EcmascriptChunkItem for WithChunksChunkItem { ...@@ -171,7 +170,7 @@ impl EcmascriptChunkItem for WithChunksChunkItem {
const chunks = {:#}; const chunks = {:#};
"#, "#,
StringifyJs(&module_id), StringifyJs(&module_id),
StringifyJs(&client_chunks), StringifyJs(&chunks_data),
)?; )?;
Ok(EcmascriptChunkItemContent { Ok(EcmascriptChunkItemContent {
......
...@@ -12,9 +12,12 @@ use turbo_binding::{ ...@@ -12,9 +12,12 @@ use turbo_binding::{
ChunkingTypeOptionVc, ChunkingTypeOptionVc,
}, },
ident::AssetIdentVc, ident::AssetIdentVc,
reference::{AssetReference, AssetReferenceVc, AssetReferencesVc}, reference::{
AssetReference, AssetReferenceVc, AssetReferencesVc, SingleAssetReferenceVc,
},
resolve::{ResolveResult, ResolveResultVc}, resolve::{ResolveResult, ResolveResultVc},
}, },
dev::ChunkData,
turbopack::ecmascript::{ turbopack::ecmascript::{
chunk::{ chunk::{
EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkItemContentVc, EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkItemContentVc,
...@@ -26,7 +29,7 @@ use turbo_binding::{ ...@@ -26,7 +29,7 @@ use turbo_binding::{
}, },
}, },
}; };
use turbo_tasks::{primitives::StringVc, Value, ValueToString, ValueToStringVc}; use turbo_tasks::{primitives::StringVc, TryJoinIterExt, Value, ValueToString, ValueToStringVc};
#[turbo_tasks::function] #[turbo_tasks::function]
fn modifier() -> StringVc { fn modifier() -> StringVc {
...@@ -127,24 +130,14 @@ impl EcmascriptChunkItem for WithClientChunksChunkItem { ...@@ -127,24 +130,14 @@ impl EcmascriptChunkItem for WithClientChunksChunkItem {
.await?; .await?;
let server_root = inner.server_root.await?; let server_root = inner.server_root.await?;
let mut asset_paths = vec![]; let chunks_data = chunks
for chunk in chunks.iter() { .iter()
for reference in chunk.references().await?.iter() { .map(|&chunk| ChunkData::from_asset(&server_root, chunk))
let assets = &*reference.resolve_reference().primary_assets().await?; .try_join()
for asset in assets.iter() { .await?
asset_paths.push(asset.ident().path().await?); .into_iter()
} .flatten()
} .collect::<Vec<_>>();
asset_paths.push(chunk.ident().path().await?);
}
let mut client_chunks = Vec::new();
for asset_path in asset_paths {
if let Some(path) = server_root.get_path_to(&asset_path) {
client_chunks.push(path.to_string());
}
}
let module_id = inner.asset.as_chunk_item(self.context).id().await?; let module_id = inner.asset.as_chunk_item(self.context).id().await?;
Ok(EcmascriptChunkItemContent { Ok(EcmascriptChunkItemContent {
...@@ -159,7 +152,7 @@ impl EcmascriptChunkItem for WithClientChunksChunkItem { ...@@ -159,7 +152,7 @@ impl EcmascriptChunkItem for WithClientChunksChunkItem {
const chunks = {:#}; const chunks = {:#};
"#, "#,
StringifyJs(&module_id), StringifyJs(&module_id),
StringifyJs(&client_chunks), StringifyJs(&chunks_data),
) )
.into(), .into(),
..Default::default() ..Default::default()
...@@ -176,8 +169,29 @@ impl ChunkItem for WithClientChunksChunkItem { ...@@ -176,8 +169,29 @@ impl ChunkItem for WithClientChunksChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn references(&self) -> AssetReferencesVc { async fn references(&self) -> Result<AssetReferencesVc> {
self.inner.references() let inner = self.inner.await?;
let mut references = Vec::new();
references.push(
WithClientChunksAssetReference {
asset: inner.asset.into(),
}
.cell()
.into(),
);
let group = self
.context
.chunk_group(inner.asset.as_root_chunk(self.context.into()));
let server_root = inner.server_root.await?;
let chunks = group.await?;
let client_chunk = StringVc::cell("client chunk".to_string());
for &chunk in chunks.iter() {
let path = chunk.ident().path().await?;
if path.is_inside(&server_root) {
references.push(SingleAssetReferenceVc::new(chunk, client_chunk).into());
}
}
Ok(AssetReferencesVc::cell(references))
} }
} }
......
...@@ -14,6 +14,7 @@ use turbo_binding::{ ...@@ -14,6 +14,7 @@ use turbo_binding::{
reference_type::{EntryReferenceSubType, ReferenceType}, reference_type::{EntryReferenceSubType, ReferenceType},
virtual_asset::VirtualAssetVc, virtual_asset::VirtualAssetVc,
}, },
dev::ChunkData,
dev_server::source::{asset_graph::AssetGraphContentSourceVc, ContentSourceVc}, dev_server::source::{asset_graph::AssetGraphContentSourceVc, ContentSourceVc},
ecmascript::{ ecmascript::{
utils::StringifyJs, EcmascriptInputTransform, EcmascriptInputTransformsVc, utils::StringifyJs, EcmascriptInputTransform, EcmascriptInputTransformsVc,
...@@ -130,16 +131,9 @@ impl Asset for PageLoaderAsset { ...@@ -130,16 +131,9 @@ impl Asset for PageLoaderAsset {
let chunks = self_vc.get_page_chunks().await?; let chunks = self_vc.get_page_chunks().await?;
let server_root = this.server_root.await?; let server_root = this.server_root.await?;
let chunk_paths: Vec<_> = chunks let chunks_data: Vec<_> = chunks
.iter() .iter()
.map(|chunk| { .map(|&chunk| ChunkData::from_asset(&server_root, chunk))
let server_root = server_root.clone();
async move {
Ok(server_root
.get_path_to(&*chunk.ident().path().await?)
.map(|path| path.to_string()))
}
})
.try_join() .try_join()
.await? .await?
.into_iter() .into_iter()
...@@ -149,7 +143,7 @@ impl Asset for PageLoaderAsset { ...@@ -149,7 +143,7 @@ impl Asset for PageLoaderAsset {
let content = format!( let content = format!(
"__turbopack_load_page_chunks__({}, {:#})\n", "__turbopack_load_page_chunks__({}, {:#})\n",
StringifyJs(&this.pathname.await?), StringifyJs(&this.pathname.await?),
StringifyJs(&chunk_paths) StringifyJs(&chunks_data)
); );
Ok(AssetContentVc::from(File::from(content))) Ok(AssetContentVc::from(File::from(content)))
......
...@@ -153,9 +153,10 @@ fn test(resource: PathBuf) { ...@@ -153,9 +153,10 @@ fn test(resource: PathBuf) {
}; };
} }
#[testing::fixture("tests/integration/*/*/__skipped__/*")] #[testing::fixture("tests/integration/*/*/__skipped__/*/input")]
#[should_panic] #[should_panic]
fn test_skipped_fails(resource: PathBuf) { fn test_skipped_fails(resource: PathBuf) {
let resource = resource.parent().unwrap().to_path_buf();
let run_result = run_async_test(run_test(resource)); let run_result = run_async_test(run_test(resource));
// Assert that this skipped test itself has at least one browser test which // Assert that this skipped test itself has at least one browser test which
......
...@@ -1004,8 +1004,8 @@ importers: ...@@ -1004,8 +1004,8 @@ importers:
'@types/react': ^18.0.26 '@types/react': ^18.0.26
'@types/react-dom': ^18.0.9 '@types/react-dom': ^18.0.9
'@vercel/ncc': ^0.36.0 '@vercel/ncc': ^0.36.0
'@vercel/turbopack-dev': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230414.4 '@vercel/turbopack-dev': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230417.2
'@vercel/turbopack-node': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230414.4 '@vercel/turbopack-node': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230417.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
...@@ -1017,8 +1017,8 @@ importers: ...@@ -1017,8 +1017,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-dev': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230414.4_react-refresh@0.12.0' '@vercel/turbopack-dev': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230417.2_react-refresh@0.12.0'
'@vercel/turbopack-node': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230414.4' '@vercel/turbopack-node': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230417.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
...@@ -5978,7 +5978,7 @@ packages: ...@@ -5978,7 +5978,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.74.0 webpack: 5.74.0_@swc+core@1.2.203
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -6644,7 +6644,6 @@ packages: ...@@ -6644,7 +6644,6 @@ packages:
cpu: [arm] cpu: [arm]
os: [android] os: [android]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-android-arm64/1.2.203: /@swc/core-android-arm64/1.2.203:
...@@ -6653,7 +6652,6 @@ packages: ...@@ -6653,7 +6652,6 @@ packages:
cpu: [arm64] cpu: [arm64]
os: [android] os: [android]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-darwin-arm64/1.2.203: /@swc/core-darwin-arm64/1.2.203:
...@@ -6662,7 +6660,6 @@ packages: ...@@ -6662,7 +6660,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.2.203: /@swc/core-darwin-x64/1.2.203:
...@@ -6671,7 +6668,6 @@ packages: ...@@ -6671,7 +6668,6 @@ packages:
cpu: [x64] cpu: [x64]
os: [darwin] os: [darwin]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-freebsd-x64/1.2.203: /@swc/core-freebsd-x64/1.2.203:
...@@ -6680,7 +6676,6 @@ packages: ...@@ -6680,7 +6676,6 @@ packages:
cpu: [x64] cpu: [x64]
os: [freebsd] os: [freebsd]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-linux-arm-gnueabihf/1.2.203: /@swc/core-linux-arm-gnueabihf/1.2.203:
...@@ -6689,7 +6684,6 @@ packages: ...@@ -6689,7 +6684,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.2.203: /@swc/core-linux-arm64-gnu/1.2.203:
...@@ -6698,7 +6692,6 @@ packages: ...@@ -6698,7 +6692,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.2.203: /@swc/core-linux-arm64-musl/1.2.203:
...@@ -6707,7 +6700,6 @@ packages: ...@@ -6707,7 +6700,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.2.203: /@swc/core-linux-x64-gnu/1.2.203:
...@@ -6716,7 +6708,6 @@ packages: ...@@ -6716,7 +6708,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.2.203: /@swc/core-linux-x64-musl/1.2.203:
...@@ -6725,7 +6716,6 @@ packages: ...@@ -6725,7 +6716,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.2.203: /@swc/core-win32-arm64-msvc/1.2.203:
...@@ -6734,7 +6724,6 @@ packages: ...@@ -6734,7 +6724,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.2.203: /@swc/core-win32-ia32-msvc/1.2.203:
...@@ -6743,7 +6732,6 @@ packages: ...@@ -6743,7 +6732,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.2.203: /@swc/core-win32-x64-msvc/1.2.203:
...@@ -6752,7 +6740,6 @@ packages: ...@@ -6752,7 +6740,6 @@ packages:
cpu: [x64] cpu: [x64]
os: [win32] os: [win32]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core/1.2.203: /@swc/core/1.2.203:
...@@ -6773,7 +6760,6 @@ packages: ...@@ -6773,7 +6760,6 @@ packages:
'@swc/core-win32-arm64-msvc': 1.2.203 '@swc/core-win32-arm64-msvc': 1.2.203
'@swc/core-win32-ia32-msvc': 1.2.203 '@swc/core-win32-ia32-msvc': 1.2.203
'@swc/core-win32-x64-msvc': 1.2.203 '@swc/core-win32-x64-msvc': 1.2.203
dev: true
/@swc/helpers/0.4.11: /@swc/helpers/0.4.11:
resolution: {integrity: sha512-rEUrBSGIoSFuYxwBYtlUFMlE2CwGhmW+w9355/5oduSw8e5h2+Tj4UrAGNNgP9915++wj5vkQo0UuOBqOAq4nw==} resolution: {integrity: sha512-rEUrBSGIoSFuYxwBYtlUFMlE2CwGhmW+w9355/5oduSw8e5h2+Tj4UrAGNNgP9915++wj5vkQo0UuOBqOAq4nw==}
...@@ -23747,7 +23733,6 @@ packages: ...@@ -23747,7 +23733,6 @@ packages:
source-map: 0.6.1 source-map: 0.6.1
terser: 5.14.1 terser: 5.14.1
webpack: 5.74.0_@swc+core@1.2.203 webpack: 5.74.0_@swc+core@1.2.203
dev: true
/terser-webpack-plugin/5.2.4_webpack@5.74.0: /terser-webpack-plugin/5.2.4_webpack@5.74.0:
resolution: {integrity: sha512-E2CkNMN+1cho04YpdANyRrn8CyN4yMy+WdFKZIySFZrGXZxJwJP6PMNGGc/Mcr6qygQHUUqRxnAPmi0M9f00XA==} resolution: {integrity: sha512-E2CkNMN+1cho04YpdANyRrn8CyN4yMy+WdFKZIySFZrGXZxJwJP6PMNGGc/Mcr6qygQHUUqRxnAPmi0M9f00XA==}
...@@ -25153,7 +25138,6 @@ packages: ...@@ -25153,7 +25138,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==}
...@@ -25551,9 +25535,9 @@ packages: ...@@ -25551,9 +25535,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.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230414.4_react-refresh@0.12.0': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230417.2_react-refresh@0.12.0':
resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230414.4} resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230417.2}
id: '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230414.4' id: '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230417.2'
name: '@vercel/turbopack-dev' name: '@vercel/turbopack-dev'
version: 0.0.0 version: 0.0.0
dependencies: dependencies:
...@@ -25563,8 +25547,8 @@ packages: ...@@ -25563,8 +25547,8 @@ packages:
- webpack - webpack
dev: false dev: false
'@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230414.4': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230417.2':
resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230414.4} resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230417.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