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(
new NextFontManifestPlugin({
appDir,
}),
isClient &&
!dev &&
isClient &&
new CssChunkingPlugin(config.experimental.cssChunking === 'strict'),
!dev &&
isClient &&
......
import path from 'path'
import { createNextDescribe, FileRef } from 'e2e-utils'
import { nextTestSetup, FileRef } from 'e2e-utils'
function getPairs(all: string[]): (readonly [string, string])[] {
const result: (readonly [string, string])[] = []
......@@ -187,141 +187,150 @@ const PAGES: Record<
const allPairs = getPairs(Object.keys(PAGES))
for (const mode of process.env.TURBOPACK ? ['turbo'] : ['strict', 'loose'])
createNextDescribe(
`css-order ${mode}`,
{
files: {
app: new FileRef(path.join(__dirname, 'app')),
pages: new FileRef(path.join(__dirname, 'pages')),
'next.config.js': process.env.TURBOPACK
? `
const options = (mode) => ({
files: {
app: new FileRef(path.join(__dirname, 'app')),
pages: new FileRef(path.join(__dirname, 'pages')),
'next.config.js': process.env.TURBOPACK
? `
module.exports = {}`
: `
: `
module.exports = {
experimental: {
cssChunking: ${JSON.stringify(mode)}
}
}`,
},
dependencies: {
sass: 'latest',
},
},
({ next, isNextDev }) => {
for (const ordering of allPairs) {
const name = `should load correct styles navigating back again ${ordering.join(
' -> '
)} -> ${ordering.join(' -> ')}`
},
dependencies: {
sass: 'latest',
},
})
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 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)) {
// Conflict scenarios won't support that case
continue
}
// TODO fix this case
const broken =
mode === 'turbo'
? isNextDev
: ordering.some(
(page) =>
PAGES[page].brokenLoading ||
(isNextDev && PAGES[page].brokenLoadingDev)
)
const broken = ordering.some(
(page) =>
PAGES[page].brokenLoading ||
(isNextDev && PAGES[page].brokenLoadingDev)
)
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])
}
})
}
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
} else {
// TODO fix this case
const broken = ordering.some((page) => PAGES[page].brokenLoadingTurbo)
if (broken) {
it.todo(name)
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(
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])
}
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