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 @@
"publish-canary": "lerna version prerelease --preid canary --force-publish && release --pre --skip-questions",
"publish-stable": "lerna version --force-publish",
"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"
},
"pre-commit": "lint-staged",
......
......@@ -662,7 +662,8 @@ export default async function getBaseWebpackConfig(
'@ampproject/toolbox-optimizer', // except this one
],
optimization: {
noEmitOnErrors: dev,
// Webpack 5 uses a new property for the same functionality
...(isWebpack5 ? { emitOnErrors: !dev } : { noEmitOnErrors: dev }),
checkWasmTypes: false,
nodeEnv: false,
splitChunks: isServer ? false : splitChunksConfig,
......
......@@ -23,8 +23,6 @@ const buildTerserOptions = ({
/* eslint-enable camelcase */
safari10
} = {}) => ({
ecma,
warnings,
parse: { ...parse
},
compress: typeof compress === 'boolean' ? compress : { ...compress
......@@ -36,15 +34,17 @@ const buildTerserOptions = ({
beautify: false,
...output
},
module,
// Ignoring sourceMap from options
sourceMap: null,
toplevel,
nameCache,
ie8,
ecma,
keep_classnames,
keep_fnames,
safari10
ie8,
module,
nameCache,
safari10,
toplevel,
warnings
});
function isObject(value) {
......@@ -97,7 +97,7 @@ const buildComments = (options, terserOptions, extractedComments) => {
if (condition[key] === 'some') {
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;
......
......@@ -111,7 +111,7 @@
"use-subscription": "1.4.1",
"watchpack": "2.0.0-beta.13",
"web-vitals": "0.2.1",
"webpack": "4.44.0",
"webpack": "4.44.1",
"webpack-sources": "1.4.3"
},
"peerDependencies": {
......@@ -205,7 +205,7 @@
"strip-ansi": "6.0.0",
"taskr": "1.1.0",
"terser": "4.4.2",
"terser-webpack-plugin": "gist:1b826e8b64f73158df99990d1b4624fa",
"terser-webpack-plugin": "3.0.8",
"text-table": "0.2.0",
"thread-loader": "2.1.3",
"typescript": "3.8.3",
......
......@@ -18,7 +18,9 @@ module.exports = function (task) {
Object.keys(assets).forEach((key) => {
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
.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