terser-webpack-plugin
Advanced tools
Comparing version 5.2.1 to 5.2.2
@@ -48,10 +48,4 @@ "use strict"; | ||
/** @typedef {import("./utils.js").UglifyJSOptions} UglifyJSOptions */ | ||
/** @typedef {import("./utils.js").CustomOptions} CustomOptions */ | ||
/** @typedef {import("./utils.js").SwcOptions} SwcOptions */ | ||
/** @typedef {import("./utils.js").EsbuildOptions} EsbuildOptions */ | ||
/** @typedef {Object.<any, any>} CustomOptions */ | ||
/** @typedef {import("jest-worker").Worker} JestWorker */ | ||
@@ -111,3 +105,3 @@ | ||
* @property {boolean} [module] | ||
* @property {5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | number | string} [ecma] | ||
* @property {any} [ecma] | ||
*/ | ||
@@ -118,4 +112,4 @@ | ||
* @typedef {Object} MinimizerImplementationAndOptions | ||
* @property {MinimizerImplementation<ThirdArgument<T>>} implementation | ||
* @property {PredefinedOptions & ThirdArgument<T>} options | ||
* @property {MinimizerImplementation<T>} implementation | ||
* @property {PredefinedOptions & T} options | ||
*/ | ||
@@ -159,22 +153,2 @@ | ||
/** | ||
* @typedef {MinimizerImplementation<TerserOptions>} TerserMinimizer | ||
*/ | ||
/** | ||
* @typedef {MinimizerImplementation<UglifyJSOptions>} UglifyJSMinimizer | ||
*/ | ||
/** | ||
* @typedef {MinimizerImplementation<SwcOptions>} SwcMinimizer | ||
*/ | ||
/** | ||
* @typedef {MinimizerImplementation<EsbuildOptions>} EsbuildMinimizer | ||
*/ | ||
/** | ||
* @typedef {MinimizerImplementation<CustomOptions>} CustomMinimizer | ||
*/ | ||
/** | ||
* @typedef {Object} BasePluginOptions | ||
@@ -190,3 +164,3 @@ * @property {Rules} [test] | ||
* @template T | ||
* @typedef {T extends (arg1: any, arg2: any, arg3: infer U, ...args: any[]) => any ? U: never} ThirdArgument | ||
* @typedef {T extends infer U ? U : CustomOptions} InferDefaultType | ||
*/ | ||
@@ -196,19 +170,12 @@ | ||
* @template T | ||
* @typedef {Object} DefaultMinimizerImplementationAndOptions | ||
* @property {undefined | MinimizerImplementation<ThirdArgument<T>>} [minify] | ||
* @property {ThirdArgument<T> | undefined} [terserOptions] | ||
* @typedef {InferDefaultType<T> extends TerserOptions ? { minify?: MinimizerImplementation<InferDefaultType<T>> | undefined, terserOptions?: InferDefaultType<T> | undefined } : { minify: MinimizerImplementation<InferDefaultType<T>>, terserOptions?: InferDefaultType<T> | undefined }} DefinedDefaultMinimizerAndOptions | ||
*/ | ||
// TODO please add manually `T = TerserOptions`, because typescript is not supported default value for templates yet | ||
/** | ||
* @template T | ||
* @typedef {T extends MinimizerImplementation<TerserOptions> ? DefaultMinimizerImplementationAndOptions<T> : { minify: MinimizerImplementation<ThirdArgument<T>>, terserOptions?: ThirdArgument<T> | undefined}} PickMinimizerImplementationAndOptions | ||
*/ | ||
// TODO please add manually `T extends ... = TerserMinimizer`, because typescript is not supported default value for templates yet | ||
/** | ||
* @template {TerserMinimizer | UglifyJSMinimizer | SwcMinimizer | EsbuildMinimizer | CustomMinimizer} T=TerserMinimizer | ||
*/ | ||
class TerserPlugin { | ||
/** | ||
* @param {BasePluginOptions & PickMinimizerImplementationAndOptions<T>} [options] | ||
* @param {BasePluginOptions & DefinedDefaultMinimizerAndOptions<T>} [options] | ||
*/ | ||
@@ -219,3 +186,4 @@ constructor(options) { | ||
baseDataPath: "options" | ||
}); | ||
}); // TODO make `minimizer` option instead `minify` and `terserOptions` in the next major release, also rename `terserMinify` to `terserMinimize` | ||
const { | ||
@@ -230,6 +198,2 @@ minify = _utils.terserMinify, | ||
} = options || {}; | ||
/** | ||
* @type {BasePluginOptions & { minify: MinimizerImplementation<ThirdArgument<T>>, terserOptions: ThirdArgument<T>}} | ||
*/ | ||
this.options = { | ||
@@ -241,4 +205,6 @@ test, | ||
exclude, | ||
minify, | ||
terserOptions | ||
minimizer: { | ||
implementation: minify, | ||
options: terserOptions | ||
} | ||
}; | ||
@@ -492,5 +458,3 @@ } | ||
} | ||
/** @type {InternalOptions<T>} */ | ||
const options = { | ||
@@ -500,6 +464,6 @@ name, | ||
inputSourceMap, | ||
// TODO make `minimizer` option instead `minify` and `terserOptions` in the next major release, also rename `terserMinify` to `terserMinimize` | ||
minimizer: { | ||
implementation: this.options.minify, | ||
options: { ...this.options.terserOptions | ||
implementation: this.options.minimizer.implementation, | ||
// @ts-ignore https://github.com/Microsoft/TypeScript/issues/10727 | ||
options: { ...this.options.minimizer.options | ||
} | ||
@@ -773,4 +737,4 @@ }, | ||
const data = (0, _serializeJavascript.default)({ | ||
minimizer: typeof this.options.minify.getMinimizerVersion !== "undefined" ? this.options.minify.getMinimizerVersion() || "0.0.0" : "0.0.0", | ||
options: this.options.terserOptions | ||
minimizer: typeof this.options.minimizer.implementation.getMinimizerVersion !== "undefined" ? this.options.minimizer.implementation.getMinimizerVersion() || "0.0.0" : "0.0.0", | ||
options: this.options.minimizer.options | ||
}); | ||
@@ -777,0 +741,0 @@ hooks.chunkHash.tap(pluginName, (chunk, hash) => { |
@@ -5,2 +5,4 @@ "use strict"; | ||
/** @typedef {import("./index.js").CustomOptions} CustomOptions */ | ||
/** | ||
@@ -7,0 +9,0 @@ * @template T |
@@ -18,12 +18,3 @@ "use strict"; | ||
/** @typedef {import("terser").ECMA} TerserECMA */ | ||
// TODO do not forget to add `// @ts-ignore` on optional peer dependencies to avoid problem with `TS2307: Cannot find module 'module' or its corresponding type declarations.` | ||
/** @typedef {import("uglify-js").OutputOptions} UglifyJSOutputOptions */ | ||
/** @typedef {import("uglify-js").MinifyOptions} UglifyJSOptions */ | ||
/** @typedef {import("@swc/core").JsMinifyOptions} SwcOptions */ | ||
/** @typedef {import("esbuild").TransformOptions} EsbuildOptions */ | ||
/** @typedef {import("./index.js").ExtractCommentsOptions} ExtractCommentsOptions */ | ||
@@ -42,14 +33,6 @@ | ||
/** | ||
* @typedef {TerserOptions & { sourceMap: undefined } & ({ output: TerserFormatOptions & { beautify: boolean } } | { format: TerserFormatOptions & { beautify: boolean } })} NormalizedTerserOptions | ||
* @typedef {{ [key: string]: any }} CustomOptions | ||
*/ | ||
/** | ||
* @typedef {UglifyJSOptions & { sourceMap: undefined } & { output: UglifyJSOutputOptions & { beautify: boolean } }} NormalizedUglifyJSOptions | ||
*/ | ||
/** | ||
* @typedef {SwcOptions & { sourceMap: undefined }} NormalizedSwcOptions | ||
*/ | ||
/** | ||
* @typedef {Array<string>} ExtractedComments | ||
@@ -63,3 +46,3 @@ */ | ||
* @param {RawSourceMap | undefined} sourceMap | ||
* @param {PredefinedOptions & TerserOptions} minimizerOptions | ||
* @param {PredefinedOptions & CustomOptions} minimizerOptions | ||
* @param {ExtractCommentsOptions | undefined} extractComments | ||
@@ -78,3 +61,3 @@ * @return {Promise<MinimizedResult>} | ||
/** | ||
* @param {NormalizedTerserOptions} terserOptions | ||
* @param {TerserOptions & { sourceMap: undefined } & ({ output: TerserFormatOptions & { beautify: boolean } } | { format: TerserFormatOptions & { beautify: boolean } })} terserOptions | ||
* @param {ExtractedComments} extractedComments | ||
@@ -181,4 +164,4 @@ * @returns {ExtractCommentsFunction} | ||
/** | ||
* @param {TerserOptions} [terserOptions={}] | ||
* @returns {NormalizedTerserOptions} | ||
* @param {PredefinedOptions & TerserOptions} [terserOptions={}] | ||
* @returns {TerserOptions & { sourceMap: undefined } & ({ output: TerserFormatOptions & { beautify: boolean } } | { format: TerserFormatOptions & { beautify: boolean } })} | ||
*/ | ||
@@ -280,3 +263,3 @@ | ||
* @param {RawSourceMap | undefined} sourceMap | ||
* @param {PredefinedOptions & UglifyJSOptions} minimizerOptions | ||
* @param {PredefinedOptions & CustomOptions} minimizerOptions | ||
* @param {ExtractCommentsOptions | undefined} extractComments | ||
@@ -297,3 +280,3 @@ * @return {Promise<MinimizedResult>} | ||
/** | ||
* @param {NormalizedUglifyJSOptions} uglifyJsOptions | ||
* @param {import("uglify-js").MinifyOptions & { sourceMap: undefined } & { output: import("uglify-js").OutputOptions & { beautify: boolean }}} uglifyJsOptions | ||
* @param {ExtractedComments} extractedComments | ||
@@ -391,4 +374,4 @@ * @returns {ExtractCommentsFunction} | ||
/** | ||
* @param {UglifyJSOptions} [uglifyJsOptions={}] | ||
* @returns {NormalizedUglifyJSOptions} | ||
* @param {PredefinedOptions & import("uglify-js").MinifyOptions} [uglifyJsOptions={}] | ||
* @returns {import("uglify-js").MinifyOptions & { sourceMap: undefined } & { output: import("uglify-js").OutputOptions & { beautify: boolean }}} | ||
*/ | ||
@@ -398,3 +381,7 @@ | ||
const buildUglifyJsOptions = (uglifyJsOptions = {}) => { | ||
// Need deep copy objects to avoid https://github.com/terser/terser/issues/366 | ||
// eslint-disable-next-line no-param-reassign | ||
delete minimizerOptions.ecma; // eslint-disable-next-line no-param-reassign | ||
delete minimizerOptions.module; // Need deep copy objects to avoid https://github.com/terser/terser/issues/366 | ||
return { ...uglifyJsOptions, | ||
@@ -425,9 +412,5 @@ // warnings: uglifyJsOptions.warnings, | ||
minify | ||
} = require("uglify-js"); // eslint-disable-next-line no-param-reassign | ||
} = require("uglify-js"); // Copy `uglify-js` options | ||
delete minimizerOptions.ecma; // eslint-disable-next-line no-param-reassign | ||
delete minimizerOptions.module; // Copy `uglify-js` options | ||
const uglifyJsOptions = buildUglifyJsOptions(minimizerOptions); // Let terser generate a SourceMap | ||
@@ -479,3 +462,3 @@ | ||
* @param {RawSourceMap | undefined} sourceMap | ||
* @param {PredefinedOptions & SwcOptions} minimizerOptions | ||
* @param {PredefinedOptions & CustomOptions} minimizerOptions | ||
* @return {Promise<MinimizedResult>} | ||
@@ -487,4 +470,4 @@ */ | ||
/** | ||
* @param {SwcOptions} [swcOptions={}] | ||
* @returns {NormalizedSwcOptions} | ||
* @param {PredefinedOptions & import("@swc/core").JsMinifyOptions} [swcOptions={}] | ||
* @returns {import("@swc/core").JsMinifyOptions & { sourceMap: undefined }} | ||
*/ | ||
@@ -557,3 +540,3 @@ const buildSwcOptions = (swcOptions = {}) => { | ||
* @param {RawSourceMap | undefined} sourceMap | ||
* @param {PredefinedOptions & EsbuildOptions} minimizerOptions | ||
* @param {PredefinedOptions & CustomOptions} minimizerOptions | ||
* @return {Promise<MinimizedResult>} | ||
@@ -565,7 +548,17 @@ */ | ||
/** | ||
* @param {EsbuildOptions} [esbuildOptions={}] | ||
* @returns {EsbuildOptions} | ||
* @param {PredefinedOptions & import("esbuild").TransformOptions} [esbuildOptions={}] | ||
* @returns {import("esbuild").TransformOptions} | ||
*/ | ||
const buildEsbuildOptions = (esbuildOptions = {}) => { | ||
// Need deep copy objects to avoid https://github.com/terser/terser/issues/366 | ||
// eslint-disable-next-line no-param-reassign | ||
delete esbuildOptions.ecma; | ||
if (esbuildOptions.module) { | ||
// eslint-disable-next-line no-param-reassign | ||
esbuildOptions.format = "esm"; | ||
} // eslint-disable-next-line no-param-reassign | ||
delete esbuildOptions.module; // Need deep copy objects to avoid https://github.com/terser/terser/issues/366 | ||
return { | ||
@@ -580,15 +573,5 @@ minify: true, | ||
const esbuild = require("esbuild"); // eslint-disable-next-line no-param-reassign | ||
const esbuild = require("esbuild"); // Copy `swc` options | ||
delete minimizerOptions.ecma; | ||
if (minimizerOptions.module) { | ||
// eslint-disable-next-line no-param-reassign | ||
minimizerOptions.format = "esm"; | ||
} // eslint-disable-next-line no-param-reassign | ||
delete minimizerOptions.module; // Copy `swc` options | ||
const esbuildOptions = buildEsbuildOptions(minimizerOptions); // Let `swc` generate a SourceMap | ||
@@ -595,0 +578,0 @@ |
{ | ||
"name": "terser-webpack-plugin", | ||
"version": "5.2.1", | ||
"version": "5.2.2", | ||
"description": "Terser plugin for webpack", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -679,3 +679,6 @@ <div align="center"> | ||
```ts | ||
import type { SwcMinifyFunction } from "terser-webpack-plugin"; | ||
import type { JsMinifyOptions as SwcOptions } from "@swc/core"; | ||
import type { MinifyOptions as UglifyJSOptions } from "uglify-js"; | ||
import type { TransformOptions as EsbuildOptions } from "esbuild"; | ||
import type { MinifyOptions as TerserOptions } from "terser"; | ||
@@ -686,14 +689,26 @@ module.exports = { | ||
minimizer: [ | ||
new TerserPlugin<SwcMinimizer>({ | ||
new TerserPlugin<SwcOptions>({ | ||
minify: TerserPlugin.swcMinify, | ||
terserOptions: { | ||
compress: true, | ||
// `swc` options | ||
}, | ||
}), | ||
new TerserPlugin<UglifyJSOptions>({ | ||
minify: TerserPlugin.uglifyJsMinify, | ||
terserOptions: { | ||
// `uglif-js` options | ||
}, | ||
}), | ||
new TerserPlugin<EsbuildOptions>({ | ||
minify: TerserPlugin.esbuildMinify, | ||
terserOptions: { | ||
// `esbuild` options | ||
}, | ||
}), | ||
// Alternative: | ||
new TerserPlugin<typeof TerserPlugin.swcMinify>({ | ||
minify: TerserPlugin.swcMinify, | ||
// Alternative usage: | ||
new TerserPlugin<TerserOptions>({ | ||
minify: TerserPlugin.terserMinify, | ||
terserOptions: { | ||
compress: true, | ||
// `terser` options | ||
}, | ||
@@ -700,0 +715,0 @@ }), |
@@ -9,6 +9,3 @@ export default TerserPlugin; | ||
export type TerserOptions = import("./utils.js").TerserOptions; | ||
export type UglifyJSOptions = import("./utils.js").UglifyJSOptions; | ||
export type SwcOptions = import("./utils.js").SwcOptions; | ||
export type EsbuildOptions = import("./utils.js").EsbuildOptions; | ||
export type CustomOptions = any; | ||
export type CustomOptions = import("./utils.js").CustomOptions; | ||
export type JestWorker = import("jest-worker").Worker; | ||
@@ -59,7 +56,7 @@ export type RawSourceMap = import("source-map").RawSourceMap; | ||
module?: boolean | undefined; | ||
ecma?: string | number | undefined; | ||
ecma?: any; | ||
}; | ||
export type MinimizerImplementationAndOptions<T> = { | ||
implementation: MinimizerImplementation<ThirdArgument<T>>; | ||
options: PredefinedOptions & ThirdArgument<T>; | ||
implementation: MinimizerImplementation<T>; | ||
options: PredefinedOptions & T; | ||
}; | ||
@@ -88,7 +85,2 @@ export type InternalOptions<T> = { | ||
MinimizeFunctionHelpers; | ||
export type TerserMinimizer = MinimizerImplementation<TerserOptions>; | ||
export type UglifyJSMinimizer = MinimizerImplementation<UglifyJSOptions>; | ||
export type SwcMinimizer = MinimizerImplementation<SwcOptions>; | ||
export type EsbuildMinimizer = MinimizerImplementation<EsbuildOptions>; | ||
export type CustomMinimizer = MinimizerImplementation<CustomOptions>; | ||
export type BasePluginOptions = { | ||
@@ -101,20 +93,14 @@ test?: Rules | undefined; | ||
}; | ||
export type ThirdArgument<T> = T extends ( | ||
arg1: any, | ||
arg2: any, | ||
arg3: infer U, | ||
...args: any[] | ||
) => any | ||
export type InferDefaultType<T> = T extends infer U | ||
? U | ||
: never; | ||
export type DefaultMinimizerImplementationAndOptions<T> = { | ||
minify?: undefined | MinimizerImplementation<ThirdArgument<T>>; | ||
terserOptions?: ThirdArgument<T> | undefined; | ||
}; | ||
export type PickMinimizerImplementationAndOptions<T> = | ||
T extends MinimizerImplementation<TerserOptions> | ||
? DefaultMinimizerImplementationAndOptions<T> | ||
: import("./utils").CustomOptions; | ||
export type DefinedDefaultMinimizerAndOptions<T> = | ||
InferDefaultType<T> extends TerserOptions | ||
? { | ||
minify?: MinimizerImplementation<InferDefaultType<T>> | undefined; | ||
terserOptions?: InferDefaultType<T> | undefined; | ||
} | ||
: { | ||
minify: MinimizerImplementation<ThirdArgument<T>>; | ||
terserOptions?: ThirdArgument<T> | undefined; | ||
minify: MinimizerImplementation<InferDefaultType<T>>; | ||
terserOptions?: InferDefaultType<T> | undefined; | ||
}; | ||
@@ -128,6 +114,3 @@ /** @typedef {import("schema-utils/declarations/validate").Schema} Schema */ | ||
/** @typedef {import("./utils.js").TerserOptions} TerserOptions */ | ||
/** @typedef {import("./utils.js").UglifyJSOptions} UglifyJSOptions */ | ||
/** @typedef {import("./utils.js").SwcOptions} SwcOptions */ | ||
/** @typedef {import("./utils.js").EsbuildOptions} EsbuildOptions */ | ||
/** @typedef {Object.<any, any>} CustomOptions */ | ||
/** @typedef {import("./utils.js").CustomOptions} CustomOptions */ | ||
/** @typedef {import("jest-worker").Worker} JestWorker */ | ||
@@ -175,3 +158,3 @@ /** @typedef {import("source-map").RawSourceMap} RawSourceMap */ | ||
* @property {boolean} [module] | ||
* @property {5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | number | string} [ecma] | ||
* @property {any} [ecma] | ||
*/ | ||
@@ -181,4 +164,4 @@ /** | ||
* @typedef {Object} MinimizerImplementationAndOptions | ||
* @property {MinimizerImplementation<ThirdArgument<T>>} implementation | ||
* @property {PredefinedOptions & ThirdArgument<T>} options | ||
* @property {MinimizerImplementation<T>} implementation | ||
* @property {PredefinedOptions & T} options | ||
*/ | ||
@@ -216,17 +199,2 @@ /** | ||
/** | ||
* @typedef {MinimizerImplementation<TerserOptions>} TerserMinimizer | ||
*/ | ||
/** | ||
* @typedef {MinimizerImplementation<UglifyJSOptions>} UglifyJSMinimizer | ||
*/ | ||
/** | ||
* @typedef {MinimizerImplementation<SwcOptions>} SwcMinimizer | ||
*/ | ||
/** | ||
* @typedef {MinimizerImplementation<EsbuildOptions>} EsbuildMinimizer | ||
*/ | ||
/** | ||
* @typedef {MinimizerImplementation<CustomOptions>} CustomMinimizer | ||
*/ | ||
/** | ||
* @typedef {Object} BasePluginOptions | ||
@@ -241,25 +209,12 @@ * @property {Rules} [test] | ||
* @template T | ||
* @typedef {T extends (arg1: any, arg2: any, arg3: infer U, ...args: any[]) => any ? U: never} ThirdArgument | ||
* @typedef {T extends infer U ? U : CustomOptions} InferDefaultType | ||
*/ | ||
/** | ||
* @template T | ||
* @typedef {Object} DefaultMinimizerImplementationAndOptions | ||
* @property {undefined | MinimizerImplementation<ThirdArgument<T>>} [minify] | ||
* @property {ThirdArgument<T> | undefined} [terserOptions] | ||
* @typedef {InferDefaultType<T> extends TerserOptions ? { minify?: MinimizerImplementation<InferDefaultType<T>> | undefined, terserOptions?: InferDefaultType<T> | undefined } : { minify: MinimizerImplementation<InferDefaultType<T>>, terserOptions?: InferDefaultType<T> | undefined }} DefinedDefaultMinimizerAndOptions | ||
*/ | ||
/** | ||
* @template T | ||
* @typedef {T extends MinimizerImplementation<TerserOptions> ? DefaultMinimizerImplementationAndOptions<T> : { minify: MinimizerImplementation<ThirdArgument<T>>, terserOptions?: ThirdArgument<T> | undefined}} PickMinimizerImplementationAndOptions | ||
*/ | ||
/** | ||
* @template {TerserMinimizer | UglifyJSMinimizer | SwcMinimizer | EsbuildMinimizer | CustomMinimizer} T=TerserMinimizer | ||
*/ | ||
declare class TerserPlugin< | ||
T extends | ||
| TerserMinimizer | ||
| UglifyJSMinimizer | ||
| SwcMinimizer | ||
| EsbuildMinimizer | ||
| CustomMinimizer | ||
> { | ||
declare class TerserPlugin<T> { | ||
/** | ||
@@ -300,15 +255,21 @@ * @private | ||
/** | ||
* @param {BasePluginOptions & PickMinimizerImplementationAndOptions<T>} [options] | ||
* @param {BasePluginOptions & DefinedDefaultMinimizerAndOptions<T>} [options] | ||
*/ | ||
constructor( | ||
options?: | ||
| (BasePluginOptions & PickMinimizerImplementationAndOptions<T>) | ||
| (BasePluginOptions & DefinedDefaultMinimizerAndOptions<T>) | ||
| undefined | ||
); | ||
/** | ||
* @type {BasePluginOptions & { minify: MinimizerImplementation<ThirdArgument<T>>, terserOptions: ThirdArgument<T>}} | ||
*/ | ||
options: BasePluginOptions & { | ||
minify: MinimizerImplementation<ThirdArgument<T>>; | ||
terserOptions: ThirdArgument<T>; | ||
options: { | ||
test: Rules; | ||
extractComments: ExtractCommentsOptions; | ||
parallel: boolean; | ||
include: Rules | undefined; | ||
exclude: Rules | undefined; | ||
minimizer: { | ||
implementation: MinimizerImplementation< | ||
import("terser").MinifyOptions & InferDefaultType<T> | ||
>; | ||
options: InferDefaultType<T>; | ||
}; | ||
}; | ||
@@ -315,0 +276,0 @@ /** |
export type MinimizedResult = import("./index.js").MinimizedResult; | ||
export type CustomOptions = import("./index.js").CustomOptions; | ||
/** @typedef {import("./index.js").MinimizedResult} MinimizedResult */ | ||
/** @typedef {import("./index.js").CustomOptions} CustomOptions */ | ||
/** | ||
@@ -4,0 +6,0 @@ * @template T |
@@ -5,6 +5,2 @@ export type RawSourceMap = import("source-map").RawSourceMap; | ||
export type TerserECMA = import("terser").ECMA; | ||
export type UglifyJSOutputOptions = import("uglify-js").OutputOptions; | ||
export type UglifyJSOptions = import("uglify-js").MinifyOptions; | ||
export type SwcOptions = import("@swc/core").JsMinifyOptions; | ||
export type EsbuildOptions = import("esbuild").TransformOptions; | ||
export type ExtractCommentsOptions = | ||
@@ -19,26 +15,5 @@ import("./index.js").ExtractCommentsOptions; | ||
export type PredefinedOptions = import("./index.js").PredefinedOptions; | ||
export type NormalizedTerserOptions = TerserOptions & { | ||
sourceMap: undefined; | ||
} & ( | ||
| { | ||
output: TerserFormatOptions & { | ||
beautify: boolean; | ||
}; | ||
} | ||
| { | ||
format: TerserFormatOptions & { | ||
beautify: boolean; | ||
}; | ||
} | ||
); | ||
export type NormalizedUglifyJSOptions = UglifyJSOptions & { | ||
sourceMap: undefined; | ||
} & { | ||
output: UglifyJSOutputOptions & { | ||
beautify: boolean; | ||
}; | ||
export type CustomOptions = { | ||
[key: string]: any; | ||
}; | ||
export type NormalizedSwcOptions = SwcOptions & { | ||
sourceMap: undefined; | ||
}; | ||
export type ExtractedComments = Array<string>; | ||
@@ -49,6 +24,2 @@ /** @typedef {import("source-map").RawSourceMap} RawSourceMap */ | ||
/** @typedef {import("terser").ECMA} TerserECMA */ | ||
/** @typedef {import("uglify-js").OutputOptions} UglifyJSOutputOptions */ | ||
/** @typedef {import("uglify-js").MinifyOptions} UglifyJSOptions */ | ||
/** @typedef {import("@swc/core").JsMinifyOptions} SwcOptions */ | ||
/** @typedef {import("esbuild").TransformOptions} EsbuildOptions */ | ||
/** @typedef {import("./index.js").ExtractCommentsOptions} ExtractCommentsOptions */ | ||
@@ -61,11 +32,5 @@ /** @typedef {import("./index.js").ExtractCommentsFunction} ExtractCommentsFunction */ | ||
/** | ||
* @typedef {TerserOptions & { sourceMap: undefined } & ({ output: TerserFormatOptions & { beautify: boolean } } | { format: TerserFormatOptions & { beautify: boolean } })} NormalizedTerserOptions | ||
* @typedef {{ [key: string]: any }} CustomOptions | ||
*/ | ||
/** | ||
* @typedef {UglifyJSOptions & { sourceMap: undefined } & { output: UglifyJSOutputOptions & { beautify: boolean } }} NormalizedUglifyJSOptions | ||
*/ | ||
/** | ||
* @typedef {SwcOptions & { sourceMap: undefined }} NormalizedSwcOptions | ||
*/ | ||
/** | ||
* @typedef {Array<string>} ExtractedComments | ||
@@ -76,3 +41,3 @@ */ | ||
* @param {RawSourceMap | undefined} sourceMap | ||
* @param {PredefinedOptions & TerserOptions} minimizerOptions | ||
* @param {PredefinedOptions & CustomOptions} minimizerOptions | ||
* @param {ExtractCommentsOptions | undefined} extractComments | ||
@@ -84,3 +49,3 @@ * @return {Promise<MinimizedResult>} | ||
sourceMap: RawSourceMap | undefined, | ||
minimizerOptions: PredefinedOptions & TerserOptions, | ||
minimizerOptions: PredefinedOptions & CustomOptions, | ||
extractComments: ExtractCommentsOptions | undefined | ||
@@ -97,3 +62,3 @@ ): Promise<MinimizedResult>; | ||
* @param {RawSourceMap | undefined} sourceMap | ||
* @param {PredefinedOptions & UglifyJSOptions} minimizerOptions | ||
* @param {PredefinedOptions & CustomOptions} minimizerOptions | ||
* @param {ExtractCommentsOptions | undefined} extractComments | ||
@@ -105,3 +70,3 @@ * @return {Promise<MinimizedResult>} | ||
sourceMap: RawSourceMap | undefined, | ||
minimizerOptions: PredefinedOptions & UglifyJSOptions, | ||
minimizerOptions: PredefinedOptions & CustomOptions, | ||
extractComments: ExtractCommentsOptions | undefined | ||
@@ -118,3 +83,3 @@ ): Promise<MinimizedResult>; | ||
* @param {RawSourceMap | undefined} sourceMap | ||
* @param {PredefinedOptions & SwcOptions} minimizerOptions | ||
* @param {PredefinedOptions & CustomOptions} minimizerOptions | ||
* @return {Promise<MinimizedResult>} | ||
@@ -125,3 +90,3 @@ */ | ||
sourceMap: RawSourceMap | undefined, | ||
minimizerOptions: PredefinedOptions & SwcOptions | ||
minimizerOptions: PredefinedOptions & CustomOptions | ||
): Promise<MinimizedResult>; | ||
@@ -137,3 +102,3 @@ export namespace swcMinify { | ||
* @param {RawSourceMap | undefined} sourceMap | ||
* @param {PredefinedOptions & EsbuildOptions} minimizerOptions | ||
* @param {PredefinedOptions & CustomOptions} minimizerOptions | ||
* @return {Promise<MinimizedResult>} | ||
@@ -144,3 +109,3 @@ */ | ||
sourceMap: RawSourceMap | undefined, | ||
minimizerOptions: PredefinedOptions & EsbuildOptions | ||
minimizerOptions: PredefinedOptions & CustomOptions | ||
): Promise<MinimizedResult>; | ||
@@ -147,0 +112,0 @@ export namespace esbuildMinify { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
743
87234
1710