Unverified Commit 26ef468d authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

test: add monorepo fixture to Turbopack build cache portability test

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 5fc17bbd
'use server'
export async function increment(count) {
return count + 1
}
'use client'
import { useState } from 'react'
import { increment } from './actions'
export function Counter() {
const [count, setCount] = useState(0)
return (
<button onClick={async () => setCount(await increment(count))}>
count {count}
</button>
)
}
import { Counter } from './counter'
export default function ActionPage() {
return <Counter />
}
export function GET() {
return Response.json({ hello: 'world' })
}
export function generateStaticParams() {
return [{ slug: 'first' }, { slug: 'second' }]
}
export default async function BlogPost({ params }) {
const { slug } = await params
return <p>blog post {slug}</p>
}
export default function Root({ children }) {
return (
<html>
<body>{children}</body>
</html>
)
}
import { Button } from '@portable/ui/button'
import { markers } from '../lib/markers'
export default function Page() {
return (
<>
<ul>
{markers.map((marker) => (
<li key={marker}>{marker}</li>
))}
</ul>
<Button />
</>
)
}
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@shared/*": ["../../packages/shared/*"]
}
}
}
import { loaderMarker } from './loaded.marker.js'
import { resolveAliasMarker } from 'resolve-alias-target'
// Resolved through the `paths` alias in `jsconfig.json`, outside of the app.
import { jsconfigPathsMarker } from '@shared/paths-target.js'
// `linked` is a relative symlink to `packages/shared`, created by the test.
import { symlinkMarker } from '../linked/symlink-target.js'
// `node_modules/@portable/ui` is a relative workspace symlink to `packages/ui`.
import { workspaceMarker } from '@portable/ui'
export const markers = [
loaderMarker,
resolveAliasMarker,
jsconfigPathsMarker,
symlinkMarker,
workspaceMarker,
]
// Replaces the placeholder in `*.marker.js` modules, so the build output proves
// that the loader ran.
module.exports = function markerLoader(source) {
return source.replace('__LOADER_PLACEHOLDER__', 'loader-applied')
}
const path = require('path')
// The workspace root (two levels up) is the project root, so that the shared
// packages outside of the app directory are part of the build.
const workspaceRoot = path.join(__dirname, '..', '..')
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
outputFileTracingRoot: workspaceRoot,
transpilePackages: ['@portable/ui'],
turbopack: {
root: workspaceRoot,
resolveAlias: {
'resolve-alias-target': './lib/resolve-alias-target.js',
},
rules: {
'*.marker.js': {
loaders: ['./loaders/marker-loader.js'],
as: '*.js',
},
},
},
}
module.exports = nextConfig
export default function handler(req, res) {
res.status(200).json({ router: 'pages' })
}
export default function LegacyPage() {
return <p>pages router</p>
}
import { NextResponse } from 'next/server'
export function proxy() {
const response = NextResponse.next()
response.headers.set('x-portable-proxy', '1')
return response
}
export const config = {
matcher: '/api/:path*',
}
{
"name": "portable-monorepo",
"version": "1.0.0",
"private": true
}
'use client'
import { useState } from 'react'
export function Button() {
const [clicked, setClicked] = useState(false)
return (
<button onClick={() => setClicked(true)}>
{clicked ? 'clicked' : 'client component'}
</button>
)
}
export const workspaceMarker = 'workspace-package-resolved'
{
"name": "@portable/ui",
"version": "1.0.0",
"private": true,
"exports": {
".": "./index.js",
"./button": "./button.jsx"
}
}
import { nextTestSetup } from 'e2e-utils'
import { FileRef, nextTestSetup } from 'e2e-utils'
import fs from 'fs/promises'
import path from 'path'
import { getPnpmRealpathWorkaround } from '../../../lib/pnpm-realpath-workaround'
......@@ -30,255 +30,414 @@ import {
// @force-gate turbopack
// @force-gate start
describe('turbopack-portable-build-cache', () => {
const { next } = nextTestSetup({
files: path.join(__dirname, 'fixtures/minimal'),
overrideFiles: getPnpmRealpathWorkaround(),
skipStart: true,
describe('minimal app', () => {
const { next } = nextTestSetup({
files: path.join(__dirname, 'fixtures/minimal'),
overrideFiles: getPnpmRealpathWorkaround(),
skipStart: true,
})
it('reuses the build cache after moving the project', async () => {
const coldExecutions = (await tracedBuild(next)).executions
// Sanity check that the trace contains task executions at all, so empty
// snapshots below mean "fully cached", not "nothing was traced".
expect(coldExecutions.length).toBeGreaterThan(10_000)
const sameDirExecutions = (await tracedBuild(next)).executions
expect(executedFunctionNames(sameDirExecutions)).toMatchInlineSnapshot(`
[
"<DiskFileSystem as FileSystem>::raw_read_dir",
"<DiskFileSystem as FileSystem>::read",
"<DiskFileSystem as FileSystem>::read_link",
"ProjectContainer::project",
"emit_all_output_assets_once_with_issues_operation",
"get_all_written_entrypoints_with_issues_operation",
"project_root_path_operation",
"uppercase_env_map",
]
`)
await moveProject(next, next.testDir)
const movedExecutions = (await tracedBuild(next)).executions
expect(executedFunctionNames(movedExecutions)).toMatchInlineSnapshot(`
[
"<DiskFileSystem as FileSystem>::raw_read_dir",
"<DiskFileSystem as FileSystem>::read",
"<DiskFileSystem as FileSystem>::read_link",
"<DiskFileSystem as FileSystem>::write",
"<DiskFileSystem as turbo_tasks :: ValueToString>::to_string",
"<NftJsonAsset as Asset>::content",
"<ServerNftJsonAsset as Asset>::content",
"DiskFileSystem::new_internal",
"NextConfig::asset_suffix_path",
"NextConfig::base_path",
"NextConfig::bundle_pages_router_dependencies",
"NextConfig::cache_handler",
"NextConfig::cache_handlers",
"NextConfig::cache_kinds",
"NextConfig::client_source_maps",
"NextConfig::client_static_folder_name",
"NextConfig::compiler",
"NextConfig::computed_asset_prefix",
"NextConfig::config_file_path",
"NextConfig::cross_origin",
"NextConfig::css_chunking",
"NextConfig::dist_dir",
"NextConfig::dist_dir_root",
"NextConfig::enable_cache_components",
"NextConfig::enable_concurrent_router_queue",
"NextConfig::enable_durable_use_cache_entries",
"NextConfig::enable_expose_testing_api_in_production_build",
"NextConfig::enable_immutable_assets",
"NextConfig::enable_react_production_profiling",
"NextConfig::enable_taint",
"NextConfig::enable_use_cache",
"NextConfig::experimental_sri",
"NextConfig::experimental_swc_env_options",
"NextConfig::experimental_swc_plugins",
"NextConfig::experimental_turbopack_local_postcss_config",
"NextConfig::experimental_turbopack_use_builtin_babel",
"NextConfig::experimental_turbopack_use_builtin_sass",
"NextConfig::explicit_parallel_route_children",
"NextConfig::from_string",
"NextConfig::image_config",
"NextConfig::import_externals",
"NextConfig::inline_css",
"NextConfig::instrumentation_client_inject",
"NextConfig::is_global_not_found_enabled",
"NextConfig::is_standalone",
"NextConfig::is_using_adapter",
"NextConfig::lightningcss_feature_flags",
"NextConfig::mdx_rs",
"NextConfig::modularize_imports",
"NextConfig::module_fragments_enabled_for_foreign_code",
"NextConfig::module_fragments_enabled_for_user_code",
"NextConfig::module_ids",
"NextConfig::optimize_package_imports",
"NextConfig::output",
"NextConfig::output_file_tracing_excludes",
"NextConfig::output_file_tracing_includes",
"NextConfig::output_hash_salt",
"NextConfig::page_extensions",
"NextConfig::react_compiler_options",
"NextConfig::report_system_env_inlining",
"NextConfig::resolve_alias_options",
"NextConfig::resolve_extension",
"NextConfig::rust_react_compiler",
"NextConfig::sass_config",
"NextConfig::server_external_packages",
"NextConfig::server_source_maps",
"NextConfig::should_append_server_deployment_id_at_runtime",
"NextConfig::skip_proxy_url_normalize",
"NextConfig::skip_trailing_slash_redirect",
"NextConfig::strict_route_matching",
"NextConfig::transpile_packages",
"NextConfig::turbo_client_minify",
"NextConfig::turbo_nested_async_chunking",
"NextConfig::turbo_scope_hoisting",
"NextConfig::turbo_server_minify",
"NextConfig::turbo_shared_runtime",
"NextConfig::turbopack_chunk_loading_global",
"NextConfig::turbopack_chunking",
"NextConfig::turbopack_cjs_scope_hoisting",
"NextConfig::turbopack_cjs_tree_shaking",
"NextConfig::turbopack_cross_module_constants",
"NextConfig::turbopack_debug_ids",
"NextConfig::turbopack_generate_component_chunks",
"NextConfig::turbopack_ignore_issue_rules",
"NextConfig::turbopack_import_type_bytes",
"NextConfig::turbopack_infer_module_side_effects",
"NextConfig::turbopack_lazy_dynamic_imports",
"NextConfig::turbopack_lazy_dynamic_imports_ssr",
"NextConfig::turbopack_mangle_export_names",
"NextConfig::turbopack_mangle_via_materialized_namespace_object",
"NextConfig::turbopack_plugin_runtime_strategy",
"NextConfig::turbopack_remove_unused_exports",
"NextConfig::turbopack_remove_unused_imports",
"NextConfig::turbopack_worker_asset_prefix",
"NextConfig::typescript_tsconfig_path",
"NextConfig::use_react_experimental",
"NextConfig::webpack_rules",
"ProjectContainer::project",
"emit_all_output_assets_once_with_issues_operation",
"get_all_written_entrypoints_with_issues_operation",
"inner_entrypoints_without_collectibles_operation",
"project_root_path_operation",
"uppercase_env_map",
]
`)
}, 600_000)
})
const env = {
NEXT_TURBOPACK_TRACING: 'turbo-tasks',
// Persist even tiny snapshots so the test doesn't depend on the
// minimum-compilation-time threshold.
TURBO_ENGINE_IGNORE_DIRTY: '1',
TURBO_ENGINE_SNAPSHOT_MIN_ACTIVE_TIME_MILLIS: '0',
}
// A monorepo combining the features that interact with the project location:
//
// <workspace root>/ the project root (`turbopack.root`), moved as a whole
// ├── apps/web/ the Next.js app (`next.testDir`)
// │ ├── app/ static, dynamic, route handler, server action,
// │ │ client component routes
// │ ├── pages/ pages router page and API route
// │ ├── proxy.js
// │ ├── loaders/ webpack loader, applied via `turbopack.rules`
// │ ├── lib/ `turbopack.resolveAlias` target
// │ ├── jsconfig.json `paths` alias into `packages/shared`
// │ ├── linked → ../../packages/shared (relative symlink)
// │ └── node_modules/@portable/ui → …/packages/ui (workspace symlink)
// └── packages/
// ├── shared/
// └── ui/ workspace package with a client component
describe('monorepo with all features', () => {
const fixture = path.join(__dirname, 'fixtures/monorepo')
const { next } = nextTestSetup({
files: {
'.': new FileRef(path.join(fixture, 'apps/web')),
'../../package.json': new FileRef(path.join(fixture, 'package.json')),
'../../packages': new FileRef(path.join(fixture, 'packages')),
},
subDir: 'apps/web',
overrideFiles: getPnpmRealpathWorkaround(),
skipStart: true,
})
async function tracedBuild(): Promise<TaskExecution[]> {
const { exitCode, cliOutput } = await next.build({ env })
if (exitCode !== 0) {
throw new Error(`next build exited with ${exitCode}:\n${cliOutput}`)
}
return readTaskExecutions(
path.join(next.testDir, '.next-profiles', 'trace-turbopack.bin')
)
}
/** The isolated workspace root, two levels above the app. */
const workspaceRoot = () => path.join(next.testDir, '..', '..')
/** Move the project, including its `.next` cache, to a new directory. */
async function moveProject() {
const from = next.testDir
const to = `${from}-moved`
await fs.rename(from, to)
// The harness runs builds in and cleans up `next.testDir`.
next.testDir = to
}
beforeAll(async () => {
// The symlinks are created here with relative targets, so they still
// resolve after the move.
await fs.symlink(
path.join('..', '..', 'packages', 'shared'),
path.join(next.testDir, 'linked'),
'dir'
)
const scope = path.join(next.testDir, 'node_modules', '@portable')
await fs.mkdir(scope, { recursive: true })
await fs.symlink(
path.join('..', '..', '..', '..', 'packages', 'ui'),
path.join(scope, 'ui'),
'dir'
)
})
afterAll(async () => {
// The harness only removes `next.testDir` (the app), not the workspace
// around it.
if (!process.env.NEXT_TEST_SKIP_CLEANUP) {
await fs.rm(workspaceRoot(), { recursive: true, force: true })
}
})
it('reuses the build cache after moving the project', async () => {
const coldExecutions = await tracedBuild()
// Sanity check that the trace contains task executions at all, so empty
// snapshots below mean "fully cached", not "nothing was traced".
expect(coldExecutions.length).toBeGreaterThan(10_000)
/** Checks that every feature of the fixture is part of the build. */
async function expectAllFeatures(cliOutput: string) {
for (const route of [
'/action',
'/api/hello',
'/blog/[slug]',
'/blog/first',
'/api/legacy',
'/legacy',
'Proxy',
]) {
expect(cliOutput).toContain(route)
}
const html = await next.readFile('.next/server/app/index.html')
for (const marker of [
'loader-applied',
'resolve-alias-applied',
'jsconfig-paths-applied',
'symlink-resolved',
'workspace-package-resolved',
'client component',
]) {
expect(html).toContain(marker)
}
const serverActions = JSON.parse(
await next.readFile('.next/server/server-reference-manifest.json')
)
expect(Object.keys(serverActions.node).length).toBeGreaterThan(0)
}
it('reuses the build cache after moving the project', async () => {
const cold = await tracedBuild(next)
await expectAllFeatures(cold.cliOutput)
// Sanity check that the trace contains task executions at all, so empty
// snapshots below mean "fully cached", not "nothing was traced".
expect(cold.executions.length).toBeGreaterThan(10_000)
const sameDirExecutions = await tracedBuild()
expect(executedFunctionNames(sameDirExecutions)).toMatchInlineSnapshot(`
[
"<DiskFileSystem as FileSystem>::raw_read_dir",
"<DiskFileSystem as FileSystem>::read",
"<DiskFileSystem as FileSystem>::read_link",
"<NftJsonAsset as Asset>::content",
"<ServerNftJsonAsset as Asset>::content",
"<SourceMapReference as GenerateSourceMap>::generate_source_map",
"EcmascriptClientReferenceModule::proxy_module",
"EcmascriptModuleContent::new",
"EcmascriptModuleContent::new_merged",
"Environment::runtime_versions",
"NodeJsEnvironment::runtime_versions",
"Project::ci_has_next_support",
"Project::client_compile_time_info",
"Project::current_node_js_version",
"Project::deferred_entries",
"Project::edge_compile_time_info",
"Project::emit_all_output_assets",
"Project::encryption_key",
"Project::entrypoints_with_app_route_filter",
"Project::env",
"Project::is_watch_enabled",
"Project::next_config",
"Project::next_mode",
"Project::no_mangling",
"Project::node_root",
"Project::output_fs",
"Project::per_page_module_graph",
"Project::project_fs",
"Project::project_path",
"Project::server_compile_time_info",
"Project::should_write_nft_manifests",
"Project::should_write_routes_hashes_manifest",
"ProjectContainer::project",
"analyze_ecmascript_module",
"client_directive_transform_plugin",
"compute_ecmascript_module_exports",
"compute_ecmascript_module_side_effects",
"emit_all_output_assets_once_with_issues_operation",
"get_all_written_entrypoints_with_issues_operation",
"lint_transform_plugin",
"modularize_imports_transform_plugin",
"next_cjs_optimizer_transform_plugin",
"next_debug_instant_stack_transform_plugin",
"next_dynamic_transform_plugin",
"next_font_transform_plugin",
"next_pure_transform_plugin",
"next_react_server_components_transform_plugin",
"next_server_actions_transform_plugin",
"parse",
"parse_actions",
"project_root_path_operation",
"styled_jsx_transform_plugin",
"uppercase_env_map",
]
`)
const sameDir = await tracedBuild(next)
expect(executedFunctionNames(sameDir.executions)).toMatchInlineSnapshot(`
[
"<DiskFileSystem as FileSystem>::raw_read_dir",
"<DiskFileSystem as FileSystem>::read",
"<DiskFileSystem as FileSystem>::read_link",
"<EnvMap as ProcessEnv>::read_all",
"ProjectContainer::project",
"common_node_env",
"create_evaluate_pool_assets_operation",
"emit_all_output_assets_once_with_issues_operation",
"get_all_written_entrypoints_with_issues_operation",
"project_root_path_operation",
"uppercase_env_map",
]
`)
await moveProject()
const movedExecutions = await tracedBuild()
expect(executedFunctionNames(movedExecutions)).toMatchInlineSnapshot(`
[
"<DiskFileSystem as FileSystem>::raw_read_dir",
"<DiskFileSystem as FileSystem>::read",
"<DiskFileSystem as FileSystem>::read_link",
"<DiskFileSystem as FileSystem>::write",
"<DiskFileSystem as turbo_tasks :: ValueToString>::to_string",
"<NftJsonAsset as Asset>::content",
"<ServerNftJsonAsset as Asset>::content",
"<SourceMapReference as GenerateSourceMap>::generate_source_map",
"DiskFileSystem::new_internal",
"EcmascriptClientReferenceModule::proxy_module",
"EcmascriptModuleContent::new",
"EcmascriptModuleContent::new_merged",
"Environment::runtime_versions",
"NextConfig::asset_suffix_path",
"NextConfig::base_path",
"NextConfig::bundle_pages_router_dependencies",
"NextConfig::cache_handler",
"NextConfig::cache_handlers",
"NextConfig::cache_kinds",
"NextConfig::client_source_maps",
"NextConfig::client_static_folder_name",
"NextConfig::compiler",
"NextConfig::computed_asset_prefix",
"NextConfig::config_file_path",
"NextConfig::cross_origin",
"NextConfig::css_chunking",
"NextConfig::dist_dir",
"NextConfig::dist_dir_root",
"NextConfig::enable_cache_components",
"NextConfig::enable_concurrent_router_queue",
"NextConfig::enable_durable_use_cache_entries",
"NextConfig::enable_expose_testing_api_in_production_build",
"NextConfig::enable_immutable_assets",
"NextConfig::enable_react_production_profiling",
"NextConfig::enable_taint",
"NextConfig::enable_use_cache",
"NextConfig::experimental_sri",
"NextConfig::experimental_swc_env_options",
"NextConfig::experimental_swc_plugins",
"NextConfig::experimental_turbopack_local_postcss_config",
"NextConfig::experimental_turbopack_use_builtin_babel",
"NextConfig::experimental_turbopack_use_builtin_sass",
"NextConfig::explicit_parallel_route_children",
"NextConfig::from_string",
"NextConfig::image_config",
"NextConfig::import_externals",
"NextConfig::inline_css",
"NextConfig::instrumentation_client_inject",
"NextConfig::is_global_not_found_enabled",
"NextConfig::is_standalone",
"NextConfig::is_using_adapter",
"NextConfig::lightningcss_feature_flags",
"NextConfig::mdx_rs",
"NextConfig::modularize_imports",
"NextConfig::module_fragments_enabled_for_foreign_code",
"NextConfig::module_fragments_enabled_for_user_code",
"NextConfig::module_ids",
"NextConfig::optimize_package_imports",
"NextConfig::output",
"NextConfig::output_file_tracing_excludes",
"NextConfig::output_file_tracing_includes",
"NextConfig::output_hash_salt",
"NextConfig::page_extensions",
"NextConfig::react_compiler_options",
"NextConfig::report_system_env_inlining",
"NextConfig::resolve_alias_options",
"NextConfig::resolve_extension",
"NextConfig::rust_react_compiler",
"NextConfig::sass_config",
"NextConfig::server_external_packages",
"NextConfig::server_source_maps",
"NextConfig::should_append_server_deployment_id_at_runtime",
"NextConfig::skip_proxy_url_normalize",
"NextConfig::skip_trailing_slash_redirect",
"NextConfig::strict_route_matching",
"NextConfig::transpile_packages",
"NextConfig::turbo_client_minify",
"NextConfig::turbo_nested_async_chunking",
"NextConfig::turbo_scope_hoisting",
"NextConfig::turbo_server_minify",
"NextConfig::turbo_shared_runtime",
"NextConfig::turbopack_chunk_loading_global",
"NextConfig::turbopack_chunking",
"NextConfig::turbopack_cjs_scope_hoisting",
"NextConfig::turbopack_cjs_tree_shaking",
"NextConfig::turbopack_cross_module_constants",
"NextConfig::turbopack_debug_ids",
"NextConfig::turbopack_generate_component_chunks",
"NextConfig::turbopack_ignore_issue_rules",
"NextConfig::turbopack_import_type_bytes",
"NextConfig::turbopack_infer_module_side_effects",
"NextConfig::turbopack_lazy_dynamic_imports",
"NextConfig::turbopack_lazy_dynamic_imports_ssr",
"NextConfig::turbopack_mangle_export_names",
"NextConfig::turbopack_mangle_via_materialized_namespace_object",
"NextConfig::turbopack_plugin_runtime_strategy",
"NextConfig::turbopack_remove_unused_exports",
"NextConfig::turbopack_remove_unused_imports",
"NextConfig::turbopack_worker_asset_prefix",
"NextConfig::typescript_tsconfig_path",
"NextConfig::use_react_experimental",
"NextConfig::webpack_rules",
"NodeJsEnvironment::runtime_versions",
"Project::ci_has_next_support",
"Project::client_compile_time_info",
"Project::current_node_js_version",
"Project::deferred_entries",
"Project::edge_compile_time_info",
"Project::emit_all_output_assets",
"Project::encryption_key",
"Project::entrypoints_with_app_route_filter",
"Project::env",
"Project::is_watch_enabled",
"Project::next_config",
"Project::next_mode",
"Project::no_mangling",
"Project::node_root",
"Project::output_fs",
"Project::per_page_module_graph",
"Project::project_fs",
"Project::project_path",
"Project::server_compile_time_info",
"Project::should_write_nft_manifests",
"Project::should_write_routes_hashes_manifest",
"ProjectContainer::project",
"analyze_ecmascript_module",
"client_directive_transform_plugin",
"compute_ecmascript_module_exports",
"compute_ecmascript_module_side_effects",
"emit_all_output_assets_once_with_issues_operation",
"get_all_written_entrypoints_with_issues_operation",
"inner_entrypoints_without_collectibles_operation",
"lint_transform_plugin",
"modularize_imports_transform_plugin",
"next_cjs_optimizer_transform_plugin",
"next_debug_instant_stack_transform_plugin",
"next_dynamic_transform_plugin",
"next_font_transform_plugin",
"next_pure_transform_plugin",
"next_react_server_components_transform_plugin",
"next_server_actions_transform_plugin",
"parse",
"parse_actions",
"project_root_path_operation",
"styled_jsx_transform_plugin",
"uppercase_env_map",
]
`)
}, 600_000)
await moveProject(next, workspaceRoot())
const moved = await tracedBuild(next)
await expectAllFeatures(moved.cliOutput)
expect(executedFunctionNames(moved.executions)).toMatchInlineSnapshot(`
[
"<DiskFileSystem as FileSystem>::raw_read_dir",
"<DiskFileSystem as FileSystem>::read",
"<DiskFileSystem as FileSystem>::read_link",
"<DiskFileSystem as FileSystem>::write",
"<DiskFileSystem as turbo_tasks :: ValueToString>::to_string",
"<EnvMap as ProcessEnv>::read_all",
"<NftJsonAsset as Asset>::content",
"<ServerNftJsonAsset as Asset>::content",
"DiskFileSystem::new_internal",
"NextConfig::asset_suffix_path",
"NextConfig::base_path",
"NextConfig::bundle_pages_router_dependencies",
"NextConfig::cache_handler",
"NextConfig::cache_handlers",
"NextConfig::cache_kinds",
"NextConfig::client_source_maps",
"NextConfig::client_static_folder_name",
"NextConfig::compiler",
"NextConfig::computed_asset_prefix",
"NextConfig::config_file_path",
"NextConfig::cross_origin",
"NextConfig::css_chunking",
"NextConfig::dist_dir",
"NextConfig::dist_dir_root",
"NextConfig::enable_cache_components",
"NextConfig::enable_concurrent_router_queue",
"NextConfig::enable_durable_use_cache_entries",
"NextConfig::enable_expose_testing_api_in_production_build",
"NextConfig::enable_immutable_assets",
"NextConfig::enable_react_production_profiling",
"NextConfig::enable_taint",
"NextConfig::enable_use_cache",
"NextConfig::experimental_sri",
"NextConfig::experimental_swc_env_options",
"NextConfig::experimental_swc_plugins",
"NextConfig::experimental_turbopack_local_postcss_config",
"NextConfig::experimental_turbopack_use_builtin_babel",
"NextConfig::experimental_turbopack_use_builtin_sass",
"NextConfig::explicit_parallel_route_children",
"NextConfig::from_string",
"NextConfig::i18n",
"NextConfig::image_config",
"NextConfig::import_externals",
"NextConfig::inline_css",
"NextConfig::instrumentation_client_inject",
"NextConfig::is_global_not_found_enabled",
"NextConfig::is_standalone",
"NextConfig::is_using_adapter",
"NextConfig::lightningcss_feature_flags",
"NextConfig::mdx_rs",
"NextConfig::modularize_imports",
"NextConfig::module_fragments_enabled_for_foreign_code",
"NextConfig::module_fragments_enabled_for_user_code",
"NextConfig::module_ids",
"NextConfig::optimize_package_imports",
"NextConfig::output",
"NextConfig::output_file_tracing_excludes",
"NextConfig::output_file_tracing_includes",
"NextConfig::output_hash_salt",
"NextConfig::page_extensions",
"NextConfig::react_compiler_options",
"NextConfig::report_system_env_inlining",
"NextConfig::resolve_alias_options",
"NextConfig::resolve_extension",
"NextConfig::rust_react_compiler",
"NextConfig::sass_config",
"NextConfig::server_external_packages",
"NextConfig::server_source_maps",
"NextConfig::should_append_server_deployment_id_at_runtime",
"NextConfig::skip_proxy_url_normalize",
"NextConfig::skip_trailing_slash_redirect",
"NextConfig::strict_route_matching",
"NextConfig::transpile_packages",
"NextConfig::turbo_client_minify",
"NextConfig::turbo_edge_minify",
"NextConfig::turbo_nested_async_chunking",
"NextConfig::turbo_scope_hoisting",
"NextConfig::turbo_server_minify",
"NextConfig::turbo_shared_runtime",
"NextConfig::turbopack_chunk_loading_global",
"NextConfig::turbopack_chunking",
"NextConfig::turbopack_cjs_scope_hoisting",
"NextConfig::turbopack_cjs_tree_shaking",
"NextConfig::turbopack_cross_module_constants",
"NextConfig::turbopack_debug_ids",
"NextConfig::turbopack_generate_component_chunks",
"NextConfig::turbopack_ignore_issue_rules",
"NextConfig::turbopack_import_type_bytes",
"NextConfig::turbopack_infer_module_side_effects",
"NextConfig::turbopack_lazy_dynamic_imports",
"NextConfig::turbopack_lazy_dynamic_imports_ssr",
"NextConfig::turbopack_mangle_export_names",
"NextConfig::turbopack_mangle_via_materialized_namespace_object",
"NextConfig::turbopack_plugin_runtime_strategy",
"NextConfig::turbopack_remove_unused_exports",
"NextConfig::turbopack_remove_unused_imports",
"NextConfig::turbopack_worker_asset_prefix",
"NextConfig::typescript_tsconfig_path",
"NextConfig::use_react_experimental",
"NextConfig::webpack_rules",
"ProjectContainer::project",
"common_node_env",
"create_evaluate_pool_assets_operation",
"emit_all_output_assets_once_with_issues_operation",
"evaluate_webpack_loader",
"get_all_written_entrypoints_with_issues_operation",
"get_evaluate_pool",
"inner_entrypoints_without_collectibles_operation",
"project_root_path_operation",
"uppercase_env_map",
]
`)
}, 600_000)
})
})
const env = {
NEXT_TURBOPACK_TRACING: 'turbo-tasks',
// Persist even tiny snapshots so the test doesn't depend on the
// minimum-compilation-time threshold.
TURBO_ENGINE_IGNORE_DIRTY: '1',
TURBO_ENGINE_SNAPSHOT_MIN_ACTIVE_TIME_MILLIS: '0',
// Inside Docker, Next.js doesn't persist the server actions encryption key
// in `.next/cache` and generates a new one for every build. The key is an
// input of the Turbopack project, so that would make every build re-execute
// server-action-dependent work, depending on the environment.
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY:
'cG9ydGFibGUtYnVpbGQtY2FjaGUtdGVzdC1rZXktMzI=',
}
type Next = ReturnType<typeof nextTestSetup>['next']
async function tracedBuild(
next: Next
): Promise<{ cliOutput: string; executions: TaskExecution[] }> {
const { exitCode, cliOutput } = await next.build({ env })
if (exitCode !== 0) {
throw new Error(`next build exited with ${exitCode}:\n${cliOutput}`)
}
const executions = await readTaskExecutions(
path.join(next.testDir, '.next-profiles', 'trace-turbopack.bin')
)
return { cliOutput, executions }
}
/**
* Moves the project root (which contains `next.testDir`), including the `.next`
* cache, to a new directory.
*/
async function moveProject(next: Next, projectRoot: string) {
const movedRoot = `${projectRoot}-moved`
const appDir = path.relative(projectRoot, next.testDir)
await fs.rename(projectRoot, movedRoot)
// The harness runs builds in and cleans up `next.testDir`.
next.testDir = path.join(movedRoot, appDir)
}
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