Unverified Commit 60f1d58c authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Fix some webpack 5 deprecation warnings (#15797)

- Use latest terser version (still 1 warning in the stable version which is an open PR)
- Add emitOnErrors instead of noEmitOnErrors
- Added trace-deprecations for Next.js core development
parent 210a6980
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
"publish-canary": "lerna version prerelease --preid canary --force-publish && release --pre --skip-questions", "publish-canary": "lerna version prerelease --preid canary --force-publish && release --pre --skip-questions",
"publish-stable": "lerna version --force-publish", "publish-stable": "lerna version --force-publish",
"lint-staged": "lint-staged", "lint-staged": "lint-staged",
"next": "node packages/next/dist/bin/next", "next": "node --trace-deprecation packages/next/dist/bin/next",
"debug": "node --inspect packages/next/dist/bin/next" "debug": "node --inspect packages/next/dist/bin/next"
}, },
"pre-commit": "lint-staged", "pre-commit": "lint-staged",
......
...@@ -662,7 +662,8 @@ export default async function getBaseWebpackConfig( ...@@ -662,7 +662,8 @@ export default async function getBaseWebpackConfig(
'@ampproject/toolbox-optimizer', // except this one '@ampproject/toolbox-optimizer', // except this one
], ],
optimization: { optimization: {
noEmitOnErrors: dev, // Webpack 5 uses a new property for the same functionality
...(isWebpack5 ? { emitOnErrors: !dev } : { noEmitOnErrors: dev }),
checkWasmTypes: false, checkWasmTypes: false,
nodeEnv: false, nodeEnv: false,
splitChunks: isServer ? false : splitChunksConfig, splitChunks: isServer ? false : splitChunksConfig,
......
...@@ -23,8 +23,6 @@ const buildTerserOptions = ({ ...@@ -23,8 +23,6 @@ const buildTerserOptions = ({
/* eslint-enable camelcase */ /* eslint-enable camelcase */
safari10 safari10
} = {}) => ({ } = {}) => ({
ecma,
warnings,
parse: { ...parse parse: { ...parse
}, },
compress: typeof compress === 'boolean' ? compress : { ...compress compress: typeof compress === 'boolean' ? compress : { ...compress
...@@ -36,15 +34,17 @@ const buildTerserOptions = ({ ...@@ -36,15 +34,17 @@ const buildTerserOptions = ({
beautify: false, beautify: false,
...output ...output
}, },
module,
// Ignoring sourceMap from options // Ignoring sourceMap from options
sourceMap: null, sourceMap: null,
toplevel, ecma,
nameCache,
ie8,
keep_classnames, keep_classnames,
keep_fnames, keep_fnames,
safari10 ie8,
module,
nameCache,
safari10,
toplevel,
warnings
}); });
function isObject(value) { function isObject(value) {
...@@ -97,7 +97,7 @@ const buildComments = (options, terserOptions, extractedComments) => { ...@@ -97,7 +97,7 @@ const buildComments = (options, terserOptions, extractedComments) => {
if (condition[key] === 'some') { if (condition[key] === 'some') {
condition[key] = (astNode, comment) => { condition[key] = (astNode, comment) => {
return comment.type === 'comment2' && /@preserve|@lic|@cc_on|^\**!/i.test(comment.value); return (comment.type === 'comment2' || comment.type === 'comment1') && /@preserve|@lic|@cc_on|^\**!/i.test(comment.value);
}; };
break; break;
......
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
"use-subscription": "1.4.1", "use-subscription": "1.4.1",
"watchpack": "2.0.0-beta.13", "watchpack": "2.0.0-beta.13",
"web-vitals": "0.2.1", "web-vitals": "0.2.1",
"webpack": "4.44.0", "webpack": "4.44.1",
"webpack-sources": "1.4.3" "webpack-sources": "1.4.3"
}, },
"peerDependencies": { "peerDependencies": {
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
"strip-ansi": "6.0.0", "strip-ansi": "6.0.0",
"taskr": "1.1.0", "taskr": "1.1.0",
"terser": "4.4.2", "terser": "4.4.2",
"terser-webpack-plugin": "gist:1b826e8b64f73158df99990d1b4624fa", "terser-webpack-plugin": "3.0.8",
"text-table": "0.2.0", "text-table": "0.2.0",
"thread-loader": "2.1.3", "thread-loader": "2.1.3",
"typescript": "3.8.3", "typescript": "3.8.3",
......
...@@ -18,7 +18,9 @@ module.exports = function (task) { ...@@ -18,7 +18,9 @@ module.exports = function (task) {
Object.keys(assets).forEach((key) => { Object.keys(assets).forEach((key) => {
let data = assets[key].source let data = assets[key].source
if (join(file.dir, key).endsWith('terser-webpack-plugin/worker.js')) { if (
join(file.dir, key).endsWith('terser-webpack-plugin/dist/minify.js')
) {
data = Buffer.from( data = Buffer.from(
data data
.toString() .toString()
......
This diff is collapsed.
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