Socket
Socket
Sign inDemoInstall

terser-webpack-plugin

Package Overview
Dependencies
76
Maintainers
3
Versions
77
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.2.5 to 5.3.0

165

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
const path = require("path");
var path = _interopRequireWildcard(require("path"));
const os = require("os");
var os = _interopRequireWildcard(require("os"));
const {
SourceMapConsumer
} = require("source-map");
var _sourceMap = require("source-map");
const {
validate
} = require("schema-utils");
var _schemaUtils = require("schema-utils");
const serialize = require("serialize-javascript");
var _serializeJavascript = _interopRequireDefault(require("serialize-javascript"));
const {
Worker
} = require("jest-worker");
var _jestWorker = require("jest-worker");
const {
throttleAll,
terserMinify,
uglifyJsMinify,
swcMinify,
esbuildMinify
} = require("./utils");
var _utils = require("./utils");
const schema = require("./options.json");
var schema = _interopRequireWildcard(require("./options.json"));
var _minify = require("./minify");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const {
minify
} = require("./minify");
/** @typedef {import("schema-utils/declarations/validate").Schema} Schema */

@@ -46,4 +48,2 @@

/** @typedef {import("./utils.js").CustomOptions} CustomOptions */
/** @typedef {import("jest-worker").Worker} JestWorker */

@@ -88,6 +88,2 @@

/**
* @typedef {{ [file: string]: string }} Input
*/
/**
* @typedef {Object} MinimizedResult

@@ -102,12 +98,7 @@ * @property {string} code

/**
* @typedef {Object} PredefinedOptions
* @property {boolean} [module]
* @property {any} [ecma]
* @typedef {{ [file: string]: string }} Input
*/
/**
* @template T
* @typedef {Object} MinimizerImplementationAndOptions
* @property {MinimizerImplementation<T>} implementation
* @property {PredefinedOptions & T} options
* @typedef {{ [key: string]: any }} CustomOptions
*/

@@ -117,13 +108,14 @@

* @template T
* @typedef {Object} InternalOptions
* @property {string} name
* @property {string} input
* @property {RawSourceMap | undefined} inputSourceMap
* @property {ExtractCommentsOptions | undefined} extractComments
* @property {MinimizerImplementationAndOptions<T>} minimizer
* @typedef {T extends infer U ? U : CustomOptions} InferDefaultType
*/
/**
* @typedef {Object} PredefinedOptions
* @property {boolean} [module]
* @property {any} [ecma]
*/
/**
* @template T
* @typedef {JestWorker & { transform: (options: string) => MinimizedResult, minify: (options: InternalOptions<T>) => MinimizedResult }} MinimizerWorker
* @typedef {PredefinedOptions & InferDefaultType<T>} MinimizerOptions
*/

@@ -136,3 +128,3 @@

* @param {RawSourceMap | undefined} sourceMap
* @param {T} minifyOptions
* @param {MinimizerOptions<T>} minifyOptions
* @param {ExtractCommentsOptions | undefined} extractComments

@@ -149,6 +141,21 @@ * @returns {Promise<MinimizedResult>}

* @template T
* @typedef {BasicMinimizerImplementation<T> & MinimizeFunctionHelpers } MinimizerImplementation
* @typedef {BasicMinimizerImplementation<T> & MinimizeFunctionHelpers} MinimizerImplementation
*/
/**
* @template T
* @typedef {Object} InternalOptions
* @property {string} name
* @property {string} input
* @property {RawSourceMap | undefined} inputSourceMap
* @property {ExtractCommentsOptions | undefined} extractComments
* @property {{ implementation: MinimizerImplementation<T>, options: MinimizerOptions<T> }} minimizer
*/
/**
* @template T
* @typedef {JestWorker & { transform: (options: string) => MinimizedResult, minify: (options: InternalOptions<T>) => MinimizedResult }} MinimizerWorker
*/
/**
* @typedef {undefined | boolean | number} Parallel

@@ -168,3 +175,3 @@ */

* @template T
* @typedef {T extends infer U ? U : CustomOptions} InferDefaultType
* @typedef {T extends TerserOptions ? { minify?: MinimizerImplementation<T> | undefined, terserOptions?: MinimizerOptions<T> | undefined } : { minify: MinimizerImplementation<T>, terserOptions?: MinimizerOptions<T> | undefined }} DefinedDefaultMinimizerAndOptions
*/

@@ -174,8 +181,10 @@

* @template T
* @typedef {InferDefaultType<T> extends TerserOptions ? { minify?: MinimizerImplementation<InferDefaultType<T>> | undefined, terserOptions?: InferDefaultType<T> | undefined } : { minify: MinimizerImplementation<InferDefaultType<T>>, terserOptions?: InferDefaultType<T> | undefined }} DefinedDefaultMinimizerAndOptions
* @typedef {BasePluginOptions & { minimizer: { implementation: MinimizerImplementation<T>, options: MinimizerOptions<T> } }} InternalPluginOptions
*/
/**
* @template T
* @template [T=TerserOptions]
*/
class TerserPlugin {

@@ -186,3 +195,3 @@ /**

constructor(options) {
(0, _schemaUtils.validate)(
validate(
/** @type {Schema} */

@@ -196,6 +205,6 @@ schema, options || {}, {

minify =
/** @type {MinimizerImplementation<InferDefaultType<T>>} */
_utils.terserMinify,
/** @type {MinimizerImplementation<T>} */
terserMinify,
terserOptions =
/** @type {InferDefaultType<T>} */
/** @type {MinimizerOptions<T>} */
{},

@@ -208,2 +217,7 @@ test = /\.[cm]?js(\?.*)?$/i,

} = options || {};
/**
* @private
* @type {InternalPluginOptions<T>}
*/
this.options = {

@@ -235,3 +249,3 @@ test,

* @private
* @param {Error | string} warning
* @param {unknown} warning
* @param {string} file

@@ -265,3 +279,3 @@ * @returns {Error}

/**
* @type {Error & { file: string }}
* @type {Error & { file?: string }}
*/

@@ -271,3 +285,2 @@ let builtError;

if (typeof error === "string") {
// @ts-ignore
builtError = new Error(`${file} from Terser plugin\n${error}`);

@@ -285,9 +298,7 @@ builtError.file = file;

if (original && original.source && requestShortener) {
// @ts-ignore
builtError = new Error(`${file} from Terser plugin\n${error.message} [${requestShortener.shorten(original.source)}:${original.line},${original.column}][${file}:${error.line},${error.col}]${error.stack ? `\n${error.stack.split("\n").slice(1).join("\n")}` : ""}`);
builtError.file = file;
return builtError;
} // @ts-ignore
}
builtError = new Error(`${file} from Terser plugin\n${error.message} [${file}:${error.line},${error.col}]${error.stack ? `\n${error.stack.split("\n").slice(1).join("\n")}` : ""}`);

@@ -299,9 +310,7 @@ builtError.file = file;

if (error.stack) {
// @ts-ignore
builtError = new Error(`${file} from Terser plugin\n${typeof error.message !== "undefined" ? error.message : ""}\n${error.stack}`);
builtError.file = file;
return builtError;
} // @ts-ignore
}
builtError = new Error(`${file} from Terser plugin\n${error.message}`);

@@ -407,3 +416,3 @@ builtError.file = file;

/** @type {MinimizerWorker<T>} */
new _jestWorker.Worker(require.resolve("./minify"), {
new Worker(require.resolve("./minify"), {
numWorkers: numberOfWorkers,

@@ -465,6 +474,6 @@ enableWorkerThreads: true

if (map) {
if (TerserPlugin.isSourceMap(map)) {
inputSourceMap =
/** @type {RawSourceMap} */
map;
if (!TerserPlugin.isSourceMap(map)) {
compilation.warnings.push(
/** @type {WebpackError} */
new Error(`${name} contains invalid source map`));
} else {

@@ -474,5 +483,2 @@ inputSourceMap =

map;
compilation.warnings.push(
/** @type {WebpackError} */
new Error(`${name} contains invalid source map`));
}

@@ -484,3 +490,7 @@ }

}
/**
* @type {InternalOptions<T>}
*/
const options = {

@@ -514,3 +524,3 @@ name,

try {
output = await (getWorker ? getWorker().transform((0, _serializeJavascript.default)(options)) : (0, _minify.minify)(options));
output = await (getWorker ? getWorker().transform(serialize(options)) : minify(options));
} catch (error) {

@@ -520,3 +530,3 @@ const hasSourceMap = inputSourceMap && TerserPlugin.isSourceMap(inputSourceMap);

/** @type {WebpackError} */
TerserPlugin.buildError(error, name, hasSourceMap ? new _sourceMap.SourceMapConsumer(
TerserPlugin.buildError(error, name, hasSourceMap ? new SourceMapConsumer(
/** @type {RawSourceMap} */

@@ -550,3 +560,3 @@ inputSourceMap) : // eslint-disable-next-line no-undefined

*/
item => TerserPlugin.buildError(item, name, hasSourceMap ? new _sourceMap.SourceMapConsumer(
item => TerserPlugin.buildError(item, name, hasSourceMap ? new SourceMapConsumer(
/** @type {RawSourceMap} */

@@ -674,3 +684,3 @@ inputSourceMap) : // eslint-disable-next-line no-undefined

numberOfWorkers : scheduledTasks.length;
await (0, _utils.throttleAll)(limit, scheduledTasks);
await throttleAll(limit, scheduledTasks);

@@ -778,3 +788,3 @@ if (initializedWorker) {

const hooks = compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation);
const data = (0, _serializeJavascript.default)({
const data = serialize({
minimizer: typeof this.options.minimizer.implementation.getMinimizerVersion !== "undefined" ? this.options.minimizer.implementation.getMinimizerVersion() || "0.0.0" : "0.0.0",

@@ -809,7 +819,6 @@ options: this.options.minimizer.options

TerserPlugin.terserMinify = _utils.terserMinify;
TerserPlugin.uglifyJsMinify = _utils.uglifyJsMinify;
TerserPlugin.swcMinify = _utils.swcMinify;
TerserPlugin.esbuildMinify = _utils.esbuildMinify;
var _default = TerserPlugin;
exports.default = _default;
TerserPlugin.terserMinify = terserMinify;
TerserPlugin.uglifyJsMinify = uglifyJsMinify;
TerserPlugin.swcMinify = swcMinify;
TerserPlugin.esbuildMinify = esbuildMinify;
module.exports = TerserPlugin;

@@ -47,3 +47,5 @@ "use strict";

module.exports.minify = minify;
module.exports.transform = transform;
module.exports = {
minify,
transform
};
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.esbuildMinify = esbuildMinify;
exports.swcMinify = swcMinify;
exports.terserMinify = terserMinify;
exports.throttleAll = throttleAll;
exports.uglifyJsMinify = uglifyJsMinify;
/** @typedef {import("source-map").RawSourceMap} RawSourceMap */

@@ -32,5 +23,3 @@

/**
* @typedef {{ [key: string]: any }} CustomOptions
*/
/** @typedef {import("./index.js").CustomOptions} CustomOptions */

@@ -691,2 +680,10 @@ /**

return packageJson && packageJson.version;
};
module.exports = {
throttleAll,
terserMinify,
uglifyJsMinify,
swcMinify,
esbuildMinify
};
{
"name": "terser-webpack-plugin",
"version": "5.2.5",
"version": "5.3.0",
"description": "Terser plugin for webpack",

@@ -14,4 +14,4 @@ "license": "MIT",

},
"main": "dist/cjs.js",
"types": "types/cjs.d.ts",
"main": "dist/index.js",
"types": "types/index.d.ts",
"engines": {

@@ -23,3 +23,3 @@ "node": ">= 10.13.0"

"prebuild": "npm run clean",
"build:types": "tsc --declaration --emitDeclarationOnly --outDir types && prettier \"types/**/*.ts\" --write && node scripts/fix-types.js && prettier types --write",
"build:types": "tsc --declaration --emitDeclarationOnly --outDir types && prettier \"types/**/*.ts\" --write",
"build:code": "cross-env NODE_ENV=production babel src -d dist --copy-files",

@@ -60,3 +60,3 @@ "build": "npm-run-all -p \"build:**\"",

"dependencies": {
"jest-worker": "^27.0.6",
"jest-worker": "^27.4.1",
"schema-utils": "^3.1.1",

@@ -71,4 +71,4 @@ "serialize-javascript": "^6.0.0",

"@babel/preset-env": "^7.14.9",
"@commitlint/cli": "^14.1.0",
"@commitlint/config-conventional": "^14.1.0",
"@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0",
"@swc/core": "^1.2.82",

@@ -83,3 +83,3 @@ "@types/serialize-javascript": "^5.0.1",

"del-cli": "^3.0.1",
"esbuild": "^0.13.3",
"esbuild": "^0.14.0",
"eslint": "^7.32.0",

@@ -99,2 +99,3 @@ "eslint-config-prettier": "^8.3.0",

"webpack": "^5.48.0",
"webpack-cli": "^4.9.1",
"worker-loader": "^3.0.8"

@@ -101,0 +102,0 @@ },

@@ -1,104 +0,2 @@

export default TerserPlugin;
export type Schema = import("schema-utils/declarations/validate").Schema;
export type Compiler = import("webpack").Compiler;
export type Compilation = import("webpack").Compilation;
export type WebpackError = import("webpack").WebpackError;
export type Asset = import("webpack").Asset;
export type TerserECMA = import("./utils.js").TerserECMA;
export type TerserOptions = import("./utils.js").TerserOptions;
export type CustomOptions = import("./utils.js").CustomOptions;
export type JestWorker = import("jest-worker").Worker;
export type RawSourceMap = import("source-map").RawSourceMap;
export type Rule = RegExp | string;
export type Rules = Rule[] | Rule;
export type ExtractCommentsFunction = (
astNode: any,
comment: {
value: string;
type: "comment1" | "comment2" | "comment3" | "comment4";
pos: number;
line: number;
col: number;
}
) => boolean;
export type ExtractCommentsCondition =
| boolean
| "all"
| "some"
| RegExp
| ExtractCommentsFunction;
export type ExtractCommentsFilename = string | ((fileData: any) => string);
export type ExtractCommentsBanner =
| string
| boolean
| ((commentsFile: string) => string);
export type ExtractCommentsObject = {
condition?: ExtractCommentsCondition | undefined;
filename?: ExtractCommentsFilename | undefined;
banner?: ExtractCommentsBanner | undefined;
};
export type ExtractCommentsOptions =
| ExtractCommentsCondition
| ExtractCommentsObject;
export type Input = {
[file: string]: string;
};
export type MinimizedResult = {
code: string;
map?: import("source-map").RawSourceMap | undefined;
errors?: (string | Error)[] | undefined;
warnings?: (string | Error)[] | undefined;
extractedComments?: string[] | undefined;
};
export type PredefinedOptions = {
module?: boolean | undefined;
ecma?: any;
};
export type MinimizerImplementationAndOptions<T> = {
implementation: MinimizerImplementation<T>;
options: PredefinedOptions & T;
};
export type InternalOptions<T> = {
name: string;
input: string;
inputSourceMap: RawSourceMap | undefined;
extractComments: ExtractCommentsOptions | undefined;
minimizer: MinimizerImplementationAndOptions<T>;
};
export type MinimizerWorker<T> = Worker & {
transform: (options: string) => MinimizedResult;
minify: (options: InternalOptions<T>) => MinimizedResult;
};
export type BasicMinimizerImplementation<T> = (
input: Input,
sourceMap: RawSourceMap | undefined,
minifyOptions: T,
extractComments: ExtractCommentsOptions | undefined
) => Promise<MinimizedResult>;
export type MinimizeFunctionHelpers = {
getMinimizerVersion?: (() => string | undefined) | undefined;
};
export type MinimizerImplementation<T> = BasicMinimizerImplementation<T> &
MinimizeFunctionHelpers;
export type Parallel = undefined | boolean | number;
export type BasePluginOptions = {
test?: Rules | undefined;
include?: Rules | undefined;
exclude?: Rules | undefined;
extractComments?: ExtractCommentsOptions | undefined;
parallel?: Parallel;
};
export type InferDefaultType<T> = T extends infer U
? U
: import("./utils").CustomOptions;
export type DefinedDefaultMinimizerAndOptions<T> =
InferDefaultType<T> extends TerserOptions
? {
minify?: MinimizerImplementation<InferDefaultType<T>> | undefined;
terserOptions?: InferDefaultType<T> | undefined;
}
: {
minify: MinimizerImplementation<InferDefaultType<T>>;
terserOptions?: InferDefaultType<T> | undefined;
};
export = TerserPlugin;
/** @typedef {import("schema-utils/declarations/validate").Schema} Schema */

@@ -111,3 +9,2 @@ /** @typedef {import("webpack").Compiler} Compiler */

/** @typedef {import("./utils.js").TerserOptions} TerserOptions */
/** @typedef {import("./utils.js").CustomOptions} CustomOptions */
/** @typedef {import("jest-worker").Worker} JestWorker */

@@ -142,5 +39,2 @@ /** @typedef {import("source-map").RawSourceMap} RawSourceMap */

/**
* @typedef {{ [file: string]: string }} Input
*/
/**
* @typedef {Object} MinimizedResult

@@ -154,24 +48,19 @@ * @property {string} code

/**
* @typedef {Object} PredefinedOptions
* @property {boolean} [module]
* @property {any} [ecma]
* @typedef {{ [file: string]: string }} Input
*/
/**
* @template T
* @typedef {Object} MinimizerImplementationAndOptions
* @property {MinimizerImplementation<T>} implementation
* @property {PredefinedOptions & T} options
* @typedef {{ [key: string]: any }} CustomOptions
*/
/**
* @template T
* @typedef {Object} InternalOptions
* @property {string} name
* @property {string} input
* @property {RawSourceMap | undefined} inputSourceMap
* @property {ExtractCommentsOptions | undefined} extractComments
* @property {MinimizerImplementationAndOptions<T>} minimizer
* @typedef {T extends infer U ? U : CustomOptions} InferDefaultType
*/
/**
* @typedef {Object} PredefinedOptions
* @property {boolean} [module]
* @property {any} [ecma]
*/
/**
* @template T
* @typedef {JestWorker & { transform: (options: string) => MinimizedResult, minify: (options: InternalOptions<T>) => MinimizedResult }} MinimizerWorker
* @typedef {PredefinedOptions & InferDefaultType<T>} MinimizerOptions
*/

@@ -183,3 +72,3 @@ /**

* @param {RawSourceMap | undefined} sourceMap
* @param {T} minifyOptions
* @param {MinimizerOptions<T>} minifyOptions
* @param {ExtractCommentsOptions | undefined} extractComments

@@ -194,5 +83,18 @@ * @returns {Promise<MinimizedResult>}

* @template T
* @typedef {BasicMinimizerImplementation<T> & MinimizeFunctionHelpers } MinimizerImplementation
* @typedef {BasicMinimizerImplementation<T> & MinimizeFunctionHelpers} MinimizerImplementation
*/
/**
* @template T
* @typedef {Object} InternalOptions
* @property {string} name
* @property {string} input
* @property {RawSourceMap | undefined} inputSourceMap
* @property {ExtractCommentsOptions | undefined} extractComments
* @property {{ implementation: MinimizerImplementation<T>, options: MinimizerOptions<T> }} minimizer
*/
/**
* @template T
* @typedef {JestWorker & { transform: (options: string) => MinimizedResult, minify: (options: InternalOptions<T>) => MinimizedResult }} MinimizerWorker
*/
/**
* @typedef {undefined | boolean | number} Parallel

@@ -210,12 +112,12 @@ */

* @template T
* @typedef {T extends infer U ? U : CustomOptions} InferDefaultType
* @typedef {T extends TerserOptions ? { minify?: MinimizerImplementation<T> | undefined, terserOptions?: MinimizerOptions<T> | undefined } : { minify: MinimizerImplementation<T>, terserOptions?: MinimizerOptions<T> | undefined }} DefinedDefaultMinimizerAndOptions
*/
/**
* @template T
* @typedef {InferDefaultType<T> extends TerserOptions ? { minify?: MinimizerImplementation<InferDefaultType<T>> | undefined, terserOptions?: InferDefaultType<T> | undefined } : { minify: MinimizerImplementation<InferDefaultType<T>>, terserOptions?: InferDefaultType<T> | undefined }} DefinedDefaultMinimizerAndOptions
* @typedef {BasePluginOptions & { minimizer: { implementation: MinimizerImplementation<T>, options: MinimizerOptions<T> } }} InternalPluginOptions
*/
/**
* @template T
* @template [T=TerserOptions]
*/
declare class TerserPlugin<T = TerserOptions> {
declare class TerserPlugin<T = import("terser").MinifyOptions> {
/**

@@ -229,3 +131,3 @@ * @private

* @private
* @param {Error | string} warning
* @param {unknown} warning
* @param {string} file

@@ -264,17 +166,9 @@ * @returns {Error}

);
options: {
test: Rules;
extractComments: ExtractCommentsOptions;
parallel: number | boolean;
include: Rules | undefined;
exclude: Rules | undefined;
minimizer: {
implementation: MinimizerImplementation<
import("terser").MinifyOptions & InferDefaultType<T>
>;
options: InferDefaultType<T>;
};
};
/**
* @private
* @type {InternalPluginOptions<T>}
*/
private options;
/**
* @private
* @param {Compiler} compiler

@@ -294,8 +188,58 @@ * @param {Compilation} compilation

declare namespace TerserPlugin {
export { terserMinify };
export { uglifyJsMinify };
export { swcMinify };
export { esbuildMinify };
export {
terserMinify,
uglifyJsMinify,
swcMinify,
esbuildMinify,
Schema,
Compiler,
Compilation,
WebpackError,
Asset,
TerserECMA,
TerserOptions,
JestWorker,
RawSourceMap,
Rule,
Rules,
ExtractCommentsFunction,
ExtractCommentsCondition,
ExtractCommentsFilename,
ExtractCommentsBanner,
ExtractCommentsObject,
ExtractCommentsOptions,
MinimizedResult,
Input,
CustomOptions,
InferDefaultType,
PredefinedOptions,
MinimizerOptions,
BasicMinimizerImplementation,
MinimizeFunctionHelpers,
MinimizerImplementation,
InternalOptions,
MinimizerWorker,
Parallel,
BasePluginOptions,
DefinedDefaultMinimizerAndOptions,
InternalPluginOptions,
};
}
import { Worker } from "jest-worker";
type Compiler = import("webpack").Compiler;
type BasePluginOptions = {
test?: Rules | undefined;
include?: Rules | undefined;
exclude?: Rules | undefined;
extractComments?: ExtractCommentsOptions | undefined;
parallel?: Parallel;
};
type DefinedDefaultMinimizerAndOptions<T> = T extends TerserOptions
? {
minify?: MinimizerImplementation<T> | undefined;
terserOptions?: MinimizerOptions<T> | undefined;
}
: {
minify: MinimizerImplementation<T>;
terserOptions?: MinimizerOptions<T> | undefined;
};
import { terserMinify } from "./utils";

@@ -305,1 +249,91 @@ import { uglifyJsMinify } from "./utils";

import { esbuildMinify } from "./utils";
type Schema = import("schema-utils/declarations/validate").Schema;
type Compilation = import("webpack").Compilation;
type WebpackError = import("webpack").WebpackError;
type Asset = import("webpack").Asset;
type TerserECMA = import("./utils.js").TerserECMA;
type TerserOptions = import("./utils.js").TerserOptions;
type JestWorker = import("jest-worker").Worker;
type RawSourceMap = import("source-map").RawSourceMap;
type Rule = RegExp | string;
type Rules = Rule[] | Rule;
type ExtractCommentsFunction = (
astNode: any,
comment: {
value: string;
type: "comment1" | "comment2" | "comment3" | "comment4";
pos: number;
line: number;
col: number;
}
) => boolean;
type ExtractCommentsCondition =
| boolean
| "all"
| "some"
| RegExp
| ExtractCommentsFunction;
type ExtractCommentsFilename = string | ((fileData: any) => string);
type ExtractCommentsBanner =
| string
| boolean
| ((commentsFile: string) => string);
type ExtractCommentsObject = {
condition?: ExtractCommentsCondition | undefined;
filename?: ExtractCommentsFilename | undefined;
banner?: ExtractCommentsBanner | undefined;
};
type ExtractCommentsOptions = ExtractCommentsCondition | ExtractCommentsObject;
type MinimizedResult = {
code: string;
map?: import("source-map").RawSourceMap | undefined;
errors?: (string | Error)[] | undefined;
warnings?: (string | Error)[] | undefined;
extractedComments?: string[] | undefined;
};
type Input = {
[file: string]: string;
};
type CustomOptions = {
[key: string]: any;
};
type InferDefaultType<T> = T extends infer U ? U : CustomOptions;
type PredefinedOptions = {
module?: boolean | undefined;
ecma?: any;
};
type MinimizerOptions<T> = PredefinedOptions & InferDefaultType<T>;
type BasicMinimizerImplementation<T> = (
input: Input,
sourceMap: RawSourceMap | undefined,
minifyOptions: MinimizerOptions<T>,
extractComments: ExtractCommentsOptions | undefined
) => Promise<MinimizedResult>;
type MinimizeFunctionHelpers = {
getMinimizerVersion?: (() => string | undefined) | undefined;
};
type MinimizerImplementation<T> = BasicMinimizerImplementation<T> &
MinimizeFunctionHelpers;
type InternalOptions<T> = {
name: string;
input: string;
inputSourceMap: RawSourceMap | undefined;
extractComments: ExtractCommentsOptions | undefined;
minimizer: {
implementation: MinimizerImplementation<T>;
options: MinimizerOptions<T>;
};
};
type MinimizerWorker<T> = Worker & {
transform: (options: string) => MinimizedResult;
minify: (options: InternalOptions<T>) => MinimizedResult;
};
type Parallel = undefined | boolean | number;
type InternalPluginOptions<T> = BasePluginOptions & {
minimizer: {
implementation: MinimizerImplementation<T>;
options: MinimizerOptions<T>;
};
};
import { minify } from "./minify";
import { Worker } from "jest-worker";

@@ -15,5 +15,3 @@ export type Task<T> = () => Promise<T>;

export type PredefinedOptions = import("./index.js").PredefinedOptions;
export type CustomOptions = {
[key: string]: any;
};
export type CustomOptions = import("./index.js").CustomOptions;
export type ExtractedComments = Array<string>;

@@ -20,0 +18,0 @@ /**

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc