@umijs/bundler-webpack 4.0.0-beta.9 → 4.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/compiled/autoprefixer/browserslist/index.d.ts +11 -7
  2. package/compiled/autoprefixer/index.js +3 -3
  3. package/compiled/autoprefixer/postcss/lib/at-rule.d.ts +1 -1
  4. package/compiled/autoprefixer/postcss/lib/comment.d.ts +1 -1
  5. package/compiled/autoprefixer/postcss/lib/container.d.ts +2 -2
  6. package/compiled/autoprefixer/postcss/lib/css-syntax-error.d.ts +55 -8
  7. package/compiled/autoprefixer/postcss/lib/declaration.d.ts +1 -1
  8. package/compiled/autoprefixer/postcss/lib/input.d.ts +26 -6
  9. package/compiled/autoprefixer/postcss/lib/lazy-result.d.ts +11 -10
  10. package/compiled/autoprefixer/postcss/lib/no-work-result.d.ts +37 -0
  11. package/compiled/autoprefixer/postcss/lib/node.d.ts +36 -2
  12. package/compiled/autoprefixer/postcss/lib/postcss.d.ts +31 -30
  13. package/compiled/autoprefixer/postcss/lib/processor.d.ts +5 -4
  14. package/compiled/autoprefixer/postcss/lib/result.d.ts +3 -2
  15. package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
  16. package/compiled/autoprefixer/postcss/lib/warning.d.ts +37 -3
  17. package/compiled/autoprefixer/source-map-js/source-map.d.ts +99 -82
  18. package/compiled/babel-loader/index.js +2 -2
  19. package/compiled/copy-webpack-plugin/576.index.js +1171 -0
  20. package/compiled/copy-webpack-plugin/index.js +16 -10
  21. package/compiled/copy-webpack-plugin/package.json +1 -1
  22. package/compiled/css-minimizer-webpack-plugin/index.js +8 -2
  23. package/compiled/css-minimizer-webpack-plugin/minify.js +25 -11
  24. package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
  25. package/compiled/css-minimizer-webpack-plugin/utils.js +225 -28
  26. package/compiled/cssnano/index.js +12 -11
  27. package/compiled/express/index.js +57 -74
  28. package/compiled/fork-ts-checker-webpack-plugin/LICENSE +21 -0
  29. package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
  30. package/compiled/fork-ts-checker-webpack-plugin/index.js +48 -0
  31. package/compiled/fork-ts-checker-webpack-plugin/package.json +1 -0
  32. package/compiled/http-proxy-middleware/dist/types.d.ts +5 -5
  33. package/compiled/http-proxy-middleware/http-proxy/index.d.ts +1 -1
  34. package/compiled/http-proxy-middleware/index.js +10 -10
  35. package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -8
  36. package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +13 -1
  37. package/compiled/mini-css-extract-plugin/index.js +8103 -7617
  38. package/compiled/mini-css-extract-plugin/loader.js +177 -54
  39. package/compiled/mini-css-extract-plugin/package.json +1 -1
  40. package/compiled/mini-css-extract-plugin/utils.js +83 -24
  41. package/compiled/postcss-loader/index.js +1 -1
  42. package/compiled/react-refresh/index.js +3 -3
  43. package/compiled/sass-loader/index.js +1 -1
  44. package/compiled/schema-utils/ajv/dist/ajv.d.ts +16 -0
  45. package/compiled/schema-utils/ajv/dist/compile/codegen/code.d.ts +39 -0
  46. package/compiled/schema-utils/ajv/dist/compile/codegen/index.d.ts +79 -0
  47. package/compiled/schema-utils/ajv/dist/compile/codegen/scope.d.ts +79 -0
  48. package/compiled/schema-utils/ajv/dist/compile/errors.d.ts +13 -0
  49. package/compiled/schema-utils/ajv/dist/compile/index.d.ts +80 -0
  50. package/compiled/schema-utils/ajv/dist/compile/ref_error.d.ts +5 -0
  51. package/compiled/schema-utils/ajv/dist/compile/resolve.d.ts +12 -0
  52. package/compiled/schema-utils/ajv/dist/compile/rules.d.ts +28 -0
  53. package/compiled/schema-utils/ajv/dist/compile/util.d.ts +40 -0
  54. package/compiled/schema-utils/ajv/dist/compile/validate/index.d.ts +42 -0
  55. package/compiled/schema-utils/ajv/dist/compile/validate/subschema.d.ts +47 -0
  56. package/compiled/schema-utils/ajv/dist/core.d.ts +171 -0
  57. package/compiled/schema-utils/ajv/dist/runtime/validation_error.d.ts +7 -0
  58. package/compiled/schema-utils/ajv/dist/types/index.d.ts +177 -0
  59. package/compiled/schema-utils/ajv/dist/types/json-schema.d.ts +124 -0
  60. package/compiled/schema-utils/ajv/dist/types/jtd-schema.d.ts +168 -0
  61. package/compiled/schema-utils/declarations/validate.d.ts +4 -4
  62. package/compiled/schema-utils/index.js +8 -2
  63. package/compiled/schema-utils/uri-js/dist/es5/uri.all.d.ts +59 -0
  64. package/compiled/style-loader/index.js +1 -1
  65. package/compiled/terser/index.js +1 -1
  66. package/compiled/terser-webpack-plugin/index.js +393 -517
  67. package/compiled/terser-webpack-plugin/jest-worker/build/types.d.ts +1 -0
  68. package/compiled/terser-webpack-plugin/minify.js +10 -3
  69. package/compiled/terser-webpack-plugin/package.json +1 -1
  70. package/compiled/terser-webpack-plugin/types/index.d.ts +183 -149
  71. package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
  72. package/compiled/terser-webpack-plugin/types/utils.d.ts +10 -15
  73. package/compiled/terser-webpack-plugin/utils.js +118 -25
  74. package/compiled/webpack/index.js +10464 -5286
  75. package/compiled/webpack-dev-middleware/index.js +11 -5
  76. package/compiled/webpack-dev-middleware/package.json +1 -1
  77. package/compiled/webpack-manifest-plugin/LICENSE +21 -0
  78. package/compiled/webpack-manifest-plugin/index.js +1 -0
  79. package/compiled/webpack-manifest-plugin/package.json +1 -0
  80. package/compiled/webpack-sources/index.js +1 -1
  81. package/compiled/ws/index.d.ts +1 -2
  82. package/compiled/ws/index.js +1 -1
  83. package/dist/build.d.ts +5 -3
  84. package/dist/build.js +2 -1
  85. package/dist/cli.js +4 -7
  86. package/dist/config/assetRules.js +6 -14
  87. package/dist/config/compressPlugin.js +6 -0
  88. package/dist/config/config.d.ts +7 -2
  89. package/dist/config/config.js +49 -7
  90. package/dist/config/cssRules.js +1 -1
  91. package/dist/config/detectDeadCode.d.ts +12 -0
  92. package/dist/config/detectDeadCode.js +120 -0
  93. package/dist/config/detectDeadCodePlugin.d.ts +9 -0
  94. package/dist/config/detectDeadCodePlugin.js +71 -0
  95. package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
  96. package/dist/config/forkTSCheckerPlugin.js +34 -0
  97. package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
  98. package/dist/config/harmonyLinkingErrorPlugin.js +42 -0
  99. package/dist/config/javaScriptRules.d.ts +1 -0
  100. package/dist/config/javaScriptRules.js +31 -20
  101. package/dist/config/manifestPlugin.d.ts +11 -0
  102. package/dist/config/manifestPlugin.js +25 -0
  103. package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
  104. package/dist/config/miniCSSExtractPlugin.js +2 -3
  105. package/dist/config/svgRules.d.ts +1 -0
  106. package/dist/config/svgRules.js +17 -3
  107. package/dist/constants.d.ts +3 -0
  108. package/dist/constants.js +4 -1
  109. package/dist/dev.d.ts +4 -2
  110. package/dist/dev.js +31 -5
  111. package/dist/loader/svgr.d.ts +4 -0
  112. package/dist/loader/svgr.js +67 -0
  113. package/dist/loader/swc.d.ts +4 -0
  114. package/dist/loader/swc.js +79 -0
  115. package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +10 -0
  116. package/dist/plugins/ParcelCSSMinifyPlugin.js +74 -0
  117. package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
  118. package/dist/plugins/RuntimePublicPathPlugin.js +20 -0
  119. package/dist/requireHook.js +1 -1
  120. package/dist/schema.js +14 -6
  121. package/dist/server/server.js +20 -1
  122. package/dist/swcPlugins/autoCSSModules.d.ts +7 -2
  123. package/dist/swcPlugins/autoCSSModules.js +13 -16
  124. package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
  125. package/dist/swcPlugins/lockCoreJS.js +23 -0
  126. package/dist/types.d.ts +16 -0
  127. package/dist/types.js +1 -0
  128. package/dist/utils/depMatch.js +1 -1
  129. package/package.json +45 -39
  130. package/compiled/@svgr/webpack/LICENSE +0 -7
  131. package/compiled/@svgr/webpack/index.js +0 -266
  132. package/compiled/@svgr/webpack/package.json +0 -1
  133. package/compiled/swc-loader/LICENSE +0 -25
  134. package/compiled/swc-loader/index.js +0 -1
  135. package/compiled/swc-loader/package.json +0 -1
@@ -86,6 +86,7 @@ export declare type WorkerOptions = {
86
86
  setupArgs: Array<unknown>;
87
87
  maxRetries: number;
88
88
  workerId: number;
89
+ workerData?: unknown;
89
90
  workerPath: string;
90
91
  };
91
92
  export declare type MessagePort = typeof EventEmitter & {
@@ -34,10 +34,17 @@ async function transform(options) {
34
34
  // 'use strict' => this === undefined (Clean Scope)
35
35
  // Safer for possible security issues, albeit not critical at all here
36
36
  // eslint-disable-next-line no-param-reassign
37
- const evaluatedOptions = // eslint-disable-next-line no-new-func
37
+ const evaluatedOptions =
38
+ /**
39
+ * @template T
40
+ * @type {import("./index.js").InternalOptions<T>}
41
+ * */
42
+ // eslint-disable-next-line no-new-func
38
43
  new Function("exports", "require", "module", "__filename", "__dirname", `'use strict'\nreturn ${options}`)(exports, require, module, __filename, __dirname);
39
44
  return minify(evaluatedOptions);
40
45
  }
41
46
 
42
- module.exports.minify = minify;
43
- module.exports.transform = transform;
47
+ module.exports = {
48
+ minify,
49
+ transform
50
+ };
@@ -1 +1 @@
1
- {"name":"terser-webpack-plugin","author":"webpack Contrib Team","license":"MIT","types":"types/cjs.d.ts"}
1
+ {"name":"terser-webpack-plugin","author":"webpack Contrib Team","license":"MIT","types":"types/index.d.ts"}
@@ -1,106 +1,4 @@
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').TerserECMA;
8
- export type TerserOptions = import('./utils').TerserOptions;
9
- export type CustomOptions = import('./utils').CustomOptions;
10
- export type JestWorker = import('../jest-worker').Worker;
11
- export type RawSourceMap = import('../source-map').RawSourceMap;
12
- export type Rule = RegExp | string;
13
- export type Rules = Rule[] | Rule;
14
- export type ExtractCommentsFunction = (
15
- astNode: any,
16
- comment: {
17
- value: string;
18
- type: "comment1" | "comment2" | "comment3" | "comment4";
19
- pos: number;
20
- line: number;
21
- col: number;
22
- }
23
- ) => boolean;
24
- export type ExtractCommentsCondition =
25
- | boolean
26
- | "all"
27
- | "some"
28
- | RegExp
29
- | ExtractCommentsFunction;
30
- export type ExtractCommentsFilename = string | ((fileData: any) => string);
31
- export type ExtractCommentsBanner =
32
- | string
33
- | boolean
34
- | ((commentsFile: string) => string);
35
- export type ExtractCommentsObject = {
36
- condition?: ExtractCommentsCondition | undefined;
37
- filename?: ExtractCommentsFilename | undefined;
38
- banner?: ExtractCommentsBanner | undefined;
39
- };
40
- export type ExtractCommentsOptions =
41
- | ExtractCommentsCondition
42
- | ExtractCommentsObject;
43
- export type Input = {
44
- [file: string]: string;
45
- };
46
- export type MinimizedResult = {
47
- code: string;
48
- map?: import('../source-map').RawSourceMap | undefined;
49
- errors?: (string | Error)[] | undefined;
50
- warnings?: (string | Error)[] | undefined;
51
- extractedComments?: string[] | undefined;
52
- };
53
- export type PredefinedOptions = {
54
- module?: boolean | undefined;
55
- ecma?: any;
56
- };
57
- export type MinimizerImplementationAndOptions<T> = {
58
- implementation: MinimizerImplementation<T>;
59
- options: PredefinedOptions & T;
60
- };
61
- export type InternalOptions<T> = {
62
- name: string;
63
- input: string;
64
- inputSourceMap: RawSourceMap | undefined;
65
- extractComments: ExtractCommentsOptions | undefined;
66
- minimizer: MinimizerImplementationAndOptions<T>;
67
- };
68
- export type MinimizerWorker<T> = Worker & {
69
- transform: (options: string) => MinimizedResult;
70
- minify: (options: InternalOptions<T>) => MinimizedResult;
71
- };
72
- export type BasicMinimizerImplementation<T> = (
73
- input: Input,
74
- sourceMap: RawSourceMap | undefined,
75
- minifyOptions: T,
76
- extractComments: ExtractCommentsOptions | undefined
77
- ) => Promise<MinimizedResult>;
78
- export type MinimizeFunctionHelpers = {
79
- getMinimizerVersion?: (() => string | undefined) | undefined;
80
- };
81
- export type MinimizerImplementation<T> = BasicMinimizerImplementation<T> &
82
- MinimizeFunctionHelpers;
83
- export type Parallel = undefined | boolean | number;
84
- export type BasePluginOptions = {
85
- test?: Rules | undefined;
86
- include?: Rules | undefined;
87
- exclude?: Rules | undefined;
88
- extractComments?: ExtractCommentsOptions | undefined;
89
- parallel?: Parallel;
90
- };
91
- export type InferDefaultType<T> = T extends infer U
92
- ? U
93
- : import('./utils').CustomOptions;
94
- export type DefinedDefaultMinimizerAndOptions<T> =
95
- InferDefaultType<T> extends TerserOptions
96
- ? {
97
- minify?: MinimizerImplementation<InferDefaultType<T>> | undefined;
98
- terserOptions?: InferDefaultType<T> | undefined;
99
- }
100
- : {
101
- minify: MinimizerImplementation<InferDefaultType<T>>;
102
- terserOptions?: InferDefaultType<T> | undefined;
103
- };
1
+ export = TerserPlugin;
104
2
  /** @typedef {import('../schema-utils/declarations/validate').Schema} Schema */
105
3
  /** @typedef {import('../../webpack').Compiler} Compiler */
106
4
  /** @typedef {import('../../webpack').Compilation} Compilation */
@@ -108,7 +6,6 @@ export type DefinedDefaultMinimizerAndOptions<T> =
108
6
  /** @typedef {import('../../webpack').Asset} Asset */
109
7
  /** @typedef {import('./utils').TerserECMA} TerserECMA */
110
8
  /** @typedef {import('./utils').TerserOptions} TerserOptions */
111
- /** @typedef {import('./utils').CustomOptions} CustomOptions */
112
9
  /** @typedef {import('../jest-worker').Worker} JestWorker */
113
10
  /** @typedef {import('../source-map').RawSourceMap} RawSourceMap */
114
11
  /** @typedef {RegExp | string} Rule */
@@ -137,9 +34,6 @@ export type DefinedDefaultMinimizerAndOptions<T> =
137
34
  /**
138
35
  * @typedef {ExtractCommentsCondition | ExtractCommentsObject} ExtractCommentsOptions
139
36
  */
140
- /**
141
- * @typedef {{ [file: string]: string }} Input
142
- */
143
37
  /**
144
38
  * @typedef {Object} MinimizedResult
145
39
  * @property {string} code
@@ -149,35 +43,30 @@ export type DefinedDefaultMinimizerAndOptions<T> =
149
43
  * @property {Array<string>} [extractedComments]
150
44
  */
151
45
  /**
152
- * @typedef {Object} PredefinedOptions
153
- * @property {boolean} [module]
154
- * @property {any} [ecma]
46
+ * @typedef {{ [file: string]: string }} Input
155
47
  */
156
48
  /**
157
- * @template T
158
- * @typedef {Object} MinimizerImplementationAndOptions
159
- * @property {MinimizerImplementation<T>} implementation
160
- * @property {PredefinedOptions & T} options
49
+ * @typedef {{ [key: string]: any }} CustomOptions
161
50
  */
162
51
  /**
163
52
  * @template T
164
- * @typedef {Object} InternalOptions
165
- * @property {string} name
166
- * @property {string} input
167
- * @property {RawSourceMap | undefined} inputSourceMap
168
- * @property {ExtractCommentsOptions | undefined} extractComments
169
- * @property {MinimizerImplementationAndOptions<T>} minimizer
53
+ * @typedef {T extends infer U ? U : CustomOptions} InferDefaultType
54
+ */
55
+ /**
56
+ * @typedef {Object} PredefinedOptions
57
+ * @property {boolean} [module]
58
+ * @property {TerserECMA} [ecma]
170
59
  */
171
60
  /**
172
61
  * @template T
173
- * @typedef {JestWorker & { transform: (options: string) => MinimizedResult, minify: (options: InternalOptions<T>) => MinimizedResult }} MinimizerWorker
62
+ * @typedef {PredefinedOptions & InferDefaultType<T>} MinimizerOptions
174
63
  */
175
64
  /**
176
65
  * @template T
177
66
  * @callback BasicMinimizerImplementation
178
67
  * @param {Input} input
179
68
  * @param {RawSourceMap | undefined} sourceMap
180
- * @param {T} minifyOptions
69
+ * @param {MinimizerOptions<T>} minifyOptions
181
70
  * @param {ExtractCommentsOptions | undefined} extractComments
182
71
  * @returns {Promise<MinimizedResult>}
183
72
  */
@@ -187,7 +76,20 @@ export type DefinedDefaultMinimizerAndOptions<T> =
187
76
  */
188
77
  /**
189
78
  * @template T
190
- * @typedef {BasicMinimizerImplementation<T> & MinimizeFunctionHelpers } MinimizerImplementation
79
+ * @typedef {BasicMinimizerImplementation<T> & MinimizeFunctionHelpers} MinimizerImplementation
80
+ */
81
+ /**
82
+ * @template T
83
+ * @typedef {Object} InternalOptions
84
+ * @property {string} name
85
+ * @property {string} input
86
+ * @property {RawSourceMap | undefined} inputSourceMap
87
+ * @property {ExtractCommentsOptions | undefined} extractComments
88
+ * @property {{ implementation: MinimizerImplementation<T>, options: MinimizerOptions<T> }} minimizer
89
+ */
90
+ /**
91
+ * @template T
92
+ * @typedef {JestWorker & { transform: (options: string) => MinimizedResult, minify: (options: InternalOptions<T>) => MinimizedResult }} MinimizerWorker
191
93
  */
192
94
  /**
193
95
  * @typedef {undefined | boolean | number} Parallel
@@ -202,16 +104,16 @@ export type DefinedDefaultMinimizerAndOptions<T> =
202
104
  */
203
105
  /**
204
106
  * @template T
205
- * @typedef {T extends infer U ? U : CustomOptions} InferDefaultType
107
+ * @typedef {T extends TerserOptions ? { minify?: MinimizerImplementation<T> | undefined, terserOptions?: MinimizerOptions<T> | undefined } : { minify: MinimizerImplementation<T>, terserOptions?: MinimizerOptions<T> | undefined }} DefinedDefaultMinimizerAndOptions
206
108
  */
207
109
  /**
208
110
  * @template T
209
- * @typedef {InferDefaultType<T> extends TerserOptions ? { minify?: MinimizerImplementation<InferDefaultType<T>> | undefined, terserOptions?: InferDefaultType<T> | undefined } : { minify: MinimizerImplementation<InferDefaultType<T>>, terserOptions?: InferDefaultType<T> | undefined }} DefinedDefaultMinimizerAndOptions
111
+ * @typedef {BasePluginOptions & { minimizer: { implementation: MinimizerImplementation<T>, options: MinimizerOptions<T> } }} InternalPluginOptions
210
112
  */
211
113
  /**
212
- * @template T
114
+ * @template [T=TerserOptions]
213
115
  */
214
- declare class TerserPlugin<T = TerserOptions> {
116
+ declare class TerserPlugin<T = import('../../terser').MinifyOptions> {
215
117
  /**
216
118
  * @private
217
119
  * @param {any} input
@@ -220,18 +122,18 @@ declare class TerserPlugin<T = TerserOptions> {
220
122
  private static isSourceMap;
221
123
  /**
222
124
  * @private
223
- * @param {Error | string} warning
125
+ * @param {unknown} warning
224
126
  * @param {string} file
225
- * @returns {WebpackError}
127
+ * @returns {Error}
226
128
  */
227
129
  private static buildWarning;
228
130
  /**
229
131
  * @private
230
132
  * @param {any} error
231
133
  * @param {string} file
232
- * @param {Compilation["requestShortener"]} [requestShortener]
233
134
  * @param {SourceMapConsumer} [sourceMap]
234
- * @returns {WebpackError}
135
+ * @param {Compilation["requestShortener"]} [requestShortener]
136
+ * @returns {Error}
235
137
  */
236
138
  private static buildError;
237
139
  /**
@@ -254,19 +156,11 @@ declare class TerserPlugin<T = TerserOptions> {
254
156
  | (BasePluginOptions & DefinedDefaultMinimizerAndOptions<T>)
255
157
  | undefined
256
158
  );
257
- options: {
258
- test: Rules;
259
- extractComments: ExtractCommentsOptions;
260
- parallel: number | boolean;
261
- include: Rules | undefined;
262
- exclude: Rules | undefined;
263
- minimizer: {
264
- implementation: MinimizerImplementation<
265
- import('../../terser').MinifyOptions & InferDefaultType<T>
266
- >;
267
- options: InferDefaultType<T>;
268
- };
269
- };
159
+ /**
160
+ * @private
161
+ * @type {InternalPluginOptions<T>}
162
+ */
163
+ private options;
270
164
  /**
271
165
  * @private
272
166
  * @param {Compiler} compiler
@@ -283,13 +177,153 @@ declare class TerserPlugin<T = TerserOptions> {
283
177
  apply(compiler: Compiler): void;
284
178
  }
285
179
  declare namespace TerserPlugin {
286
- export { terserMinify };
287
- export { uglifyJsMinify };
288
- export { swcMinify };
289
- 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
+ };
290
218
  }
291
- 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
+ };
292
236
  import { terserMinify } from './utils';
293
237
  import { uglifyJsMinify } from './utils';
294
238
  import { swcMinify } from './utils';
295
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').TerserECMA;
245
+ type TerserOptions = import('./utils').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?: import('../../terser').ECMA | undefined;
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,0 +1,17 @@
1
+ export type MinimizedResult = import('./index').MinimizedResult;
2
+ export type CustomOptions = import('./index').CustomOptions;
3
+ /** @typedef {import('./index').MinimizedResult} MinimizedResult */
4
+ /** @typedef {import('./index').CustomOptions} CustomOptions */
5
+ /**
6
+ * @template T
7
+ * @param {import('./index').InternalOptions<T>} options
8
+ * @returns {Promise<MinimizedResult>}
9
+ */
10
+ export function minify<T>(
11
+ options: import('./index').InternalOptions<T>
12
+ ): Promise<MinimizedResult>;
13
+ /**
14
+ * @param {string} options
15
+ * @returns {Promise<MinimizedResult>}
16
+ */
17
+ export function transform(options: string): Promise<MinimizedResult>;
@@ -1,3 +1,4 @@
1
+ export type Task<T> = () => Promise<T>;
1
2
  export type RawSourceMap = import('../source-map').RawSourceMap;
2
3
  export type TerserFormatOptions = import('../../terser').FormatOptions;
3
4
  export type TerserOptions = import('../../terser').MinifyOptions;
@@ -11,26 +12,20 @@ export type ExtractCommentsCondition =
11
12
  export type Input = import('./index').Input;
12
13
  export type MinimizedResult = import('./index').MinimizedResult;
13
14
  export type PredefinedOptions = import('./index').PredefinedOptions;
14
- export type CustomOptions = {
15
- [key: string]: any;
16
- };
15
+ export type CustomOptions = import('./index').CustomOptions;
17
16
  export type ExtractedComments = Array<string>;
18
- /** @typedef {import('../source-map').RawSourceMap} RawSourceMap */
19
- /** @typedef {import('../../terser').FormatOptions} TerserFormatOptions */
20
- /** @typedef {import('../../terser').MinifyOptions} TerserOptions */
21
- /** @typedef {import('../../terser').ECMA} TerserECMA */
22
- /** @typedef {import('./index').ExtractCommentsOptions} ExtractCommentsOptions */
23
- /** @typedef {import('./index').ExtractCommentsFunction} ExtractCommentsFunction */
24
- /** @typedef {import('./index').ExtractCommentsCondition} ExtractCommentsCondition */
25
- /** @typedef {import('./index').Input} Input */
26
- /** @typedef {import('./index').MinimizedResult} MinimizedResult */
27
- /** @typedef {import('./index').PredefinedOptions} PredefinedOptions */
28
17
  /**
29
- * @typedef {{ [key: string]: any }} CustomOptions
18
+ * @template T
19
+ * @typedef {() => Promise<T>} Task
30
20
  */
31
21
  /**
32
- * @typedef {Array<string>} ExtractedComments
22
+ * Run tasks with limited concurency.
23
+ * @template T
24
+ * @param {number} limit - Limit of tasks that run at once.
25
+ * @param {Task<T>[]} tasks - List of tasks to run.
26
+ * @returns {Promise<T[]>} A promise that fulfills to an array of the results
33
27
  */
28
+ export function throttleAll<T>(limit: number, tasks: Task<T>[]): Promise<T[]>;
34
29
  /**
35
30
  * @param {Input} input
36
31
  * @param {RawSourceMap | undefined} sourceMap