Unverified Commit af33ebc3 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix ncc'd version of terser not being used by terser webpack plugin (#12252)

parent f0809316
......@@ -2,7 +2,7 @@
const {
minify: terserMinify
} = require('terser');
} = require("next/dist/compiled/terser");
const buildTerserOptions = ({
ecma,
......
......@@ -14,13 +14,26 @@ module.exports = function(task) {
minify: true,
...options,
}).then(({ code, assets }) => {
Object.keys(assets).forEach(key =>
Object.keys(assets).forEach(key => {
let data = assets[key].source
if (join(file.dir, key).endsWith('terser-webpack-plugin/worker.js')) {
data = Buffer.from(
data
.toString()
.replace(
`require('terser')`,
`require("${options.externals['terser']}")`
)
)
}
this._.files.push({
dir: join(file.dir, dirname(key)),
data,
base: basename(key),
data: assets[key].source,
dir: join(file.dir, dirname(key)),
})
)
})
if (options && options.packageName) {
writePackageManifest.call(this, options.packageName, file.base)
......
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