Commit 282de734 authored by Tobias Koppers's avatar Tobias Koppers Committed by Zack Tanner

disable production chunking in dev (#64488)

### What?

The production chunking plugin shouldn't be enabled in development

### Why?

It doesn't handle HMR yet


Closes PACK-2956
parent 1b931ce7
...@@ -1880,7 +1880,8 @@ export default async function getBaseWebpackConfig( ...@@ -1880,7 +1880,8 @@ export default async function getBaseWebpackConfig(
new NextFontManifestPlugin({ new NextFontManifestPlugin({
appDir, appDir,
}), }),
isClient && !dev &&
isClient &&
new CssChunkingPlugin(config.experimental.cssChunking === 'strict'), new CssChunkingPlugin(config.experimental.cssChunking === 'strict'),
!dev && !dev &&
isClient && isClient &&
......
import path from 'path' import path from 'path'
import { createNextDescribe, FileRef } from 'e2e-utils' import { nextTestSetup, FileRef } from 'e2e-utils'
function getPairs(all: string[]): (readonly [string, string])[] { function getPairs(all: string[]): (readonly [string, string])[] {
const result: (readonly [string, string])[] = [] const result: (readonly [string, string])[] = []
...@@ -187,141 +187,150 @@ const PAGES: Record< ...@@ -187,141 +187,150 @@ const PAGES: Record<
const allPairs = getPairs(Object.keys(PAGES)) const allPairs = getPairs(Object.keys(PAGES))
for (const mode of process.env.TURBOPACK ? ['turbo'] : ['strict', 'loose']) const options = (mode) => ({
createNextDescribe( files: {
`css-order ${mode}`, app: new FileRef(path.join(__dirname, 'app')),
{ pages: new FileRef(path.join(__dirname, 'pages')),
files: { 'next.config.js': process.env.TURBOPACK
app: new FileRef(path.join(__dirname, 'app')), ? `
pages: new FileRef(path.join(__dirname, 'pages')),
'next.config.js': process.env.TURBOPACK
? `
module.exports = {}` module.exports = {}`
: ` : `
module.exports = { module.exports = {
experimental: { experimental: {
cssChunking: ${JSON.stringify(mode)} cssChunking: ${JSON.stringify(mode)}
} }
}`, }`,
}, },
dependencies: { dependencies: {
sass: 'latest', sass: 'latest',
}, },
}, })
({ next, isNextDev }) => { describe.each(process.env.TURBOPACK ? ['turbo'] : ['strict', 'loose'])(
for (const ordering of allPairs) { 'css-order %s',
const name = `should load correct styles navigating back again ${ordering.join( (mode: string) => {
' -> ' const { next, isNextDev } = nextTestSetup(options(mode))
)} -> ${ordering.join(' -> ')}` for (const ordering of allPairs) {
const name = `should load correct styles navigating back again ${ordering.join(
' -> '
)} -> ${ordering.join(' -> ')}`
if (ordering.some((page) => PAGES[page].conflict)) {
// Conflict scenarios won't support that case
continue
}
// TODO fix this case
const broken =
isNextDev || ordering.some((page) => PAGES[page].brokenLoading)
if (broken) {
it.todo(name)
continue
}
it(name, async () => {
const start = PAGES[ordering[0]]
const browser = await next.browser(start.url)
const check = async (pageInfo) => {
expect(
await browser
.waitForElementByCss(pageInfo.selector)
.getComputedCss('color')
).toBe(pageInfo.color)
if (pageInfo.background) {
expect(
await browser
.waitForElementByCss(pageInfo.selector)
.getComputedCss('background-color')
).toBe(pageInfo.background)
}
}
const navigate = async (page) => {
await browser.waitForElementByCss('#' + page).click()
}
await check(start)
for (const page of ordering.slice(1)) {
await navigate(page)
await check(PAGES[page])
}
for (const page of ordering) {
await navigate(page)
await check(PAGES[page])
}
await browser.close()
})
}
}
)
describe.each(process.env.TURBOPACK ? ['turbo'] : ['strict', 'loose'])(
'css-order %s',
(mode: string) => {
const { next, isNextDev } = nextTestSetup(options(mode))
for (const ordering of allPairs) {
const name = `should load correct styles navigating ${ordering.join(
' -> '
)}`
if (mode !== 'turbo') {
if (ordering.some((page) => PAGES[page].conflict)) { if (ordering.some((page) => PAGES[page].conflict)) {
// Conflict scenarios won't support that case // Conflict scenarios won't support that case
continue continue
} }
// TODO fix this case // TODO fix this case
const broken = const broken = ordering.some(
mode === 'turbo' (page) =>
? isNextDev PAGES[page].brokenLoading ||
: ordering.some( (isNextDev && PAGES[page].brokenLoadingDev)
(page) => )
PAGES[page].brokenLoading ||
(isNextDev && PAGES[page].brokenLoadingDev)
)
if (broken) { if (broken) {
it.todo(name) it.todo(name)
continue continue
} }
it(name, async () => { } else {
const start = PAGES[ordering[0]] // TODO fix this case
const browser = await next.browser(start.url) const broken = ordering.some((page) => PAGES[page].brokenLoadingTurbo)
const check = async (pageInfo) => { if (broken) {
expect( it.todo(name)
await browser
.waitForElementByCss(pageInfo.selector)
.getComputedCss('color')
).toBe(pageInfo.color)
if (pageInfo.background) {
expect(
await browser
.waitForElementByCss(pageInfo.selector)
.getComputedCss('background-color')
).toBe(pageInfo.background)
}
}
const navigate = async (page) => {
await browser.waitForElementByCss('#' + page).click()
}
await check(start)
for (const page of ordering.slice(1)) {
await navigate(page)
await check(PAGES[page])
}
for (const page of ordering) {
await navigate(page)
await check(PAGES[page])
}
})
}
for (const ordering of allPairs) {
const name = `should load correct styles navigating ${ordering.join(
' -> '
)}`
if (mode !== 'turbo') {
if (ordering.some((page) => PAGES[page].conflict)) {
// Conflict scenarios won't support that case
continue
}
// TODO fix this case
const broken = ordering.some(
(page) =>
PAGES[page].brokenLoading ||
(isNextDev && PAGES[page].brokenLoadingDev)
)
if (broken) {
it.todo(name)
continue
}
} else {
// TODO fix this case
const broken = ordering.some((page) => PAGES[page].brokenLoadingTurbo)
if (broken) {
it.todo(name)
continue
}
}
it(name, async () => {
const start = PAGES[ordering[0]]
const browser = await next.browser(start.url)
const check = async (pageInfo) => {
expect(
await browser
.waitForElementByCss(pageInfo.selector)
.getComputedCss('color')
).toBe(pageInfo.color)
}
const navigate = async (page) => {
await browser.waitForElementByCss('#' + page).click()
}
await check(start)
for (const page of ordering.slice(1)) {
await navigate(page)
await check(PAGES[page])
}
})
}
for (const [page, pageInfo] of Object.entries(PAGES)) {
const name = `should load correct styles on ${page}`
if (mode === 'loose' && pageInfo.conflict) {
// Conflict scenarios won't support that case
continue continue
} }
it(name, async () => { }
const browser = await next.browser(pageInfo.url) it(name, async () => {
const start = PAGES[ordering[0]]
const browser = await next.browser(start.url)
const check = async (pageInfo) => {
expect( expect(
await browser await browser
.waitForElementByCss(pageInfo.selector) .waitForElementByCss(pageInfo.selector)
.getComputedCss('color') .getComputedCss('color')
).toBe(pageInfo.color) ).toBe(pageInfo.color)
}) }
const navigate = async (page) => {
await browser.waitForElementByCss('#' + page).click()
}
await check(start)
for (const page of ordering.slice(1)) {
await navigate(page)
await check(PAGES[page])
}
await browser.close()
})
}
}
)
describe.each(process.env.TURBOPACK ? ['turbo'] : ['strict', 'loose'])(
'css-order %s',
(mode: string) => {
const { next } = nextTestSetup(options(mode))
for (const [page, pageInfo] of Object.entries(PAGES)) {
const name = `should load correct styles on ${page}`
if (mode === 'loose' && pageInfo.conflict) {
// Conflict scenarios won't support that case
continue
} }
it(name, async () => {
const browser = await next.browser(pageInfo.url)
expect(
await browser
.waitForElementByCss(pageInfo.selector)
.getComputedCss('color')
).toBe(pageInfo.color)
await browser.close()
})
} }
) }
)
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