1 | export default TerserPlugin;
|
---|
2 | export type ExtractedCommentsInfo = {
|
---|
3 | extractedCommentsSource: import("webpack").sources.RawSource;
|
---|
4 | commentsFilename: string;
|
---|
5 | };
|
---|
6 | export type Schema = import("schema-utils/declarations/validate").Schema;
|
---|
7 | export type Compiler = import("webpack").Compiler;
|
---|
8 | export type Compilation = import("webpack").Compilation;
|
---|
9 | export type WebpackError = import("webpack").WebpackError;
|
---|
10 | export type Asset = import("webpack").Asset;
|
---|
11 | export type TerserECMA = import("terser").ECMA;
|
---|
12 | export type TerserMinifyOptions = import("terser").MinifyOptions;
|
---|
13 | export type JestWorker = import("jest-worker").default;
|
---|
14 | export type RawSourceMap = import("source-map").RawSourceMap;
|
---|
15 | export type InternalMinifyOptions = import("./minify.js").InternalMinifyOptions;
|
---|
16 | export type InternalMinifyResult = import("./minify.js").InternalMinifyResult;
|
---|
17 | export type CustomMinifyOptions = import("./minify.js").CustomMinifyOptions;
|
---|
18 | export type Rule = RegExp | string;
|
---|
19 | export type Rules = Rule[] | Rule;
|
---|
20 | export type MinifyWorker = MinifyWorker;
|
---|
21 | export type ExtractCommentsFunction = (
|
---|
22 | astNode: any,
|
---|
23 | comment: {
|
---|
24 | value: string;
|
---|
25 | type: "comment1" | "comment2" | "comment3" | "comment4";
|
---|
26 | pos: number;
|
---|
27 | line: number;
|
---|
28 | col: number;
|
---|
29 | }
|
---|
30 | ) => boolean;
|
---|
31 | export type ExtractCommentsCondition =
|
---|
32 | | boolean
|
---|
33 | | string
|
---|
34 | | RegExp
|
---|
35 | | ExtractCommentsFunction;
|
---|
36 | export type ExtractCommentsFilename = string | ((fileData: any) => string);
|
---|
37 | export type ExtractCommentsBanner =
|
---|
38 | | string
|
---|
39 | | boolean
|
---|
40 | | ((commentsFile: string) => string);
|
---|
41 | export type ExtractCommentsObject = {
|
---|
42 | condition: ExtractCommentsCondition;
|
---|
43 | filename: ExtractCommentsFilename;
|
---|
44 | banner: ExtractCommentsBanner;
|
---|
45 | };
|
---|
46 | export type CustomMinifyFunction = (
|
---|
47 | fileAndCode: {
|
---|
48 | [file: string]: string;
|
---|
49 | },
|
---|
50 | sourceMap?: import("source-map").RawSourceMap | undefined,
|
---|
51 | minifyOptions: any
|
---|
52 | ) => any;
|
---|
53 | export type ExtractCommentsOptions =
|
---|
54 | | ExtractCommentsCondition
|
---|
55 | | ExtractCommentsObject;
|
---|
56 | export type PluginWithTerserOptions = {
|
---|
57 | test?: Rules | undefined;
|
---|
58 | include?: Rules | undefined;
|
---|
59 | exclude?: Rules | undefined;
|
---|
60 | terserOptions?: import("terser").MinifyOptions | undefined;
|
---|
61 | extractComments?: ExtractCommentsOptions | undefined;
|
---|
62 | parallel?: boolean | undefined;
|
---|
63 | minify?: CustomMinifyFunction | undefined;
|
---|
64 | };
|
---|
65 | export type PluginWithCustomMinifyOptions = {
|
---|
66 | test?: Rules | undefined;
|
---|
67 | include?: Rules | undefined;
|
---|
68 | exclude?: Rules | undefined;
|
---|
69 | terserOptions?: any;
|
---|
70 | extractComments?: ExtractCommentsOptions | undefined;
|
---|
71 | parallel?: boolean | undefined;
|
---|
72 | minify?: CustomMinifyFunction | undefined;
|
---|
73 | };
|
---|
74 | export type TerserPluginOptions =
|
---|
75 | | PluginWithTerserOptions
|
---|
76 | | PluginWithCustomMinifyOptions;
|
---|
77 | /** @typedef {import("schema-utils/declarations/validate").Schema} Schema */
|
---|
78 | /** @typedef {import("webpack").Compiler} Compiler */
|
---|
79 | /** @typedef {import("webpack").Compilation} Compilation */
|
---|
80 | /** @typedef {import("webpack").WebpackError} WebpackError */
|
---|
81 | /** @typedef {import("webpack").Asset} Asset */
|
---|
82 | /** @typedef {import("terser").ECMA} TerserECMA */
|
---|
83 | /** @typedef {import("terser").MinifyOptions} TerserMinifyOptions */
|
---|
84 | /** @typedef {import("jest-worker").default} JestWorker */
|
---|
85 | /** @typedef {import("source-map").RawSourceMap} RawSourceMap */
|
---|
86 | /** @typedef {import("./minify.js").InternalMinifyOptions} InternalMinifyOptions */
|
---|
87 | /** @typedef {import("./minify.js").InternalMinifyResult} InternalMinifyResult */
|
---|
88 | /** @typedef {import("./minify.js").CustomMinifyOptions} CustomMinifyOptions */
|
---|
89 | /** @typedef {RegExp | string} Rule */
|
---|
90 | /** @typedef {Rule[] | Rule} Rules */
|
---|
91 | /** @typedef {JestWorker & { transform: (options: string) => InternalMinifyResult, minify: (options: InternalMinifyOptions) => InternalMinifyResult }} MinifyWorker */
|
---|
92 | /**
|
---|
93 | * @callback ExtractCommentsFunction
|
---|
94 | * @param {any} astNode
|
---|
95 | * @param {{ value: string, type: 'comment1' | 'comment2' | 'comment3' | 'comment4', pos: number, line: number, col: number }} comment
|
---|
96 | * @returns {boolean}
|
---|
97 | */
|
---|
98 | /**
|
---|
99 | * @typedef {boolean | string | RegExp | ExtractCommentsFunction} ExtractCommentsCondition
|
---|
100 | */
|
---|
101 | /**
|
---|
102 | * @typedef {string | ((fileData: any) => string)} ExtractCommentsFilename
|
---|
103 | */
|
---|
104 | /**
|
---|
105 | * @typedef {boolean | string | ((commentsFile: string) => string)} ExtractCommentsBanner
|
---|
106 | */
|
---|
107 | /**
|
---|
108 | * @typedef {Object} ExtractCommentsObject
|
---|
109 | * @property {ExtractCommentsCondition} condition
|
---|
110 | * @property {ExtractCommentsFilename} filename
|
---|
111 | * @property {ExtractCommentsBanner} banner
|
---|
112 | */
|
---|
113 | /**
|
---|
114 | * @callback CustomMinifyFunction
|
---|
115 | * @param {{ [file: string]: string }} fileAndCode
|
---|
116 | * @param {RawSourceMap} [sourceMap]
|
---|
117 | * @param {Object.<any, any>} minifyOptions
|
---|
118 | */
|
---|
119 | /**
|
---|
120 | * @typedef {ExtractCommentsCondition | ExtractCommentsObject} ExtractCommentsOptions
|
---|
121 | */
|
---|
122 | /**
|
---|
123 | * @typedef {Object} PluginWithTerserOptions
|
---|
124 | * @property {Rules} [test]
|
---|
125 | * @property {Rules} [include]
|
---|
126 | * @property {Rules} [exclude]
|
---|
127 | * @property {TerserMinifyOptions} [terserOptions]
|
---|
128 | * @property {ExtractCommentsOptions} [extractComments]
|
---|
129 | * @property {boolean} [parallel]
|
---|
130 | * @property {CustomMinifyFunction} [minify]
|
---|
131 | */
|
---|
132 | /**
|
---|
133 | * @typedef {Object} PluginWithCustomMinifyOptions
|
---|
134 | * @property {Rules} [test]
|
---|
135 | * @property {Rules} [include]
|
---|
136 | * @property {Rules} [exclude]
|
---|
137 | * @property {Object.<any, any>} [terserOptions]
|
---|
138 | * @property {ExtractCommentsOptions} [extractComments]
|
---|
139 | * @property {boolean} [parallel]
|
---|
140 | * @property {CustomMinifyFunction} [minify]
|
---|
141 | */
|
---|
142 | /**
|
---|
143 | * @typedef {PluginWithTerserOptions | PluginWithCustomMinifyOptions} TerserPluginOptions
|
---|
144 | */
|
---|
145 | declare class TerserPlugin {
|
---|
146 | /**
|
---|
147 | * @private
|
---|
148 | * @param {any} input
|
---|
149 | * @returns {boolean}
|
---|
150 | */
|
---|
151 | private static isSourceMap;
|
---|
152 | /**
|
---|
153 | * @private
|
---|
154 | * @param {Error & { line: number, col: number}} error
|
---|
155 | * @param {string} file
|
---|
156 | * @param {Compilation["requestShortener"]} [requestShortener]
|
---|
157 | * @param {SourceMapConsumer} [sourceMap]
|
---|
158 | * @returns {Error}
|
---|
159 | */
|
---|
160 | private static buildError;
|
---|
161 | /**
|
---|
162 | * @private
|
---|
163 | * @param {boolean} parallel
|
---|
164 | * @returns {number}
|
---|
165 | */
|
---|
166 | private static getAvailableNumberOfCores;
|
---|
167 | /**
|
---|
168 | * @private
|
---|
169 | * @param {any} environment
|
---|
170 | * @returns {TerserECMA}
|
---|
171 | */
|
---|
172 | private static getEcmaVersion;
|
---|
173 | /**
|
---|
174 | * @param {TerserPluginOptions} options
|
---|
175 | */
|
---|
176 | constructor(options?: TerserPluginOptions);
|
---|
177 | options: {
|
---|
178 | test: Rules;
|
---|
179 | extractComments: ExtractCommentsOptions;
|
---|
180 | parallel: boolean;
|
---|
181 | include: Rules | undefined;
|
---|
182 | exclude: Rules | undefined;
|
---|
183 | minify: CustomMinifyFunction | undefined;
|
---|
184 | terserOptions: any;
|
---|
185 | };
|
---|
186 | /**
|
---|
187 | * @param {Compiler} compiler
|
---|
188 | * @param {Compilation} compilation
|
---|
189 | * @param {Record<string, import("webpack").sources.Source>} assets
|
---|
190 | * @param {{availableNumberOfCores: number}} optimizeOptions
|
---|
191 | * @returns {Promise<void>}
|
---|
192 | */
|
---|
193 | optimize(
|
---|
194 | compiler: Compiler,
|
---|
195 | compilation: Compilation,
|
---|
196 | assets: Record<string, import("webpack").sources.Source>,
|
---|
197 | optimizeOptions: {
|
---|
198 | availableNumberOfCores: number;
|
---|
199 | }
|
---|
200 | ): Promise<void>;
|
---|
201 | /**
|
---|
202 | * @param {Compiler} compiler
|
---|
203 | * @returns {void}
|
---|
204 | */
|
---|
205 | apply(compiler: Compiler): void;
|
---|
206 | }
|
---|