Unverified Commit b4e3fecc authored by Sam Poder's avatar Sam Poder Committed by GitHub

[turbopack] add `experimental.turbopackChunking` config (#96398)

Built using @sokra's Fleet! This re-arranges all of our chunking
experimental features under `experimental.turbopackChunking` and adds
the following options:

```javascript
/**
 * Avoid creating more than one chunk smaller than this size, in bytes. Smaller
 * chunks are merged into bigger ones to avoid that. Defaults to `50000` (50 KB).
 */
minChunkSize?: number
/**
 * Avoid creating more than this number of chunks per chunk group. Chunks are
 * merged into bigger ones to avoid that. Defaults to `40`.
 */
maxChunkCountPerGroup?: number
/**
 * Never merge chunks bigger than this size, in bytes, with other chunks. This keeps code
 * in big chunks from being duplicated across multiple chunks. Defaults to `200000` (200 KB).
 */
maxMergeChunkSize?: number
/**
 * Minimum size, in bytes, for a component chunk to be emitted on its own when
 * `generateComponentChunks` is enabled. Component chunks smaller than this are folded into a
 * single remainder chunk. Defaults to `20000` (20 KB).
 */
minComponentChunkSize?: number
```
parent e3d634e0
......@@ -2210,13 +2210,13 @@ impl Endpoint for AppEndpoint {
async fn entries(self: Vc<Self>) -> Result<Vc<GraphEntries>> {
let this = self.await?;
let app_entry = self.app_endpoint_entry().await?;
// The route's chunking heuristics from `experimental.turbopackChunkingHeuristics`. They are
// The route's chunking heuristics from `experimental.turbopackChunking`. They are
// attached to the route's entry chunk group.
let heuristics = this
.app_project
.project()
.next_config()
.chunking_heuristics()
.turbopack_chunking()
.await?
.entry_heuristics_for(&app_entry.pathname);
Ok(GraphEntries::from_chunk_groups(vec![
......
......@@ -1758,7 +1758,7 @@ impl Endpoint for PageEndpoint {
.pages_project
.project()
.next_config()
.chunking_heuristics()
.turbopack_chunking()
.await?
.entry_heuristics_for(&this.pathname);
......
......@@ -1598,7 +1598,7 @@ impl Project {
self: Vc<Self>,
) -> Result<Vc<Box<dyn ChunkingContext>>> {
let css_url_suffix = self.next_config().asset_suffix_path();
let chunking_heuristics = self.next_config().chunking_heuristics().await?;
let turbopack_chunking = self.next_config().turbopack_chunking().await?;
Ok(get_client_chunking_context(ClientChunkingContextOptions {
mode: self.next_mode(),
root_path: self.project_root_path().owned().await?,
......@@ -1631,9 +1631,13 @@ impl Project {
cross_origin: self.next_config().cross_origin(),
chunk_loading_global: self.next_config().turbopack_chunk_loading_global(),
style_groups_algorithm: self.next_config().css_chunking().owned().await?,
chunking_first_page_load_priority: chunking_heuristics.first_page_load_priority,
chunking_priority_boost_percent: chunking_heuristics.priority_boost_percent,
chunking_request_cost: chunking_heuristics.request_cost,
chunking_first_page_load_priority: turbopack_chunking.first_page_load_priority,
chunking_priority_boost_percent: turbopack_chunking.priority_boost_percent,
chunking_request_cost: turbopack_chunking.request_cost,
chunking_min_chunk_size: turbopack_chunking.min_chunk_size,
chunking_max_chunk_count_per_group: turbopack_chunking.max_chunk_count_per_group,
chunking_max_merge_chunk_size: turbopack_chunking.max_merge_chunk_size,
chunking_min_component_chunk_size: turbopack_chunking.min_component_chunk_size,
generate_component_chunks: self.next_config().turbopack_generate_component_chunks(),
}))
}
......
......@@ -499,6 +499,10 @@ pub struct ClientChunkingContextOptions {
pub chunking_first_page_load_priority: Option<u32>,
pub chunking_priority_boost_percent: Option<u32>,
pub chunking_request_cost: Option<u64>,
pub chunking_min_chunk_size: Option<usize>,
pub chunking_max_chunk_count_per_group: Option<usize>,
pub chunking_max_merge_chunk_size: Option<usize>,
pub chunking_min_component_chunk_size: Option<usize>,
pub generate_component_chunks: Vc<bool>,
}
......@@ -543,6 +547,10 @@ pub async fn get_client_chunking_context(
chunking_first_page_load_priority,
chunking_priority_boost_percent,
chunking_request_cost,
chunking_min_chunk_size,
chunking_max_chunk_count_per_group,
chunking_max_merge_chunk_size,
chunking_min_component_chunk_size,
generate_component_chunks,
} = options;
......@@ -607,16 +615,16 @@ pub async fn get_client_chunking_context(
.chunking_config(
Vc::<EcmascriptChunkType>::default().to_resolved().await?,
ChunkingConfig {
min_chunk_size: 50_000,
max_chunk_count_per_group: 40,
max_merge_chunk_size: 200_000,
min_chunk_size: chunking_min_chunk_size.unwrap_or(50_000),
max_chunk_count_per_group: chunking_max_chunk_count_per_group.unwrap_or(40),
max_merge_chunk_size: chunking_max_merge_chunk_size.unwrap_or(200_000),
first_page_load_priority: chunking_first_page_load_priority,
priority_boost_percent: chunking_priority_boost_percent,
request_cost: chunking_request_cost,
// Generate component chunks alongside the merged chunk so that the browser
// runtime can fetch an already-cached one instead of the whole merged chunk.
generate_component_chunks: *generate_component_chunks.await?,
min_component_chunk_size: 20_000,
min_component_chunk_size: chunking_min_component_chunk_size.unwrap_or(20_000),
..Default::default()
},
)
......
......@@ -1135,7 +1135,7 @@ const DEFAULT_REQUEST_COST: f32 = 20_000.0;
/// Default `weightDistribution` for the graph algorithm.
const DEFAULT_WEIGHT_DISTRIBUTION: f32 = 0.1;
/// `experimental.chunkingHeuristics`: hints for Turbopack's production chunker.
/// `experimental.turbopackChunking`: hints for Turbopack's production chunker.
#[derive(
Clone,
Debug,
......@@ -1149,7 +1149,7 @@ const DEFAULT_WEIGHT_DISTRIBUTION: f32 = 0.1;
Decode,
)]
#[serde(rename_all = "camelCase")]
pub struct ChunkingHeuristicsConfig {
pub struct TurbopackChunkingConfig {
/// A number between `0.0..=1.0`. Higher values weight the benefit of merging
/// chunks for a single page load more heavily. A site's bounce rate is a good
/// approximation if you don't have a better value.
......@@ -1165,10 +1165,24 @@ pub struct ChunkingHeuristicsConfig {
/// bytes of code, default is 200 KB), used by the chunker to trade off request
/// count against preventing double-fetching.
request_cost: Option<u64>,
/// Avoid creating more than one chunk smaller than this size, in bytes (default `50000`).
/// Smaller chunks are merged into larger chunks.
min_chunk_size: Option<usize>,
/// Avoid creating more than this number of chunks per chunk group (default `40`).
max_chunk_count_per_group: Option<usize>,
/// Don't merge chunks bigger than this size, in bytes (default `200000`), with other
/// chunks. This keeps code in big chunks from being duplicated across multiple chunks.
max_merge_chunk_size: Option<usize>,
/// Emit each merged production chunk's constituent component chunks alongside it, so the
/// browser runtime can load only the chunks it doesn't already have (default `false`).
generate_component_chunks: Option<bool>,
/// Minimum size, in bytes (default `20000`), for a component chunk to be emitted on its
/// own when `generate_component_chunks` is enabled.
min_component_chunk_size: Option<usize>,
}
#[turbo_tasks::value]
pub struct ChunkingHeuristics {
pub struct TurbopackChunking {
/// First-page-load priority as an integer percentage (`0..=100`), or `None` if unset.
pub first_page_load_priority: Option<u32>,
/// Route-matching regexes for priority routes.
......@@ -1178,9 +1192,19 @@ pub struct ChunkingHeuristics {
pub priority_boost_percent: Option<u32>,
/// Global estimated cost of an additional request, in bytes, or `None` if unset.
pub request_cost: Option<u64>,
}
impl ChunkingHeuristics {
/// Override for the client JS `min_chunk_size`, or `None` to use the default.
pub min_chunk_size: Option<usize>,
/// Override for the client JS `max_chunk_count_per_group`, or `None` to use the default.
pub max_chunk_count_per_group: Option<usize>,
/// Override for the client JS `max_merge_chunk_size`, or `None` to use the default.
pub max_merge_chunk_size: Option<usize>,
/// Override for the client JS `min_component_chunk_size`, or `None` to use the default.
pub min_component_chunk_size: Option<usize>,
/// Whether to emit component chunks alongside merged chunks (default `false`).
pub generate_component_chunks: bool,
}
impl TurbopackChunking {
/// Compute the [`EntryHeuristics`] for a route `pathname` by matching it against the configured
/// priority-route regexes.
pub fn entry_heuristics_for(&self, pathname: &str) -> EntryHeuristics {
......@@ -1206,7 +1230,7 @@ fn parse_route_regexes(patterns: &[RegexComponents]) -> Result<Vec<EsRegex>> {
.cloned()
.map(|pattern| {
EsRegex::try_from(pattern)
.context("Invalid route pattern in `experimental.turbopackChunkingHeuristics`")
.context("Invalid route pattern in `experimental.turbopackChunking`")
})
.collect()
}
......@@ -1300,8 +1324,7 @@ pub struct ExperimentalConfig {
/// CSS chunking strategy. See [`CssChunkingConfig`] for the accepted shapes.
css_chunking: Option<CssChunkingConfig>,
/// Traffic-shape hints for the production chunker. See [`ChunkingHeuristicsConfig`].
turbopack_chunking_heuristics: Option<ChunkingHeuristicsConfig>,
turbopack_chunking: Option<TurbopackChunkingConfig>,
// ---
// UNSUPPORTED
......@@ -1370,7 +1393,6 @@ pub struct ExperimentalConfig {
turbopack_input_source_maps: Option<bool>,
turbopack_module_fragments: Option<bool>,
turbopack_scope_hoisting: Option<bool>,
turbopack_generate_component_chunks: Option<bool>,
turbopack_shared_runtime: Option<bool>,
/// Custom URL prefix for Web Worker URLs (the entrypoint and the module
/// chunks loaded inside the worker) produced by
......@@ -2099,14 +2121,14 @@ impl NextConfig {
}
#[turbo_tasks::function]
pub fn chunking_heuristics(&self) -> Result<Vc<ChunkingHeuristics>> {
let config = self.experimental.turbopack_chunking_heuristics.as_ref();
pub fn turbopack_chunking(&self) -> Result<Vc<TurbopackChunking>> {
let config = self.experimental.turbopack_chunking.as_ref();
let priority_routes = parse_route_regexes(
config
.and_then(|c| c.priority_routes.as_deref())
.unwrap_or_default(),
)?;
Ok(ChunkingHeuristics {
Ok(TurbopackChunking {
first_page_load_priority: config
.and_then(|c| c.first_page_load_priority)
.map(|priority| (priority.clamp(0.0, 1.0) * 100.0).round() as u32),
......@@ -2115,6 +2137,13 @@ impl NextConfig {
.and_then(|c| c.priority_boost)
.map(|boost| (boost.max(0.0) * 100.0).round() as u32),
request_cost: config.and_then(|c| c.request_cost),
min_chunk_size: config.and_then(|c| c.min_chunk_size),
max_chunk_count_per_group: config.and_then(|c| c.max_chunk_count_per_group),
max_merge_chunk_size: config.and_then(|c| c.max_merge_chunk_size),
min_component_chunk_size: config.and_then(|c| c.min_component_chunk_size),
generate_component_chunks: config
.and_then(|c| c.generate_component_chunks)
.unwrap_or(false),
}
.cell())
}
......@@ -2521,7 +2550,9 @@ impl NextConfig {
pub fn turbopack_generate_component_chunks(&self) -> Vc<bool> {
Vc::cell(
self.experimental
.turbopack_generate_component_chunks
.turbopack_chunking
.as_ref()
.and_then(|c| c.generate_component_chunks)
.unwrap_or(false),
)
}
......
......@@ -1460,5 +1460,7 @@
"1459": "[Server HMR] unreachable: unknown HMR instruction type %s",
"1460": "[Server HMR] unreachable: unexpected update instruction type %s",
"1461": "Expected segment cache to have data for stage '%s'",
"1462": "Unexpected chunk emitted in Before stage"
"1462": "Unexpected chunk emitted in Before stage",
"1463": "\\`experimental.turbopackGenerateComponentChunks\\` has been moved to \\`experimental.turbopackChunking.generateComponentChunks\\`. Please update your next.config.js file accordingly.",
"1464": "\\`experimental.turbopackChunkingHeuristics\\` has been renamed to \\`experimental.turbopackChunking\\`. Please update your next.config.js file accordingly."
}
......@@ -1037,21 +1037,20 @@ function bindingToApi(
nextConfigSerializable.turbopack = turbopack
}
// Serialize `experimental.turbopackChunkingHeuristics` route patterns: convert each RegExp to
// Serialize `experimental.turbopackChunking` route patterns: convert each RegExp to
// {source, flags} since RegExp objects are not JSON-serializable.
const chunkingHeuristics =
nextConfigSerializable.experimental?.turbopackChunkingHeuristics
if (chunkingHeuristics) {
const chunkingConfig =
nextConfigSerializable.experimental?.turbopackChunking
if (chunkingConfig) {
const regexComponents = (regex: RegExp) => ({
source: regex.source,
flags: regex.flags,
})
nextConfigSerializable.experimental = {
...nextConfigSerializable.experimental,
turbopackChunkingHeuristics: {
...chunkingHeuristics,
priorityRoutes:
chunkingHeuristics.priorityRoutes?.map(regexComponents),
turbopackChunking: {
...chunkingConfig,
priorityRoutes: chunkingConfig.priorityRoutes?.map(regexComponents),
},
}
}
......
......@@ -383,14 +383,18 @@ export const experimentalSchema = {
turbopackRemoveUnusedImports: z.boolean().optional(),
turbopackRemoveUnusedExports: z.boolean().optional(),
turbopackScopeHoisting: z.boolean().optional(),
turbopackGenerateComponentChunks: z.boolean().optional(),
turbopackSharedRuntime: z.boolean().optional(),
turbopackChunkingHeuristics: z
turbopackChunking: z
.object({
firstPageLoadPriority: z.number().min(0).max(1).optional(),
priorityRoutes: z.array(z.instanceof(RegExp)).optional(),
priorityBoost: z.number().min(1).optional(),
requestCost: z.number().min(0).max(1_000_000).optional(),
minChunkSize: z.number().min(0).optional(),
maxChunkCountPerGroup: z.number().min(0).optional(),
maxMergeChunkSize: z.number().min(0).optional(),
minComponentChunkSize: z.number().min(0).optional(),
generateComponentChunks: z.boolean().optional(),
})
.optional(),
turbopackWorkerAssetPrefix: z.string().optional(),
......
......@@ -763,13 +763,6 @@ export interface ExperimentalConfig {
*/
turbopackScopeHoisting?: boolean
/**
* (`next --turbopack` only) Emit each merged production chunk's constituent component chunks
* alongside it, so the browser runtime can load only the ones it doesn't already have.
* Defaults to `false`. Only applies in build mode.
*/
turbopackGenerateComponentChunks?: boolean
/**
* Share the browser runtime across routes in a single `runtime.js` asset and inline the
* per-route chunk-group bootstrap into the HTML, dropping the per-route runtime. Defaults to
......@@ -778,10 +771,10 @@ export interface ExperimentalConfig {
turbopackSharedRuntime?: boolean
/**
* (`next --turbopack` only) Traffic-related hints for the production chunker. These change the
* assumptions Turbopack makes when making chunk merging decisions.
* (`next --turbopack` only) These options change the assumptions Turbopack makes when
* making chunk merging decisions and the raw size thresholds it uses.
*/
turbopackChunkingHeuristics?: {
turbopackChunking?: {
/**
* This is a number between `0..1`, when higher, we weight the benefits of
* merging chunks for a signal page load higher. If you don't know a good
......@@ -808,6 +801,32 @@ export interface ExperimentalConfig {
* is approximately 5x the size of compressed and minified code.
*/
requestCost?: number
/**
* Avoid creating more than one chunk smaller than this size, in bytes. Smaller
* chunks are merged into bigger ones to avoid that. Defaults to `50000` (50 KB).
*/
minChunkSize?: number
/**
* Avoid creating more than this number of chunks per chunk group. Chunks are
* merged into bigger ones to avoid that. Defaults to `40`.
*/
maxChunkCountPerGroup?: number
/**
* Never merge chunks bigger than this size, in bytes, with other chunks. This keeps code
* in big chunks from being duplicated across multiple chunks. Defaults to `200000` (200 KB).
*/
maxMergeChunkSize?: number
/**
* Emit each merged production chunk's constituent component chunks alongside it, so the
* browser runtime can load only the ones it doesn't already have. Defaults to `false`.
*/
generateComponentChunks?: boolean
/**
* Minimum size, in bytes, for a component chunk to be emitted on its own when
* `generateComponentChunks` is enabled. Component chunks smaller than this are folded into a
* single remainder chunk. Defaults to `20000` (20 KB).
*/
minComponentChunkSize?: number
}
/**
......
......@@ -2036,6 +2036,28 @@ async function loadConfigImpl(
userConfig.experimental.supportsImmutableAssets
}
// `experimental.turbopackGenerateComponentChunks` has moved into
// `experimental.turbopackChunking.generateComponentChunks`.
if (
(userConfig.experimental as any)?.turbopackGenerateComponentChunks !==
undefined
) {
throw new Error(
`\`experimental.turbopackGenerateComponentChunks\` has been moved to \`experimental.turbopackChunking.generateComponentChunks\`. Please update your ${configFileName} file accordingly.`
)
}
// `experimental.turbopackChunkingHeuristics` has been renamed to
// `experimental.turbopackChunking`.
if (
(userConfig.experimental as any)?.turbopackChunkingHeuristics !==
undefined
) {
throw new Error(
`\`experimental.turbopackChunkingHeuristics\` has been renamed to \`experimental.turbopackChunking\`. Please update your ${configFileName} file accordingly.`
)
}
// Always validate the config against schema in non minimal mode
if (!process.env.NEXT_MINIMAL && !silent) {
await validateConfigSchema(
......
import { ReactNode } from 'react'
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
export default function Page() {
return <p id="hello">hello</p>
}
/** @type {import('next').NextConfig} */
module.exports = {}
import { nextTestSetup } from 'e2e-utils'
describe('experimental.turbopackChunking removed/renamed config', () => {
const { next } = nextTestSetup({
files: __dirname,
skipStart: true,
})
it('errors when the removed `turbopackGenerateComponentChunks` flag is used', async () => {
await next.patchFile(
'next.config.js',
`module.exports = {
experimental: { turbopackGenerateComponentChunks: true },
}`
)
const { cliOutput } = await next.build()
expect(cliOutput).toContain(
'`experimental.turbopackGenerateComponentChunks` has been moved to `experimental.turbopackChunking.generateComponentChunks`'
)
})
it('errors when the renamed `turbopackChunkingHeuristics` key is used', async () => {
await next.patchFile(
'next.config.js',
`module.exports = {
experimental: { turbopackChunkingHeuristics: { requestCost: 100000 } },
}`
)
const { cliOutput } = await next.build()
expect(cliOutput).toContain(
'`experimental.turbopackChunkingHeuristics` has been renamed to `experimental.turbopackChunking`'
)
})
it('accepts a valid `turbopackChunking` config', async () => {
await next.patchFile(
'next.config.js',
`module.exports = {
experimental: { turbopackChunking: { maxMergeChunkSize: 100000 } },
}`
)
const { exitCode, cliOutput } = await next.build()
expect(exitCode).toBe(0)
expect(cliOutput).not.toContain('has been moved to')
expect(cliOutput).not.toContain('has been renamed to')
})
})
import { BulkyA } from '../../components/bulky-a'
import { BulkyB } from '../../components/bulky-b'
import { BulkyC } from '../../components/bulky-c'
export default function Page() {
return (
<main>
<h1 id="page-a">page a</h1>
<BulkyA />
<BulkyB />
<BulkyC />
</main>
)
}
import { BulkyB } from '../../components/bulky-b'
import { BulkyC } from '../../components/bulky-c'
import { BulkyD } from '../../components/bulky-d'
export default function Page() {
return (
<main>
<h1 id="page-b">page b</h1>
<BulkyB />
<BulkyC />
<BulkyD />
</main>
)
}
import { BulkyC } from '../../components/bulky-c'
import { BulkyD } from '../../components/bulky-d'
import { BulkyE } from '../../components/bulky-e'
export default function Page() {
return (
<main>
<h1 id="page-c">page c</h1>
<BulkyC />
<BulkyD />
<BulkyE />
</main>
)
}
import { BulkyD } from '../../components/bulky-d'
import { BulkyE } from '../../components/bulky-e'
import { BulkyA } from '../../components/bulky-a'
export default function Page() {
return (
<main>
<h1 id="page-d">page d</h1>
<BulkyD />
<BulkyE />
<BulkyA />
</main>
)
}
import { BulkyE } from '../../components/bulky-e'
import { BulkyA } from '../../components/bulky-a'
import { BulkyB } from '../../components/bulky-b'
export default function Page() {
return (
<main>
<h1 id="page-e">page e</h1>
<BulkyE />
<BulkyA />
<BulkyB />
</main>
)
}
import { ReactNode } from 'react'
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html>
<body>
<nav>
<a href="/">home</a> <a href="/a">a</a> <a href="/b">b</a>{' '}
<a href="/c">c</a> <a href="/d">d</a> <a href="/e">e</a>
</nav>
{children}
</body>
</html>
)
}
import { BulkyA } from '../components/bulky-a'
import { BulkyB } from '../components/bulky-b'
export default function Home() {
return (
<main>
<h1 id="home">home</h1>
<BulkyA />
<BulkyB />
</main>
)
}
'use client'
import { useState } from 'react'
// Shared client component imported by every route. Because it is used by
// multiple chunk groups it becomes a candidate for a shared chunk, which the
// chunker may or may not merge depending on the configured thresholds.
export function Shared({ label }: { label: string }) {
const [count, setCount] = useState(0)
return (
<button id="shared-button" onClick={() => setCount((c) => c + 1)}>
{label}: {count}
</button>
)
}
/** @type {import('next').NextConfig} */
module.exports = {}
import { nextTestSetup } from 'e2e-utils'
import { listClientChunks } from 'next-test-utils'
import { join } from 'path'
// `experimental.turbopackChunking` only affects Turbopack production builds, so
// this suite is Turbopack-only. Webpack uses a different chunker and ignores it.
;(process.env.IS_TURBOPACK_TEST ? describe : describe.skip)(
'experimental.turbopackChunking',
() => {
const { next } = nextTestSetup({
files: __dirname,
skipStart: true,
})
async function buildWith(turbopackChunking: object | undefined) {
const experimental = turbopackChunking ? { turbopackChunking } : {}
await next.patchFile(
'next.config.js',
`module.exports = ${JSON.stringify({ experimental }, null, 2)}`
)
const { exitCode } = await next.build()
expect(exitCode).toBe(0)
const chunks = await listClientChunks(join(next.testDir, '.next'))
return chunks.filter(
(name) => name.includes('chunks') && name.endsWith('.js')
)
}
// Force the chunker to merge as much as possible into as few chunks as
// possible.
const mergeAll = {
minChunkSize: 100_000_000,
maxMergeChunkSize: 100_000_000,
maxChunkCountPerGroup: 1,
}
// Disable merging entirely, so every chunk group emits its own chunks.
const noMerge = {
minChunkSize: 0,
maxChunkCountPerGroup: 0,
maxMergeChunkSize: 0,
}
let mergeAllChunks: string[]
let noMergeChunks: string[]
let mergeAllWithComponentChunks: string[]
beforeAll(async () => {
mergeAllChunks = await buildWith(mergeAll)
noMergeChunks = await buildWith(noMerge)
mergeAllWithComponentChunks = await buildWith({
...mergeAll,
generateComponentChunks: true,
minComponentChunkSize: 0,
})
})
it('changes the client chunk output based on the size thresholds', () => {
// Disabling merging produces strictly more client chunks than merging
// everything, proving the size thresholds are wired through.
expect(noMergeChunks.length).toBeGreaterThan(mergeAllChunks.length)
})
it('emits additional component chunks when generateComponentChunks is enabled', () => {
// With the same merge settings, enabling component chunks emits extra
// per-component chunks alongside the merged chunks.
expect(mergeAllWithComponentChunks.length).toBeGreaterThan(
mergeAllChunks.length
)
})
it('renders and navigates correctly with custom chunking', async () => {
await next.patchFile(
'next.config.js',
`module.exports = ${JSON.stringify(
{ experimental: { turbopackChunking: mergeAll } },
null,
2
)}`
)
await next.build()
await next.start()
try {
const browser = await next.browser('/')
expect(await browser.elementByCss('#home').text()).toBe('home')
await browser
.elementByCss('a[href="/a"]')
.click()
.waitForElementByCss('#page-a')
expect(await browser.elementByCss('#page-a').text()).toBe('page a')
} finally {
await next.stop()
}
})
}
)
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