first commit
Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled

This commit is contained in:
Arian Tron
2026-03-10 19:37:31 +03:30
commit 61f56f997c
27684 changed files with 2784175 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
module.exports = {
webpack: (config, { isServer }) => {
if (!isServer) {
const optimization = config.optimization || {}
const splitChunks = optimization.splitChunks || {}
const cacheGroups = splitChunks.cacheGroups || {}
config.optimization = {
...optimization,
splitChunks: {
...splitChunks,
cacheGroups: {
...cacheGroups,
requiredByApp: {
test: /requiredByApp.js/,
name: 'requiredByApp',
enforce: true,
priority: 10,
chunks: 'all',
filename: 'static/chunks/[name].[chunkhash].js',
},
requiredByPage: {
test: /requiredByPage.js/,
name: 'requiredByPage',
enforce: true,
priority: 10,
chunks: 'all',
filename: 'static/chunks/[name].[chunkhash].js',
},
},
},
}
}
return config
},
}

View File

@@ -0,0 +1,16 @@
import React from 'react'
import RequiredByApp from '../requiredByApp'
import sideEffect from '../sideEffectModule'
sideEffect('_app')
function MyApp({ Component, pageProps }) {
return (
<React.Fragment>
<RequiredByApp />
<Component {...pageProps} />
</React.Fragment>
)
}
export default MyApp

View File

@@ -0,0 +1,28 @@
import Document, { Html, Head, Main, NextScript } from 'next/document'
import sideEffect from '../sideEffectModule'
sideEffect('_document')
class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)
return {
...initialProps,
}
}
render() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument

View File

@@ -0,0 +1,22 @@
import sideEffect from '../sideEffectModule'
import RequiredByPage from '../requiredByPage'
const sideEffects = sideEffect('page')
function Hi() {
return (
<div>
<RequiredByPage />
<p>Hello world!</p>
{sideEffects.map((arg, index) => (
<p key={arg} className="side-effect-calls">
{arg}
</p>
))}
</div>
)
}
Hi.getInitialProps = () => ({})
export default Hi

View File

@@ -0,0 +1,9 @@
function RequiredByApp() {
return (
<div>
<p>RequiredByApp!</p>
</div>
)
}
export default RequiredByApp

View File

@@ -0,0 +1,9 @@
function RequiredByPage() {
return (
<div>
<p>RequiredByPage</p>
</div>
)
}
export default RequiredByPage

View File

@@ -0,0 +1,10 @@
const sideEffect = (arg) => {
if (!sideEffect.callArguments) {
sideEffect.callArguments = []
}
sideEffect.callArguments.push(arg)
return sideEffect.callArguments
}
export default sideEffect

View File

@@ -0,0 +1,107 @@
/* eslint-env jest */
import { join } from 'path'
import cheerio from 'cheerio'
import {
nextBuild,
fetchViaHTTP,
findPort,
launchApp,
killApp,
nextStart,
} from 'next-test-utils'
const appDir = join(__dirname, '../')
let appPort
let app
const respectsSideEffects = async () => {
const res = await fetchViaHTTP(appPort, '/')
const html = await res.text()
const $ = cheerio.load(html)
const expectSideEffectsOrder = ['_document', '_app', 'page']
const sideEffectCalls = $('.side-effect-calls')
Array.from(sideEffectCalls).forEach((sideEffectCall, index) => {
expect($(sideEffectCall).text()).toEqual(expectSideEffectsOrder[index])
})
}
const respectsChunkAttachmentOrder = async () => {
const res = await fetchViaHTTP(appPort, '/')
const html = await res.text()
const $ = cheerio.load(html)
const requiredByRegex = /^\/_next\/static\/chunks\/(requiredBy\w*).*\.js/
const chunks = Array.from($('head').contents())
.filter(
(child) =>
child.type === 'script' &&
child.name === 'script' &&
child.attribs.src.match(requiredByRegex)
)
.map((child) => child.attribs.src.match(requiredByRegex)[1])
const requiredByAppIndex = chunks.indexOf('requiredByApp')
const requiredByPageIndex = chunks.indexOf('requiredByPage')
expect(requiredByAppIndex).toBeLessThan(requiredByPageIndex)
}
describe('Root components import order', () => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
// Test relies on webpack splitChunks overrides.
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
'Skipped in Turbopack',
() => {
it(
'_app chunks should be attached to de dom before page chunks',
respectsChunkAttachmentOrder
)
}
)
it(
'root components should be imported in this order _document > _app > page in order to respect side effects',
respectsSideEffects
)
}
)
})
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(join(__dirname, '../'), appPort)
})
afterAll(() => killApp(app))
it(
'root components should be imported in this order _document > _app > page in order to respect side effects',
respectsSideEffects
)
// Test relies on webpack splitChunks overrides.
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
'Skipped in Turbopack',
() => {
it(
'_app chunks should be attached to de dom before page chunks',
respectsChunkAttachmentOrder
)
}
)
}
)