Skip to content

Commit

Permalink
chore(deps): update (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored Dec 16, 2020
1 parent 562d121 commit 809ef42
Show file tree
Hide file tree
Showing 17 changed files with 1,623 additions and 1,798 deletions.
1,500 changes: 613 additions & 887 deletions package-lock.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,41 +46,41 @@
},
"dependencies": {
"jest-worker": "^26.6.2",
"p-limit": "^3.0.2",
"p-limit": "^3.1.0",
"schema-utils": "^3.0.0",
"serialize-javascript": "^5.0.1",
"source-map": "^0.6.1",
"terser": "^5.3.8"
"terser": "^5.5.1"
},
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@types/serialize-javascript": "^4.0.0",
"@types/serialize-javascript": "^5.0.0",
"@webpack-contrib/defaults": "^6.3.0",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^26.6.3",
"copy-webpack-plugin": "^6.3.0",
"cross-env": "^7.0.2",
"copy-webpack-plugin": "^7.0.0",
"cross-env": "^7.0.3",
"del": "^6.0.0",
"del-cli": "^3.0.1",
"eslint": "^7.13.0",
"eslint-config-prettier": "^6.15.0",
"eslint": "^7.15.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-import": "^2.22.1",
"file-loader": "^6.2.0",
"husky": "^4.3.0",
"husky": "^4.3.6",
"jest": "^26.6.3",
"lint-staged": "^10.5.1",
"lint-staged": "^10.5.3",
"memfs": "^3.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"prettier": "^2.2.1",
"standard-version": "^9.0.0",
"typescript": "^4.0.5",
"uglify-js": "^3.11.5",
"webpack": "^5.4.0",
"worker-loader": "^3.0.5"
"typescript": "^4.1.3",
"uglify-js": "^3.12.1",
"webpack": "^5.10.3",
"worker-loader": "^3.0.6"
},
"keywords": [
"uglify",
Expand Down
25 changes: 11 additions & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ import { minify as minifyFn } from "./minify";
/** @typedef {import("webpack").Compiler} Compiler */
/** @typedef {import("webpack").Compilation} Compilation */
/** @typedef {import("webpack").Rules} Rules */
/** @typedef {import("webpack").Source} Source */
/** @typedef {import("webpack").WebpackError} WebpackError */
/** @typedef {import("webpack").Asset} Asset */
/** @typedef {import("webpack").AssetInfo} AssetInfo */
/** @typedef {import("terser").ECMA} TerserECMA */
/** @typedef {import("terser").MinifyOptions} TerserMinifyOptions */
/** @typedef {import("jest-worker").default} JestWorker */
/** @typedef {import("source-map").RawSourceMap} SourceMapRawSourceMap */
/** @typedef {import("source-map").RawSourceMap} RawSourceMap */
/** @typedef {import("./minify.js").InternalMinifyOptions} InternalMinifyOptions */
/** @typedef {import("./minify.js").InternalMinifyResult} InternalMinifyResult */

Expand Down Expand Up @@ -59,7 +58,7 @@ import { minify as minifyFn } from "./minify";
/**
* @callback CustomMinifyFunction
* @param {Object.<string, string>} file
* @param {SourceMapRawSourceMap} sourceMap
* @param {RawSourceMap | undefined} sourceMap
* @param {MinifyOptions} minifyOptions
*/

Expand Down Expand Up @@ -191,7 +190,7 @@ class TerserPlugin {
/**
* @param {Compiler} compiler
* @param {Compilation} compilation
* @param {Record<string, Source>} assets
* @param {Record<string, import("webpack").sources.Source>} assets
* @param {{availableNumberOfCores: number}} optimizeOptions
* @returns {Promise<void>}
*/
Expand Down Expand Up @@ -265,17 +264,13 @@ class TerserPlugin {
const workerStdout = initializedWorker.getStdout();

if (workerStdout) {
workerStdout.on("data", (chunk) => {
return process.stdout.write(chunk);
});
workerStdout.on("data", (chunk) => process.stdout.write(chunk));
}

const workerStderr = initializedWorker.getStderr();

if (workerStderr) {
workerStderr.on("data", (chunk) => {
return process.stderr.write(chunk);
});
workerStderr.on("data", (chunk) => process.stderr.write(chunk));
}

return initializedWorker;
Expand Down Expand Up @@ -303,6 +298,7 @@ class TerserPlugin {

if (!output) {
let input;
/** @type {RawSourceMap | undefined} */
let inputSourceMap;

const {
Expand All @@ -314,9 +310,9 @@ class TerserPlugin {

if (map) {
if (TerserPlugin.isSourceMap(map)) {
inputSourceMap = map;
inputSourceMap = /** @type {RawSourceMap} */ (map);
} else {
inputSourceMap = map;
inputSourceMap = /** @type {RawSourceMap} */ (map);

compilation.warnings.push(
/** @type {WebpackError} */
Expand All @@ -329,6 +325,7 @@ class TerserPlugin {
input = input.toString();
}

/** @type {InternalMinifyOptions} */
const options = {
name,
input,
Expand Down Expand Up @@ -364,7 +361,7 @@ class TerserPlugin {
hasSourceMap ? compilation.requestShortener : undefined,
hasSourceMap
? new SourceMapConsumer(
/** @type {SourceMapRawSourceMap} */ (inputSourceMap)
/** @type {RawSourceMap} */ (inputSourceMap)
)
: // eslint-disable-next-line no-undefined
undefined
Expand Down Expand Up @@ -395,7 +392,7 @@ class TerserPlugin {
name,
output.map,
input,
/** @type {SourceMapRawSourceMap} */ (inputSourceMap),
/** @type {RawSourceMap} */ (inputSourceMap),
true
);
} else {
Expand Down
19 changes: 6 additions & 13 deletions src/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const { minify: terserMinify } = require("terser");
* @typedef {Object} InternalMinifyOptions
* @property {string} name
* @property {string} input
* @property {RawSourceMap} inputSourceMap
* @property {RawSourceMap | undefined} inputSourceMap
* @property {ExtractCommentsOptions} extractComments
* @property {CustomMinifyFunction} minify
* @property {CustomMinifyFunction | undefined} minify
* @property {MinifyOptions} minifyOptions
*/

Expand Down Expand Up @@ -135,12 +135,9 @@ function buildComments(extractComments, terserOptions, extractedComments) {
condition[key] = /** @type {ExtractCommentsFunction} */ ((
astNode,
comment
) => {
return (
(comment.type === "comment2" || comment.type === "comment1") &&
/@preserve|@lic|@cc_on|^\**!/i.test(comment.value)
);
});
) =>
(comment.type === "comment2" || comment.type === "comment1") &&
/@preserve|@lic|@cc_on|^\**!/i.test(comment.value));

break;
}
Expand All @@ -150,11 +147,7 @@ function buildComments(extractComments, terserOptions, extractedComments) {
condition[key] = /** @type {ExtractCommentsFunction} */ ((
astNode,
comment
) => {
return new RegExp(/** @type {string} */ (regexStr)).test(
comment.value
);
});
) => new RegExp(/** @type {string} */ (regexStr)).test(comment.value));

break;
default:
Expand Down
Loading

0 comments on commit 809ef42

Please sign in to comment.