Skip to content

Commit e5bee63

Browse files
refactor: types (#625)
1 parent 67f02a5 commit e5bee63

File tree

7 files changed

+60
-55
lines changed

7 files changed

+60
-55
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"prettier": "^2.8.7",
9696
"standard-version": "^9.3.1",
9797
"typescript": "^4.9.5",
98-
"uglify-js": "^3.18.0",
98+
"uglify-js": "^3.19.3",
9999
"webpack": "^5.92.1",
100100
"webpack-cli": "^4.10.0",
101101
"worker-loader": "^3.0.8"

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const { minify } = require("./minify");
9898
* @param {SourceMapInput | undefined} sourceMap
9999
* @param {MinimizerOptions<T>} minifyOptions
100100
* @param {ExtractCommentsOptions | undefined} extractComments
101-
* @returns {Promise<MinimizedResult>}
101+
* @returns {Promise<MinimizedResult> | MinimizedResult}
102102
*/
103103

104104
/**
@@ -124,7 +124,7 @@ const { minify } = require("./minify");
124124

125125
/**
126126
* @template T
127-
* @typedef {JestWorker & { transform: (options: string) => MinimizedResult, minify: (options: InternalOptions<T>) => MinimizedResult }} MinimizerWorker
127+
* @typedef {JestWorker & { transform: (options: string) => Promise<MinimizedResult>, minify: (options: InternalOptions<T>) => Promise<MinimizedResult> }} MinimizerWorker
128128
*/
129129

130130
/**

src/utils.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ function throttleAll(limit, tasks) {
8181
/* istanbul ignore next */
8282
/**
8383
* @param {Input} input
84-
* @param {SourceMapInput | undefined} sourceMap
85-
* @param {CustomOptions} minimizerOptions
86-
* @param {ExtractCommentsOptions | undefined} extractComments
84+
* @param {SourceMapInput} [sourceMap]
85+
* @param {CustomOptions} [minimizerOptions]
86+
* @param {ExtractCommentsOptions} [extractComments]
8787
* @return {Promise<MinimizedResult>}
8888
*/
8989
async function terserMinify(
@@ -334,9 +334,9 @@ terserMinify.supportsWorkerThreads = () => true;
334334
/* istanbul ignore next */
335335
/**
336336
* @param {Input} input
337-
* @param {SourceMapInput | undefined} sourceMap
338-
* @param {CustomOptions} minimizerOptions
339-
* @param {ExtractCommentsOptions | undefined} extractComments
337+
* @param {SourceMapInput} [sourceMap]
338+
* @param {CustomOptions} [minimizerOptions]
339+
* @param {ExtractCommentsOptions} [extractComments]
340340
* @return {Promise<MinimizedResult>}
341341
*/
342342
async function uglifyJsMinify(
@@ -468,10 +468,15 @@ async function uglifyJsMinify(
468468
* @returns {import("uglify-js").MinifyOptions & { sourceMap: undefined } & { output: import("uglify-js").OutputOptions & { beautify: boolean }}}
469469
*/
470470
const buildUglifyJsOptions = (uglifyJsOptions = {}) => {
471-
// eslint-disable-next-line no-param-reassign
472-
delete minimizerOptions.ecma;
473-
// eslint-disable-next-line no-param-reassign
474-
delete minimizerOptions.module;
471+
if (typeof uglifyJsOptions.ecma !== "undefined") {
472+
// eslint-disable-next-line no-param-reassign
473+
delete uglifyJsOptions.ecma;
474+
}
475+
476+
if (typeof uglifyJsOptions.module !== "undefined") {
477+
// eslint-disable-next-line no-param-reassign
478+
delete uglifyJsOptions.module;
479+
}
475480

476481
// Need deep copy objects to avoid https://github.com/terser/terser/issues/366
477482
return {
@@ -557,8 +562,8 @@ uglifyJsMinify.supportsWorkerThreads = () => true;
557562
/* istanbul ignore next */
558563
/**
559564
* @param {Input} input
560-
* @param {SourceMapInput | undefined} sourceMap
561-
* @param {CustomOptions} minimizerOptions
565+
* @param {SourceMapInput} [sourceMap]
566+
* @param {CustomOptions} [minimizerOptions]
562567
* @return {Promise<MinimizedResult>}
563568
*/
564569
async function swcMinify(input, sourceMap, minimizerOptions) {
@@ -663,8 +668,8 @@ swcMinify.supportsWorkerThreads = () => false;
663668
/* istanbul ignore next */
664669
/**
665670
* @param {Input} input
666-
* @param {SourceMapInput | undefined} sourceMap
667-
* @param {CustomOptions} minimizerOptions
671+
* @param {SourceMapInput} [sourceMap]
672+
* @param {CustomOptions} [minimizerOptions]
668673
* @return {Promise<MinimizedResult>}
669674
*/
670675
async function esbuildMinify(input, sourceMap, minimizerOptions) {

0 commit comments

Comments
 (0)