1 | export = TerserPlugin;
|
2 |
|
3 |
|
4 |
|
5 | declare class TerserPlugin<T = import("terser").MinifyOptions> {
|
6 | |
7 |
|
8 |
|
9 |
|
10 |
|
11 | private static isSourceMap;
|
12 | |
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | private static buildWarning;
|
19 | |
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | private static buildError;
|
28 | |
29 |
|
30 |
|
31 |
|
32 |
|
33 | private static getAvailableNumberOfCores;
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 | private static getEcmaVersion;
|
40 | |
41 |
|
42 |
|
43 | constructor(
|
44 | options?:
|
45 | | (BasePluginOptions & DefinedDefaultMinimizerAndOptions<T>)
|
46 | | undefined
|
47 | );
|
48 | /**
|
49 | * @private
|
50 | * @type {InternalPluginOptions<T>}
|
51 | */
|
52 | private options;
|
53 | |
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | private optimize;
|
62 | |
63 |
|
64 |
|
65 |
|
66 | apply(compiler: Compiler): void;
|
67 | }
|
68 | declare namespace TerserPlugin {
|
69 | export {
|
70 | terserMinify,
|
71 | uglifyJsMinify,
|
72 | swcMinify,
|
73 | esbuildMinify,
|
74 | Schema,
|
75 | Compiler,
|
76 | Compilation,
|
77 | WebpackError,
|
78 | Asset,
|
79 | TerserECMA,
|
80 | TerserOptions,
|
81 | JestWorker,
|
82 | SourceMapInput,
|
83 | TraceMap,
|
84 | Rule,
|
85 | Rules,
|
86 | ExtractCommentsFunction,
|
87 | ExtractCommentsCondition,
|
88 | ExtractCommentsFilename,
|
89 | ExtractCommentsBanner,
|
90 | ExtractCommentsObject,
|
91 | ExtractCommentsOptions,
|
92 | MinimizedResult,
|
93 | Input,
|
94 | CustomOptions,
|
95 | InferDefaultType,
|
96 | PredefinedOptions,
|
97 | MinimizerOptions,
|
98 | BasicMinimizerImplementation,
|
99 | MinimizeFunctionHelpers,
|
100 | MinimizerImplementation,
|
101 | InternalOptions,
|
102 | MinimizerWorker,
|
103 | Parallel,
|
104 | BasePluginOptions,
|
105 | DefinedDefaultMinimizerAndOptions,
|
106 | InternalPluginOptions,
|
107 | };
|
108 | }
|
109 | type Compiler = import("webpack").Compiler;
|
110 | type BasePluginOptions = {
|
111 | test?: Rules | undefined;
|
112 | include?: Rules | undefined;
|
113 | exclude?: Rules | undefined;
|
114 | extractComments?: ExtractCommentsOptions | undefined;
|
115 | parallel?: Parallel;
|
116 | };
|
117 | type DefinedDefaultMinimizerAndOptions<T> = T extends TerserOptions
|
118 | ? {
|
119 | minify?: MinimizerImplementation<T> | undefined;
|
120 | terserOptions?: MinimizerOptions<T> | undefined;
|
121 | }
|
122 | : {
|
123 | minify: MinimizerImplementation<T>;
|
124 | terserOptions?: MinimizerOptions<T> | undefined;
|
125 | };
|
126 | import { terserMinify } from "./utils";
|
127 | import { uglifyJsMinify } from "./utils";
|
128 | import { swcMinify } from "./utils";
|
129 | import { esbuildMinify } from "./utils";
|
130 | type Schema = import("schema-utils/declarations/validate").Schema;
|
131 | type Compilation = import("webpack").Compilation;
|
132 | type WebpackError = import("webpack").WebpackError;
|
133 | type Asset = import("webpack").Asset;
|
134 | type TerserECMA = import("./utils.js").TerserECMA;
|
135 | type TerserOptions = import("./utils.js").TerserOptions;
|
136 | type JestWorker = import("jest-worker").Worker;
|
137 | type SourceMapInput = import("@jridgewell/trace-mapping").SourceMapInput;
|
138 | type TraceMap = import("@jridgewell/trace-mapping").TraceMap;
|
139 | type Rule = RegExp | string;
|
140 | type Rules = Rule[] | Rule;
|
141 | type ExtractCommentsFunction = (
|
142 | astNode: any,
|
143 | comment: {
|
144 | value: string;
|
145 | type: "comment1" | "comment2" | "comment3" | "comment4";
|
146 | pos: number;
|
147 | line: number;
|
148 | col: number;
|
149 | }
|
150 | ) => boolean;
|
151 | type ExtractCommentsCondition =
|
152 | | boolean
|
153 | | "all"
|
154 | | "some"
|
155 | | RegExp
|
156 | | ExtractCommentsFunction;
|
157 | type ExtractCommentsFilename = string | ((fileData: any) => string);
|
158 | type ExtractCommentsBanner =
|
159 | | string
|
160 | | boolean
|
161 | | ((commentsFile: string) => string);
|
162 | type ExtractCommentsObject = {
|
163 | condition?: ExtractCommentsCondition | undefined;
|
164 | filename?: ExtractCommentsFilename | undefined;
|
165 | banner?: ExtractCommentsBanner | undefined;
|
166 | };
|
167 | type ExtractCommentsOptions = ExtractCommentsCondition | ExtractCommentsObject;
|
168 | type MinimizedResult = {
|
169 | code: string;
|
170 | map?: import("@jridgewell/trace-mapping").SourceMapInput | undefined;
|
171 | errors?: (string | Error)[] | undefined;
|
172 | warnings?: (string | Error)[] | undefined;
|
173 | extractedComments?: string[] | undefined;
|
174 | };
|
175 | type Input = {
|
176 | [file: string]: string;
|
177 | };
|
178 | type CustomOptions = {
|
179 | [key: string]: any;
|
180 | };
|
181 | type InferDefaultType<T> = T extends infer U ? U : CustomOptions;
|
182 | type PredefinedOptions = {
|
183 | module?: boolean | undefined;
|
184 | ecma?: import("terser").ECMA | undefined;
|
185 | };
|
186 | type MinimizerOptions<T> = PredefinedOptions & InferDefaultType<T>;
|
187 | type BasicMinimizerImplementation<T> = (
|
188 | input: Input,
|
189 | sourceMap: SourceMapInput | undefined,
|
190 | minifyOptions: MinimizerOptions<T>,
|
191 | extractComments: ExtractCommentsOptions | undefined
|
192 | ) => Promise<MinimizedResult>;
|
193 | type MinimizeFunctionHelpers = {
|
194 | getMinimizerVersion?: (() => string | undefined) | undefined;
|
195 | };
|
196 | type MinimizerImplementation<T> = BasicMinimizerImplementation<T> &
|
197 | MinimizeFunctionHelpers;
|
198 | type InternalOptions<T> = {
|
199 | name: string;
|
200 | input: string;
|
201 | inputSourceMap: SourceMapInput | undefined;
|
202 | extractComments: ExtractCommentsOptions | undefined;
|
203 | minimizer: {
|
204 | implementation: MinimizerImplementation<T>;
|
205 | options: MinimizerOptions<T>;
|
206 | };
|
207 | };
|
208 | type MinimizerWorker<T> = import("jest-worker").Worker & {
|
209 | transform: (options: string) => MinimizedResult;
|
210 | minify: (options: InternalOptions<T>) => MinimizedResult;
|
211 | };
|
212 | type Parallel = undefined | boolean | number;
|
213 | type InternalPluginOptions<T> = BasePluginOptions & {
|
214 | minimizer: {
|
215 | implementation: MinimizerImplementation<T>;
|
216 | options: MinimizerOptions<T>;
|
217 | };
|
218 | };
|
219 | import { minify } from "./minify";
|