diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml
index 3132eafa2aec2..8c9cbae0f0e9f 100644
--- a/.github/workflows/build_test_deploy.yml
+++ b/.github/workflows/build_test_deploy.yml
@@ -160,7 +160,7 @@ jobs:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
HEADLESS: true
- NEXT_WEBPACK5: 1
+ NEXT_PRIVATE_TEST_WEBPACK5_MODE: 1
steps:
- uses: actions/checkout@v2
@@ -174,7 +174,7 @@ jobs:
- run: yarn install --check-files
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}
- - run: xvfb-run node run-tests.js test/integration/{link-ref,production,basic,async-modules,font-optimization,ssr-ctx,worker-loader}/test/index.test.js test/acceptance/*.test.js
+ - run: xvfb-run node run-tests.js test/integration/{link-ref,production,basic,async-modules,font-optimization,ssr-ctx}/test/index.test.js test/acceptance/*.test.js
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}
testLegacyReact:
diff --git a/examples/with-emotion-vanilla/.babelrc b/examples/with-emotion-vanilla/.babelrc
new file mode 100644
index 0000000000000..d69237b3888a2
--- /dev/null
+++ b/examples/with-emotion-vanilla/.babelrc
@@ -0,0 +1,4 @@
+{
+ "presets": [["next/babel"]],
+ "plugins": ["@emotion/babel-plugin"]
+}
diff --git a/examples/with-emotion-vanilla/.gitignore b/examples/with-emotion-vanilla/.gitignore
new file mode 100644
index 0000000000000..1437c53f70bc2
--- /dev/null
+++ b/examples/with-emotion-vanilla/.gitignore
@@ -0,0 +1,34 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.js
+
+# testing
+/coverage
+
+# next.js
+/.next/
+/out/
+
+# production
+/build
+
+# misc
+.DS_Store
+*.pem
+
+# debug
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# local env files
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+
+# vercel
+.vercel
diff --git a/examples/with-emotion-vanilla/README.md b/examples/with-emotion-vanilla/README.md
new file mode 100644
index 0000000000000..f43e633dfc36b
--- /dev/null
+++ b/examples/with-emotion-vanilla/README.md
@@ -0,0 +1,24 @@
+# Emotion Vanilla Example
+
+Extract and inline critical css with
+[emotion](https://github.com/emotion-js/emotion/tree/master/packages/emotion),
+[@emotion/server](https://github.com/emotion-js/emotion/tree/master/packages/server),
+[@emotion/css](https://github.com/emotion-js/emotion/tree/master/packages/css)
+
+## Deploy your own
+
+Deploy the example using [Vercel](https://vercel.com):
+
+[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/import/project?template=https://github.com/vercel/next.js/tree/canary/examples/with-emotion-vanilla)
+
+## How to use
+
+Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
+
+```bash
+npx create-next-app --example with-emotion-vanilla with-emotion-vanilla-app
+# or
+yarn create next-app --example with-emotion-vanilla with-emotion-vanilla-app
+```
+
+Deploy it to the cloud with [Vercel](https://vercel.com/import?filter=next.js&utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
diff --git a/examples/with-emotion-vanilla/package.json b/examples/with-emotion-vanilla/package.json
new file mode 100644
index 0000000000000..4d271b1761be4
--- /dev/null
+++ b/examples/with-emotion-vanilla/package.json
@@ -0,0 +1,20 @@
+{
+ "name": "with-emotion-vanilla",
+ "version": "1.0.0",
+ "scripts": {
+ "dev": "next",
+ "build": "next build",
+ "start": "next start"
+ },
+ "license": "MIT",
+ "devDependencies": {
+ "@emotion/babel-plugin": "11.0.0"
+ },
+ "dependencies": {
+ "@emotion/css": "11.0.0",
+ "@emotion/server": "11.0.0",
+ "next": "latest",
+ "react": "^17.0.1",
+ "react-dom": "^17.0.1"
+ }
+}
diff --git a/examples/with-emotion-vanilla/pages/_document.js b/examples/with-emotion-vanilla/pages/_document.js
new file mode 100644
index 0000000000000..e34725067736d
--- /dev/null
+++ b/examples/with-emotion-vanilla/pages/_document.js
@@ -0,0 +1,34 @@
+import Document, { Html, Head, Main, NextScript } from 'next/document'
+import * as React from 'react'
+import { renderStatic } from '../shared/renderer'
+export default class AppDocument extends Document {
+ static async getInitialProps(ctx) {
+ const page = await ctx.renderPage()
+ const { css, ids } = await renderStatic(page.html)
+ const initialProps = await Document.getInitialProps(ctx)
+ return {
+ ...initialProps,
+ styles: (
+
+ {initialProps.styles}
+
+
+ ),
+ }
+ }
+
+ render() {
+ return (
+
+
+
+
+
+
+ )
+ }
+}
diff --git a/examples/with-emotion-vanilla/pages/index.js b/examples/with-emotion-vanilla/pages/index.js
new file mode 100644
index 0000000000000..0c3c7b014d2c5
--- /dev/null
+++ b/examples/with-emotion-vanilla/pages/index.js
@@ -0,0 +1,30 @@
+import Head from 'next/head'
+import {
+ basicStyles,
+ otherStyles,
+ someMoreBasicStyles,
+ someCssAsObject,
+ combinedAsArray,
+ cxExample,
+ keyframesExample,
+} from '../shared/styles'
+
+const Home = () => (
+ <>
+
+ Emotion using the vanilla version supporting SSR
+
+
+
Emotion Vanilla example
+
Basic styles using emotion
+
Some more styles using emotion
+
Well why not here is some more
+
Object styles using emotion css
+
Array of styles using emotion css
+
cx example from emotion
+
+
+ >
+)
+
+export default Home
diff --git a/examples/with-emotion-vanilla/shared/renderer.js b/examples/with-emotion-vanilla/shared/renderer.js
new file mode 100644
index 0000000000000..6865f1adea2ef
--- /dev/null
+++ b/examples/with-emotion-vanilla/shared/renderer.js
@@ -0,0 +1,12 @@
+import createEmotionServer from '@emotion/server/create-instance'
+import { cache } from '@emotion/css'
+
+export const renderStatic = async (html) => {
+ if (html === undefined) {
+ throw new Error('did you forget to return html from renderToString?')
+ }
+ const { extractCritical } = createEmotionServer(cache)
+ const { ids, css } = extractCritical(html)
+
+ return { html, ids, css }
+}
diff --git a/examples/with-emotion-vanilla/shared/styles.js b/examples/with-emotion-vanilla/shared/styles.js
new file mode 100644
index 0000000000000..c2562c032f844
--- /dev/null
+++ b/examples/with-emotion-vanilla/shared/styles.js
@@ -0,0 +1,102 @@
+import { css, cx, keyframes, injectGlobal } from '@emotion/css'
+
+injectGlobal`
+ * {
+ box-sizing: border-box;
+ }
+ body {
+ background: #DFCFBE;
+ font-family: Helvetica, sans-serif;
+ }
+`
+
+const basicStyles = css`
+ background-color: white;
+ color: cornflowerblue;
+ border: 1px solid lightgreen;
+ border-right: none;
+ border-bottom: none;
+ box-shadow: 5px 5px 0 0 lightgreen, 10px 10px 0 0 lightyellow;
+ transition: all 0.1s linear;
+ margin: 3rem 0;
+ padding: 1rem 0.5rem;
+`
+
+const otherStyles = css`
+ background-color: red;
+ padding: 10px;
+ margin-bottom: 10px;
+`
+
+const someMoreBasicStyles = css`
+ background-color: green;
+ color: white;
+ margin-bottom: 10px;
+ padding: 10px;
+`
+
+const someCssAsObject = css({
+ background: 'orange',
+ color: 'white',
+ padding: '10px',
+ marginBottom: '10px',
+})
+
+const combinedAsArray = css([someMoreBasicStyles, someCssAsObject])
+
+const cls1 = css`
+ font-size: 20px;
+ padding: 5px;
+ background: green;
+ color: orange;
+`
+const cls2 = css`
+ font-size: 20px;
+ padding: 15px;
+ background: blue;
+ color: white;
+`
+
+const cxExample = cx(cls1, cls2)
+
+const bounce = keyframes`
+ from, 20%, 53%, 80%, to {
+ transform: translate3d(0,0,0);
+ }
+
+ 40%, 43% {
+ transform: translate3d(0, -30px, 0);
+ }
+
+ 70% {
+ transform: translate3d(0, -15px, 0);
+ }
+
+ 90% {
+ transform: translate3d(0,-4px,0);
+ }
+`
+
+const keyframesExample = css([
+ bounce,
+ css({
+ marginTop: '50px',
+ width: '20px',
+ height: '20px',
+ background: 'black',
+ borderRadius: '50%',
+ padding: '20px',
+ animation: `${bounce} 1s ease infinite`,
+ transformOrigin: 'center',
+ }),
+])
+
+export {
+ combinedAsArray,
+ cxExample,
+ keyframesExample,
+ someCssAsObject,
+ someMoreBasicStyles,
+ otherStyles,
+ basicStyles,
+}
diff --git a/examples/with-iron-session/components/Header.js b/examples/with-iron-session/components/Header.js
index 121fab4f4e0b0..fdfa5adc2fb68 100644
--- a/examples/with-iron-session/components/Header.js
+++ b/examples/with-iron-session/components/Header.js
@@ -54,7 +54,7 @@ const Header = () => {
)}
-
+
diff --git a/examples/with-tailwindcss-emotion/package.json b/examples/with-tailwindcss-emotion/package.json
index 8e6a2da28d0f6..3aeb191e752d4 100644
--- a/examples/with-tailwindcss-emotion/package.json
+++ b/examples/with-tailwindcss-emotion/package.json
@@ -4,8 +4,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
- "start": "next start",
- "build:base-css": "tailwindcss build ./styles/tailwind.base.css -o ./styles/base.css"
+ "start": "next start"
},
"dependencies": {
"@emotion/react": "^11.1.1",
diff --git a/examples/with-tailwindcss-emotion/pages/_app.js b/examples/with-tailwindcss-emotion/pages/_app.js
index 71cba2ead896b..0af8b3785e0ce 100644
--- a/examples/with-tailwindcss-emotion/pages/_app.js
+++ b/examples/with-tailwindcss-emotion/pages/_app.js
@@ -2,8 +2,6 @@ import Head from 'next/head'
import { Global } from '@emotion/react'
import xw from 'xwind'
-import '../styles/base.css'
-
function App({ Component, pageProps }) {
return (
<>
@@ -11,8 +9,8 @@ function App({ Component, pageProps }) {
Tailwindcss Emotion Example
>
diff --git a/examples/with-tailwindcss-emotion/styles/base.css b/examples/with-tailwindcss-emotion/styles/base.css
deleted file mode 100644
index 542bdbc85f5fd..0000000000000
--- a/examples/with-tailwindcss-emotion/styles/base.css
+++ /dev/null
@@ -1,541 +0,0 @@
-/*! modern-normalize v1.0.0 | MIT License | https://github.com/sindresorhus/modern-normalize */
-
-/*
-Document
-========
-*/
-
-/**
-Use a better box model (opinionated).
-*/
-
-*,
-*::before,
-*::after {
- box-sizing: border-box;
-}
-
-/**
-Use a more readable tab size (opinionated).
-*/
-
-:root {
- -moz-tab-size: 4;
- -o-tab-size: 4;
- tab-size: 4;
-}
-
-/**
-1. Correct the line height in all browsers.
-2. Prevent adjustments of font size after orientation changes in iOS.
-*/
-
-html {
- line-height: 1.15; /* 1 */
- -webkit-text-size-adjust: 100%; /* 2 */
-}
-
-/*
-Sections
-========
-*/
-
-/**
-Remove the margin in all browsers.
-*/
-
-body {
- margin: 0;
-}
-
-/**
-Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
-*/
-
-body {
- font-family: system-ui, -apple-system,
- /* Firefox supports this but not yet `system-ui` */ 'Segoe UI', Roboto,
- Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
-}
-
-/*
-Grouping content
-================
-*/
-
-/**
-1. Add the correct height in Firefox.
-2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
-*/
-
-hr {
- height: 0; /* 1 */
- color: inherit; /* 2 */
-}
-
-/*
-Text-level semantics
-====================
-*/
-
-/**
-Add the correct text decoration in Chrome, Edge, and Safari.
-*/
-
-abbr[title] {
- -webkit-text-decoration: underline dotted;
- text-decoration: underline dotted;
-}
-
-/**
-Add the correct font weight in Edge and Safari.
-*/
-
-b,
-strong {
- font-weight: bolder;
-}
-
-/**
-1. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
-2. Correct the odd 'em' font sizing in all browsers.
-*/
-
-code,
-kbd,
-samp,
-pre {
- font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo,
- monospace; /* 1 */
- font-size: 1em; /* 2 */
-}
-
-/**
-Add the correct font size in all browsers.
-*/
-
-small {
- font-size: 80%;
-}
-
-/**
-Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
-*/
-
-sub,
-sup {
- font-size: 75%;
- line-height: 0;
- position: relative;
- vertical-align: baseline;
-}
-
-sub {
- bottom: -0.25em;
-}
-
-sup {
- top: -0.5em;
-}
-
-/*
-Tabular data
-============
-*/
-
-/**
-1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
-2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
-*/
-
-table {
- text-indent: 0; /* 1 */
- border-color: inherit; /* 2 */
-}
-
-/*
-Forms
-=====
-*/
-
-/**
-1. Change the font styles in all browsers.
-2. Remove the margin in Firefox and Safari.
-*/
-
-button,
-input,
-optgroup,
-select,
-textarea {
- font-family: inherit; /* 1 */
- font-size: 100%; /* 1 */
- line-height: 1.15; /* 1 */
- margin: 0; /* 2 */
-}
-
-/**
-Remove the inheritance of text transform in Edge and Firefox.
-1. Remove the inheritance of text transform in Firefox.
-*/
-
-button,
-select {
- /* 1 */
- text-transform: none;
-}
-
-/**
-Correct the inability to style clickable types in iOS and Safari.
-*/
-
-button,
-[type='button'],
-[type='reset'],
-[type='submit'] {
- -webkit-appearance: button;
-}
-
-/**
-Remove the inner border and padding in Firefox.
-*/
-
-::-moz-focus-inner {
- border-style: none;
- padding: 0;
-}
-
-/**
-Restore the focus styles unset by the previous rule.
-*/
-
-:-moz-focusring {
- outline: 1px dotted ButtonText;
-}
-
-/**
-Remove the additional ':invalid' styles in Firefox.
-See: https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737
-*/
-
-:-moz-ui-invalid {
- box-shadow: none;
-}
-
-/**
-Remove the padding so developers are not caught out when they zero out 'fieldset' elements in all browsers.
-*/
-
-legend {
- padding: 0;
-}
-
-/**
-Add the correct vertical alignment in Chrome and Firefox.
-*/
-
-progress {
- vertical-align: baseline;
-}
-
-/**
-Correct the cursor style of increment and decrement buttons in Safari.
-*/
-
-::-webkit-inner-spin-button,
-::-webkit-outer-spin-button {
- height: auto;
-}
-
-/**
-1. Correct the odd appearance in Chrome and Safari.
-2. Correct the outline style in Safari.
-*/
-
-[type='search'] {
- -webkit-appearance: textfield; /* 1 */
- outline-offset: -2px; /* 2 */
-}
-
-/**
-Remove the inner padding in Chrome and Safari on macOS.
-*/
-
-::-webkit-search-decoration {
- -webkit-appearance: none;
-}
-
-/**
-1. Correct the inability to style clickable types in iOS and Safari.
-2. Change font properties to 'inherit' in Safari.
-*/
-
-::-webkit-file-upload-button {
- -webkit-appearance: button; /* 1 */
- font: inherit; /* 2 */
-}
-
-/*
-Interactive
-===========
-*/
-
-/*
-Add the correct display in Chrome and Safari.
-*/
-
-summary {
- display: list-item;
-}
-
-/**
- * Manually forked from SUIT CSS Base: https://github.com/suitcss/base
- * A thin layer on top of normalize.css that provides a starting point more
- * suitable for web applications.
- */
-
-/**
- * Removes the default spacing and border for appropriate elements.
- */
-
-blockquote,
-dl,
-dd,
-h1,
-h2,
-h3,
-h4,
-h5,
-h6,
-hr,
-figure,
-p,
-pre {
- margin: 0;
-}
-
-button {
- background-color: transparent;
- background-image: none;
-}
-
-/**
- * Work around a Firefox/IE bug where the transparent `button` background
- * results in a loss of the default `button` focus styles.
- */
-
-button:focus {
- outline: 1px dotted;
- outline: 5px auto -webkit-focus-ring-color;
-}
-
-fieldset {
- margin: 0;
- padding: 0;
-}
-
-ol,
-ul {
- list-style: none;
- margin: 0;
- padding: 0;
-}
-
-/**
- * Tailwind custom reset styles
- */
-
-/**
- * 1. Use the user's configured `sans` font-family (with Tailwind's default
- * sans-serif font stack as a fallback) as a sane default.
- * 2. Use Tailwind's default "normal" line-height so the user isn't forced
- * to override it to ensure consistency even when using the default theme.
- */
-
-html {
- font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
- 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
- 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; /* 1 */
- line-height: 1.5; /* 2 */
-}
-
-/**
- * Inherit font-family and line-height from `html` so users can set them as
- * a class directly on the `html` element.
- */
-
-body {
- font-family: inherit;
- line-height: inherit;
-}
-
-/**
- * 1. Prevent padding and border from affecting element width.
- *
- * We used to set this in the html element and inherit from
- * the parent element for everything else. This caused issues
- * in shadow-dom-enhanced elements like where the content
- * is wrapped by a div with box-sizing set to `content-box`.
- *
- * https://github.com/mozdevs/cssremedy/issues/4
- *
- *
- * 2. Allow adding a border to an element by just adding a border-width.
- *
- * By default, the way the browser specifies that an element should have no
- * border is by setting it's border-style to `none` in the user-agent
- * stylesheet.
- *
- * In order to easily add borders to elements by just setting the `border-width`
- * property, we change the default border-style for all elements to `solid`, and
- * use border-width to hide them instead. This way our `border` utilities only
- * need to set the `border-width` property instead of the entire `border`
- * shorthand, making our border utilities much more straightforward to compose.
- *
- * https://github.com/tailwindcss/tailwindcss/pull/116
- */
-
-*,
-::before,
-::after {
- box-sizing: border-box; /* 1 */
- border-width: 0; /* 2 */
- border-style: solid; /* 2 */
- border-color: #e4e4e7; /* 2 */
-}
-
-/*
- * Ensure horizontal rules are visible by default
- */
-
-hr {
- border-top-width: 1px;
-}
-
-/**
- * Undo the `border-style: none` reset that Normalize applies to images so that
- * our `border-{width}` utilities have the expected effect.
- *
- * The Normalize reset is unnecessary for us since we default the border-width
- * to 0 on all elements.
- *
- * https://github.com/tailwindcss/tailwindcss/issues/362
- */
-
-img {
- border-style: solid;
-}
-
-textarea {
- resize: vertical;
-}
-
-input::-moz-placeholder,
-textarea::-moz-placeholder {
- color: #a1a1aa;
-}
-
-input:-ms-input-placeholder,
-textarea:-ms-input-placeholder {
- color: #a1a1aa;
-}
-
-input::placeholder,
-textarea::placeholder {
- color: #a1a1aa;
-}
-
-button,
-[role='button'] {
- cursor: pointer;
-}
-
-table {
- border-collapse: collapse;
-}
-
-h1,
-h2,
-h3,
-h4,
-h5,
-h6 {
- font-size: inherit;
- font-weight: inherit;
-}
-
-/**
- * Reset links to optimize for opt-in styling instead of
- * opt-out.
- */
-
-a {
- color: inherit;
- text-decoration: inherit;
-}
-
-/**
- * Reset form element properties that are easy to forget to
- * style explicitly so you don't inadvertently introduce
- * styles that deviate from your design system. These styles
- * supplement a partial reset that is already applied by
- * normalize.css.
- */
-
-button,
-input,
-optgroup,
-select,
-textarea {
- padding: 0;
- line-height: inherit;
- color: inherit;
-}
-
-/**
- * Use the configured 'mono' font family for elements that
- * are expected to be rendered with a monospace font, falling
- * back to the system monospace stack if there is no configured
- * 'mono' font family.
- */
-
-pre,
-code,
-kbd,
-samp {
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
- 'Liberation Mono', 'Courier New', monospace;
-}
-
-/**
- * Make replaced elements `display: block` by default as that's
- * the behavior you want almost all of the time. Inspired by
- * CSS Remedy, with `svg` added as well.
- *
- * https://github.com/mozdevs/cssremedy/issues/14
- */
-
-img,
-svg,
-video,
-canvas,
-audio,
-iframe,
-embed,
-object {
- display: block;
- vertical-align: middle;
-}
-
-/**
- * Constrain images and videos to the parent width and preserve
- * their instrinsic aspect ratio.
- *
- * https://github.com/mozdevs/cssremedy/issues/14
- */
-
-img,
-video {
- max-width: 100%;
- height: auto;
-}
diff --git a/examples/with-tailwindcss-emotion/styles/tailwind.base.css b/examples/with-tailwindcss-emotion/styles/tailwind.base.css
deleted file mode 100644
index 2f02db53f6e3a..0000000000000
--- a/examples/with-tailwindcss-emotion/styles/tailwind.base.css
+++ /dev/null
@@ -1 +0,0 @@
-@tailwind base;
diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts
index c36610e0a04bc..23df952770384 100644
--- a/packages/next/build/webpack-config.ts
+++ b/packages/next/build/webpack-config.ts
@@ -204,11 +204,7 @@ export default async function getBaseWebpackConfig(
rewrites: Rewrite[]
}
): Promise {
- initWebpack(
- config.future?.webpack5 ||
- (config.future?.webpack5 !== false &&
- Number(process.env.NEXT_WEBPACK5) > 0)
- )
+ initWebpack(!!config.future?.webpack5)
let plugins: PluginMetaData[] = []
let babelPresetPlugins: { dir: string; config: any }[] = []
diff --git a/packages/next/next-server/server/config.ts b/packages/next/next-server/server/config.ts
index 02e2558037f0d..2408b923a7800 100644
--- a/packages/next/next-server/server/config.ts
+++ b/packages/next/next-server/server/config.ts
@@ -91,7 +91,7 @@ const defaultConfig: NextConfig = {
future: {
strictPostcssConfiguration: false,
excludeDefaultMomentLocales: false,
- webpack5: false,
+ webpack5: Number(process.env.NEXT_PRIVATE_TEST_WEBPACK5_MODE) > 0,
},
serverRuntimeConfig: {},
publicRuntimeConfig: {},