|
1 | | -export default TerserPlugin; |
2 | | -export type Schema = import("schema-utils/declarations/validate").Schema; |
3 | | -export type Compiler = import("webpack").Compiler; |
4 | | -export type Compilation = import("webpack").Compilation; |
5 | | -export type WebpackError = import("webpack").WebpackError; |
6 | | -export type Asset = import("webpack").Asset; |
7 | | -export type TerserECMA = import("./utils.js").TerserECMA; |
8 | | -export type TerserOptions = import("./utils.js").TerserOptions; |
9 | | -export type JestWorker = import("jest-worker").Worker; |
10 | | -export type RawSourceMap = import("source-map").RawSourceMap; |
11 | | -export type Rule = RegExp | string; |
12 | | -export type Rules = Rule[] | Rule; |
13 | | -export type ExtractCommentsFunction = ( |
14 | | - astNode: any, |
15 | | - comment: { |
16 | | - value: string; |
17 | | - type: "comment1" | "comment2" | "comment3" | "comment4"; |
18 | | - pos: number; |
19 | | - line: number; |
20 | | - col: number; |
21 | | - } |
22 | | -) => boolean; |
23 | | -export type ExtractCommentsCondition = |
24 | | - | boolean |
25 | | - | "all" |
26 | | - | "some" |
27 | | - | RegExp |
28 | | - | ExtractCommentsFunction; |
29 | | -export type ExtractCommentsFilename = string | ((fileData: any) => string); |
30 | | -export type ExtractCommentsBanner = |
31 | | - | string |
32 | | - | boolean |
33 | | - | ((commentsFile: string) => string); |
34 | | -export type ExtractCommentsObject = { |
35 | | - condition?: ExtractCommentsCondition | undefined; |
36 | | - filename?: ExtractCommentsFilename | undefined; |
37 | | - banner?: ExtractCommentsBanner | undefined; |
38 | | -}; |
39 | | -export type ExtractCommentsOptions = |
40 | | - | ExtractCommentsCondition |
41 | | - | ExtractCommentsObject; |
42 | | -export type MinimizedResult = { |
43 | | - code: string; |
44 | | - map?: import("source-map").RawSourceMap | undefined; |
45 | | - errors?: (string | Error)[] | undefined; |
46 | | - warnings?: (string | Error)[] | undefined; |
47 | | - extractedComments?: string[] | undefined; |
48 | | -}; |
49 | | -export type Input = { |
50 | | - [file: string]: string; |
51 | | -}; |
52 | | -export type CustomOptions = { |
53 | | - [key: string]: any; |
54 | | -}; |
55 | | -export type InferDefaultType<T> = T extends infer U ? U : CustomOptions; |
56 | | -export type PredefinedOptions = { |
57 | | - module?: boolean | undefined; |
58 | | - ecma?: any; |
59 | | -}; |
60 | | -export type MinimizerOptions<T> = PredefinedOptions & InferDefaultType<T>; |
61 | | -export type BasicMinimizerImplementation<T> = ( |
62 | | - input: Input, |
63 | | - sourceMap: RawSourceMap | undefined, |
64 | | - minifyOptions: MinimizerOptions<T>, |
65 | | - extractComments: ExtractCommentsOptions | undefined |
66 | | -) => Promise<MinimizedResult>; |
67 | | -export type MinimizeFunctionHelpers = { |
68 | | - getMinimizerVersion?: (() => string | undefined) | undefined; |
69 | | -}; |
70 | | -export type MinimizerImplementation<T> = BasicMinimizerImplementation<T> & |
71 | | - MinimizeFunctionHelpers; |
72 | | -export type InternalOptions<T> = { |
73 | | - name: string; |
74 | | - input: string; |
75 | | - inputSourceMap: RawSourceMap | undefined; |
76 | | - extractComments: ExtractCommentsOptions | undefined; |
77 | | - minimizer: { |
78 | | - implementation: MinimizerImplementation<T>; |
79 | | - options: MinimizerOptions<T>; |
80 | | - }; |
81 | | -}; |
82 | | -export type MinimizerWorker<T> = Worker & { |
83 | | - transform: (options: string) => MinimizedResult; |
84 | | - minify: (options: InternalOptions<T>) => MinimizedResult; |
85 | | -}; |
86 | | -export type Parallel = undefined | boolean | number; |
87 | | -export type BasePluginOptions = { |
88 | | - test?: Rules | undefined; |
89 | | - include?: Rules | undefined; |
90 | | - exclude?: Rules | undefined; |
91 | | - extractComments?: ExtractCommentsOptions | undefined; |
92 | | - parallel?: Parallel; |
93 | | -}; |
94 | | -export type DefinedDefaultMinimizerAndOptions<T> = T extends TerserOptions |
95 | | - ? { |
96 | | - minify?: MinimizerImplementation<T> | undefined; |
97 | | - terserOptions?: MinimizerOptions<T> | undefined; |
98 | | - } |
99 | | - : { |
100 | | - minify: MinimizerImplementation<T>; |
101 | | - terserOptions?: MinimizerOptions<T> | undefined; |
102 | | - }; |
103 | | -export type InternalPluginOptions<T> = BasePluginOptions & { |
104 | | - minimizer: { |
105 | | - implementation: MinimizerImplementation<T>; |
106 | | - options: MinimizerOptions<T>; |
107 | | - }; |
108 | | -}; |
| 1 | +export = TerserPlugin; |
109 | 2 | /** @typedef {import("schema-utils/declarations/validate").Schema} Schema */ |
110 | 3 | /** @typedef {import("webpack").Compiler} Compiler */ |
111 | 4 | /** @typedef {import("webpack").Compilation} Compilation */ |
@@ -284,13 +177,153 @@ declare class TerserPlugin<T = import("terser").MinifyOptions> { |
284 | 177 | apply(compiler: Compiler): void; |
285 | 178 | } |
286 | 179 | declare namespace TerserPlugin { |
287 | | - export { terserMinify }; |
288 | | - export { uglifyJsMinify }; |
289 | | - export { swcMinify }; |
290 | | - export { esbuildMinify }; |
| 180 | + export { |
| 181 | + terserMinify, |
| 182 | + uglifyJsMinify, |
| 183 | + swcMinify, |
| 184 | + esbuildMinify, |
| 185 | + Schema, |
| 186 | + Compiler, |
| 187 | + Compilation, |
| 188 | + WebpackError, |
| 189 | + Asset, |
| 190 | + TerserECMA, |
| 191 | + TerserOptions, |
| 192 | + JestWorker, |
| 193 | + RawSourceMap, |
| 194 | + Rule, |
| 195 | + Rules, |
| 196 | + ExtractCommentsFunction, |
| 197 | + ExtractCommentsCondition, |
| 198 | + ExtractCommentsFilename, |
| 199 | + ExtractCommentsBanner, |
| 200 | + ExtractCommentsObject, |
| 201 | + ExtractCommentsOptions, |
| 202 | + MinimizedResult, |
| 203 | + Input, |
| 204 | + CustomOptions, |
| 205 | + InferDefaultType, |
| 206 | + PredefinedOptions, |
| 207 | + MinimizerOptions, |
| 208 | + BasicMinimizerImplementation, |
| 209 | + MinimizeFunctionHelpers, |
| 210 | + MinimizerImplementation, |
| 211 | + InternalOptions, |
| 212 | + MinimizerWorker, |
| 213 | + Parallel, |
| 214 | + BasePluginOptions, |
| 215 | + DefinedDefaultMinimizerAndOptions, |
| 216 | + InternalPluginOptions, |
| 217 | + }; |
291 | 218 | } |
292 | | -import { Worker } from "jest-worker"; |
| 219 | +type Compiler = import("webpack").Compiler; |
| 220 | +type BasePluginOptions = { |
| 221 | + test?: Rules | undefined; |
| 222 | + include?: Rules | undefined; |
| 223 | + exclude?: Rules | undefined; |
| 224 | + extractComments?: ExtractCommentsOptions | undefined; |
| 225 | + parallel?: Parallel; |
| 226 | +}; |
| 227 | +type DefinedDefaultMinimizerAndOptions<T> = T extends TerserOptions |
| 228 | + ? { |
| 229 | + minify?: MinimizerImplementation<T> | undefined; |
| 230 | + terserOptions?: MinimizerOptions<T> | undefined; |
| 231 | + } |
| 232 | + : { |
| 233 | + minify: MinimizerImplementation<T>; |
| 234 | + terserOptions?: MinimizerOptions<T> | undefined; |
| 235 | + }; |
293 | 236 | import { terserMinify } from "./utils"; |
294 | 237 | import { uglifyJsMinify } from "./utils"; |
295 | 238 | import { swcMinify } from "./utils"; |
296 | 239 | import { esbuildMinify } from "./utils"; |
| 240 | +type Schema = import("schema-utils/declarations/validate").Schema; |
| 241 | +type Compilation = import("webpack").Compilation; |
| 242 | +type WebpackError = import("webpack").WebpackError; |
| 243 | +type Asset = import("webpack").Asset; |
| 244 | +type TerserECMA = import("./utils.js").TerserECMA; |
| 245 | +type TerserOptions = import("./utils.js").TerserOptions; |
| 246 | +type JestWorker = import("jest-worker").Worker; |
| 247 | +type RawSourceMap = import("source-map").RawSourceMap; |
| 248 | +type Rule = RegExp | string; |
| 249 | +type Rules = Rule[] | Rule; |
| 250 | +type ExtractCommentsFunction = ( |
| 251 | + astNode: any, |
| 252 | + comment: { |
| 253 | + value: string; |
| 254 | + type: "comment1" | "comment2" | "comment3" | "comment4"; |
| 255 | + pos: number; |
| 256 | + line: number; |
| 257 | + col: number; |
| 258 | + } |
| 259 | +) => boolean; |
| 260 | +type ExtractCommentsCondition = |
| 261 | + | boolean |
| 262 | + | "all" |
| 263 | + | "some" |
| 264 | + | RegExp |
| 265 | + | ExtractCommentsFunction; |
| 266 | +type ExtractCommentsFilename = string | ((fileData: any) => string); |
| 267 | +type ExtractCommentsBanner = |
| 268 | + | string |
| 269 | + | boolean |
| 270 | + | ((commentsFile: string) => string); |
| 271 | +type ExtractCommentsObject = { |
| 272 | + condition?: ExtractCommentsCondition | undefined; |
| 273 | + filename?: ExtractCommentsFilename | undefined; |
| 274 | + banner?: ExtractCommentsBanner | undefined; |
| 275 | +}; |
| 276 | +type ExtractCommentsOptions = ExtractCommentsCondition | ExtractCommentsObject; |
| 277 | +type MinimizedResult = { |
| 278 | + code: string; |
| 279 | + map?: import("source-map").RawSourceMap | undefined; |
| 280 | + errors?: (string | Error)[] | undefined; |
| 281 | + warnings?: (string | Error)[] | undefined; |
| 282 | + extractedComments?: string[] | undefined; |
| 283 | +}; |
| 284 | +type Input = { |
| 285 | + [file: string]: string; |
| 286 | +}; |
| 287 | +type CustomOptions = { |
| 288 | + [key: string]: any; |
| 289 | +}; |
| 290 | +type InferDefaultType<T> = T extends infer U ? U : CustomOptions; |
| 291 | +type PredefinedOptions = { |
| 292 | + module?: boolean | undefined; |
| 293 | + ecma?: any; |
| 294 | +}; |
| 295 | +type MinimizerOptions<T> = PredefinedOptions & InferDefaultType<T>; |
| 296 | +type BasicMinimizerImplementation<T> = ( |
| 297 | + input: Input, |
| 298 | + sourceMap: RawSourceMap | undefined, |
| 299 | + minifyOptions: MinimizerOptions<T>, |
| 300 | + extractComments: ExtractCommentsOptions | undefined |
| 301 | +) => Promise<MinimizedResult>; |
| 302 | +type MinimizeFunctionHelpers = { |
| 303 | + getMinimizerVersion?: (() => string | undefined) | undefined; |
| 304 | +}; |
| 305 | +type MinimizerImplementation<T> = BasicMinimizerImplementation<T> & |
| 306 | + MinimizeFunctionHelpers; |
| 307 | +type InternalOptions<T> = { |
| 308 | + name: string; |
| 309 | + input: string; |
| 310 | + inputSourceMap: RawSourceMap | undefined; |
| 311 | + extractComments: ExtractCommentsOptions | undefined; |
| 312 | + minimizer: { |
| 313 | + implementation: MinimizerImplementation<T>; |
| 314 | + options: MinimizerOptions<T>; |
| 315 | + }; |
| 316 | +}; |
| 317 | +type MinimizerWorker<T> = Worker & { |
| 318 | + transform: (options: string) => MinimizedResult; |
| 319 | + minify: (options: InternalOptions<T>) => MinimizedResult; |
| 320 | +}; |
| 321 | +type Parallel = undefined | boolean | number; |
| 322 | +type InternalPluginOptions<T> = BasePluginOptions & { |
| 323 | + minimizer: { |
| 324 | + implementation: MinimizerImplementation<T>; |
| 325 | + options: MinimizerOptions<T>; |
| 326 | + }; |
| 327 | +}; |
| 328 | +import { minify } from "./minify"; |
| 329 | +import { Worker } from "jest-worker"; |
0 commit comments