Skip to content

Commit

Permalink
feat: update Terser to version 5
Browse files Browse the repository at this point in the history
  • Loading branch information
chicoxyzzy committed Aug 3, 2020
1 parent 2a5acaa commit 094d04b
Show file tree
Hide file tree
Showing 19 changed files with 116 additions and 8,466 deletions.
17 changes: 14 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -48,7 +48,7 @@
"schema-utils": "^2.6.6",
"serialize-javascript": "^4.0.0",
"source-map": "^0.6.1",
"terser": "^4.8.0",
"terser": "^5.0.0",
"webpack-sources": "^1.4.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Expand Up @@ -476,7 +476,7 @@ class TerserPlugin {
if (worker) {
taskResult = await worker.transform(serialize(task));
} else {
taskResult = minifyFn(task);
taskResult = await minifyFn(task);
}
} catch (error) {
taskResult = { error };
Expand Down
17 changes: 5 additions & 12 deletions src/minify.js
Expand Up @@ -168,12 +168,11 @@ const minify = (options) => {
extractedComments
);

const { error, map, code, warnings } = terserMinify(
{ [file]: input },
terserOptions
return terserMinify({ [file]: input }, terserOptions).then(
({ error, map, code, warnings }) => {
return { error, map, code, warnings, extractedComments };
}
);

return { error, map, code, warnings, extractedComments };
};

function transform(options) {
Expand All @@ -189,13 +188,7 @@ function transform(options) {
`'use strict'\nreturn ${options}`
)(exports, require, module, __filename, __dirname);

const result = minify(options);

if (result.error) {
throw result.error;
} else {
return result;
}
return minify(options);
}

module.exports.minify = minify;
Expand Down

0 comments on commit 094d04b

Please sign in to comment.