Unverified Commit 80000f42 authored by Jens Meindertsma's avatar Jens Meindertsma Committed by GitHub

[Fix] `webpack@5.0.0-beta.30`: Invalid configuration (#17045)

Earlier today #17038 was merged which I opened to fix a problem when using `webpack@5.0.0-beta.30` with Next.js using the new Webpack 5 support. In that PR, the only change was the renaming of a configuration key. I later discovered that the change on the Webpack side was different than I initially thought, and this meant that the fix I submittted to Next.js didn't work.

This PR intends to fix the remaining problems. Webpack 5 now accepts a `environment` key that can be used to configure the target output. Previously, this was known as `ecmaVersion` and accepted a number. Now, `environment` accepts a configuration object with individual options. I've configured this in such a way where it resembles an ES5 environment:
```js
environment: {
   arrowFunction: false,
   bigIntLiteral: false,
   const: false,
   destructuring: false,
   dynamicImport: false,
   forOf: false,
   module: false,
}
```
parent 1d30f217
...@@ -790,7 +790,19 @@ export default async function getBaseWebpackConfig( ...@@ -790,7 +790,19 @@ export default async function getBaseWebpackConfig(
ignored: ['**/.git/**', '**/node_modules/**', '**/.next/**'], ignored: ['**/.git/**', '**/node_modules/**', '**/.next/**'],
}, },
output: { output: {
...(isWebpack5 ? { environment: 5 } : {}), ...(isWebpack5
? {
environment: {
arrowFunction: false,
bigIntLiteral: false,
const: false,
destructuring: false,
dynamicImport: false,
forOf: false,
module: false,
},
}
: {}),
path: outputPath, path: outputPath,
// On the server we don't use the chunkhash // On the server we don't use the chunkhash
filename: isServer filename: isServer
......
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