@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.
- package/compiled/autoprefixer/browserslist/index.d.ts +11 -7
- package/compiled/autoprefixer/index.js +3 -3
- package/compiled/autoprefixer/postcss/lib/at-rule.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/comment.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/container.d.ts +2 -2
- package/compiled/autoprefixer/postcss/lib/css-syntax-error.d.ts +55 -8
- package/compiled/autoprefixer/postcss/lib/declaration.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/input.d.ts +26 -6
- package/compiled/autoprefixer/postcss/lib/lazy-result.d.ts +11 -10
- package/compiled/autoprefixer/postcss/lib/no-work-result.d.ts +37 -0
- package/compiled/autoprefixer/postcss/lib/node.d.ts +36 -2
- package/compiled/autoprefixer/postcss/lib/postcss.d.ts +31 -30
- package/compiled/autoprefixer/postcss/lib/processor.d.ts +5 -4
- package/compiled/autoprefixer/postcss/lib/result.d.ts +3 -2
- package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/warning.d.ts +37 -3
- package/compiled/autoprefixer/source-map-js/source-map.d.ts +99 -82
- package/compiled/babel-loader/index.js +2 -2
- package/compiled/copy-webpack-plugin/576.index.js +1171 -0
- package/compiled/copy-webpack-plugin/index.js +16 -10
- package/compiled/copy-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/index.js +8 -2
- package/compiled/css-minimizer-webpack-plugin/minify.js +25 -11
- package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/utils.js +225 -28
- package/compiled/cssnano/index.js +12 -11
- package/compiled/express/index.js +57 -74
- package/compiled/fork-ts-checker-webpack-plugin/LICENSE +21 -0
- package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
- package/compiled/fork-ts-checker-webpack-plugin/index.js +48 -0
- package/compiled/fork-ts-checker-webpack-plugin/package.json +1 -0
- package/compiled/http-proxy-middleware/dist/types.d.ts +5 -5
- package/compiled/http-proxy-middleware/http-proxy/index.d.ts +1 -1
- package/compiled/http-proxy-middleware/index.js +10 -10
- package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -8
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +13 -1
- package/compiled/mini-css-extract-plugin/index.js +8103 -7617
- package/compiled/mini-css-extract-plugin/loader.js +177 -54
- package/compiled/mini-css-extract-plugin/package.json +1 -1
- package/compiled/mini-css-extract-plugin/utils.js +83 -24
- package/compiled/postcss-loader/index.js +1 -1
- package/compiled/react-refresh/index.js +3 -3
- package/compiled/sass-loader/index.js +1 -1
- package/compiled/schema-utils/ajv/dist/ajv.d.ts +16 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/code.d.ts +39 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/compiled/schema-utils/ajv/dist/compile/errors.d.ts +13 -0
- package/compiled/schema-utils/ajv/dist/compile/index.d.ts +80 -0
- package/compiled/schema-utils/ajv/dist/compile/ref_error.d.ts +5 -0
- package/compiled/schema-utils/ajv/dist/compile/resolve.d.ts +12 -0
- package/compiled/schema-utils/ajv/dist/compile/rules.d.ts +28 -0
- package/compiled/schema-utils/ajv/dist/compile/util.d.ts +40 -0
- package/compiled/schema-utils/ajv/dist/compile/validate/index.d.ts +42 -0
- package/compiled/schema-utils/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/compiled/schema-utils/ajv/dist/core.d.ts +171 -0
- package/compiled/schema-utils/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/compiled/schema-utils/ajv/dist/types/index.d.ts +177 -0
- package/compiled/schema-utils/ajv/dist/types/json-schema.d.ts +124 -0
- package/compiled/schema-utils/ajv/dist/types/jtd-schema.d.ts +168 -0
- package/compiled/schema-utils/declarations/validate.d.ts +4 -4
- package/compiled/schema-utils/index.js +8 -2
- package/compiled/schema-utils/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/compiled/style-loader/index.js +1 -1
- package/compiled/terser/index.js +1 -1
- package/compiled/terser-webpack-plugin/index.js +393 -517
- package/compiled/terser-webpack-plugin/jest-worker/build/types.d.ts +1 -0
- package/compiled/terser-webpack-plugin/minify.js +10 -3
- package/compiled/terser-webpack-plugin/package.json +1 -1
- package/compiled/terser-webpack-plugin/types/index.d.ts +183 -149
- package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
- package/compiled/terser-webpack-plugin/types/utils.d.ts +10 -15
- package/compiled/terser-webpack-plugin/utils.js +118 -25
- package/compiled/webpack/index.js +10464 -5286
- package/compiled/webpack-dev-middleware/index.js +11 -5
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/webpack-manifest-plugin/LICENSE +21 -0
- package/compiled/webpack-manifest-plugin/index.js +1 -0
- package/compiled/webpack-manifest-plugin/package.json +1 -0
- package/compiled/webpack-sources/index.js +1 -1
- package/compiled/ws/index.d.ts +1 -2
- package/compiled/ws/index.js +1 -1
- package/dist/build.d.ts +5 -3
- package/dist/build.js +2 -1
- package/dist/cli.js +4 -7
- package/dist/config/assetRules.js +6 -14
- package/dist/config/compressPlugin.js +6 -0
- package/dist/config/config.d.ts +7 -2
- package/dist/config/config.js +49 -7
- package/dist/config/cssRules.js +1 -1
- package/dist/config/detectDeadCode.d.ts +12 -0
- package/dist/config/detectDeadCode.js +120 -0
- package/dist/config/detectDeadCodePlugin.d.ts +9 -0
- package/dist/config/detectDeadCodePlugin.js +71 -0
- package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
- package/dist/config/forkTSCheckerPlugin.js +34 -0
- package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
- package/dist/config/harmonyLinkingErrorPlugin.js +42 -0
- package/dist/config/javaScriptRules.d.ts +1 -0
- package/dist/config/javaScriptRules.js +31 -20
- package/dist/config/manifestPlugin.d.ts +11 -0
- package/dist/config/manifestPlugin.js +25 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
- package/dist/config/miniCSSExtractPlugin.js +2 -3
- package/dist/config/svgRules.d.ts +1 -0
- package/dist/config/svgRules.js +17 -3
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +4 -1
- package/dist/dev.d.ts +4 -2
- package/dist/dev.js +31 -5
- package/dist/loader/svgr.d.ts +4 -0
- package/dist/loader/svgr.js +67 -0
- package/dist/loader/swc.d.ts +4 -0
- package/dist/loader/swc.js +79 -0
- package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +10 -0
- package/dist/plugins/ParcelCSSMinifyPlugin.js +74 -0
- package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
- package/dist/plugins/RuntimePublicPathPlugin.js +20 -0
- package/dist/requireHook.js +1 -1
- package/dist/schema.js +14 -6
- package/dist/server/server.js +20 -1
- package/dist/swcPlugins/autoCSSModules.d.ts +7 -2
- package/dist/swcPlugins/autoCSSModules.js +13 -16
- package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
- package/dist/swcPlugins/lockCoreJS.js +23 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.js +1 -0
- package/dist/utils/depMatch.js +1 -1
- package/package.json +45 -39
- package/compiled/@svgr/webpack/LICENSE +0 -7
- package/compiled/@svgr/webpack/index.js +0 -266
- package/compiled/@svgr/webpack/package.json +0 -1
- package/compiled/swc-loader/LICENSE +0 -25
- package/compiled/swc-loader/index.js +0 -1
- package/compiled/swc-loader/package.json +0 -1
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.terserMinify = terserMinify;
|
|
7
|
-
exports.uglifyJsMinify = uglifyJsMinify;
|
|
8
|
-
exports.swcMinify = swcMinify;
|
|
9
|
-
exports.esbuildMinify = esbuildMinify;
|
|
10
|
-
|
|
11
3
|
/** @typedef {import("source-map").RawSourceMap} RawSourceMap */
|
|
12
4
|
|
|
13
5
|
/** @typedef {import("terser").FormatOptions} TerserFormatOptions */
|
|
@@ -28,14 +20,68 @@ exports.esbuildMinify = esbuildMinify;
|
|
|
28
20
|
|
|
29
21
|
/** @typedef {import("./index.js").PredefinedOptions} PredefinedOptions */
|
|
30
22
|
|
|
23
|
+
/** @typedef {import("./index.js").CustomOptions} CustomOptions */
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {Array<string>} ExtractedComments
|
|
27
|
+
*/
|
|
28
|
+
const notSettled = Symbol(`not-settled`);
|
|
31
29
|
/**
|
|
32
|
-
* @
|
|
30
|
+
* @template T
|
|
31
|
+
* @typedef {() => Promise<T>} Task
|
|
33
32
|
*/
|
|
34
33
|
|
|
35
34
|
/**
|
|
36
|
-
*
|
|
35
|
+
* Run tasks with limited concurency.
|
|
36
|
+
* @template T
|
|
37
|
+
* @param {number} limit - Limit of tasks that run at once.
|
|
38
|
+
* @param {Task<T>[]} tasks - List of tasks to run.
|
|
39
|
+
* @returns {Promise<T[]>} A promise that fulfills to an array of the results
|
|
37
40
|
*/
|
|
38
41
|
|
|
42
|
+
function throttleAll(limit, tasks) {
|
|
43
|
+
if (!Number.isInteger(limit) || limit < 1) {
|
|
44
|
+
throw new TypeError(`Expected \`limit\` to be a finite number > 0, got \`${limit}\` (${typeof limit})`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!Array.isArray(tasks) || !tasks.every(task => typeof task === `function`)) {
|
|
48
|
+
throw new TypeError(`Expected \`tasks\` to be a list of functions returning a promise`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
const result = Array(tasks.length).fill(notSettled);
|
|
53
|
+
const entries = tasks.entries();
|
|
54
|
+
|
|
55
|
+
const next = () => {
|
|
56
|
+
const {
|
|
57
|
+
done,
|
|
58
|
+
value
|
|
59
|
+
} = entries.next();
|
|
60
|
+
|
|
61
|
+
if (done) {
|
|
62
|
+
const isLast = !result.includes(notSettled);
|
|
63
|
+
if (isLast) resolve(
|
|
64
|
+
/** @type{T[]} **/
|
|
65
|
+
result);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const [index, task] = value;
|
|
70
|
+
/**
|
|
71
|
+
* @param {T} x
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
const onFulfilled = x => {
|
|
75
|
+
result[index] = x;
|
|
76
|
+
next();
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
task().then(onFulfilled, reject);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
Array(limit).fill(0).forEach(next);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
39
85
|
/* istanbul ignore next */
|
|
40
86
|
|
|
41
87
|
/**
|
|
@@ -45,6 +91,8 @@ exports.esbuildMinify = esbuildMinify;
|
|
|
45
91
|
* @param {ExtractCommentsOptions | undefined} extractComments
|
|
46
92
|
* @return {Promise<MinimizedResult>}
|
|
47
93
|
*/
|
|
94
|
+
|
|
95
|
+
|
|
48
96
|
async function terserMinify(input, sourceMap, minimizerOptions, extractComments) {
|
|
49
97
|
/**
|
|
50
98
|
* @param {any} value
|
|
@@ -117,21 +165,33 @@ async function terserMinify(input, sourceMap, minimizerOptions, extractComments)
|
|
|
117
165
|
}
|
|
118
166
|
|
|
119
167
|
if (condition[key] === "some") {
|
|
120
|
-
condition[key] =
|
|
168
|
+
condition[key] =
|
|
169
|
+
/** @type {ExtractCommentsFunction} */
|
|
170
|
+
(astNode, comment) => (comment.type === "comment2" || comment.type === "comment1") && /@preserve|@lic|@cc_on|^\**!/i.test(comment.value);
|
|
121
171
|
|
|
122
172
|
break;
|
|
123
173
|
}
|
|
124
174
|
|
|
125
|
-
regexStr =
|
|
175
|
+
regexStr =
|
|
176
|
+
/** @type {string} */
|
|
177
|
+
condition[key];
|
|
126
178
|
|
|
127
|
-
condition[key] =
|
|
179
|
+
condition[key] =
|
|
180
|
+
/** @type {ExtractCommentsFunction} */
|
|
181
|
+
(astNode, comment) => new RegExp(
|
|
182
|
+
/** @type {string} */
|
|
183
|
+
regexStr).test(comment.value);
|
|
128
184
|
|
|
129
185
|
break;
|
|
130
186
|
|
|
131
187
|
default:
|
|
132
|
-
regex =
|
|
188
|
+
regex =
|
|
189
|
+
/** @type {RegExp} */
|
|
190
|
+
condition[key];
|
|
133
191
|
|
|
134
|
-
condition[key] =
|
|
192
|
+
condition[key] =
|
|
193
|
+
/** @type {ExtractCommentsFunction} */
|
|
194
|
+
(astNode, comment) =>
|
|
135
195
|
/** @type {RegExp} */
|
|
136
196
|
regex.test(comment.value);
|
|
137
197
|
|
|
@@ -227,10 +287,14 @@ async function terserMinify(input, sourceMap, minimizerOptions, extractComments)
|
|
|
227
287
|
[filename]: code
|
|
228
288
|
}, terserOptions);
|
|
229
289
|
return {
|
|
230
|
-
code:
|
|
290
|
+
code:
|
|
291
|
+
/** @type {string} **/
|
|
292
|
+
result.code,
|
|
231
293
|
// @ts-ignore
|
|
232
294
|
// eslint-disable-next-line no-undefined
|
|
233
|
-
map: result.map ?
|
|
295
|
+
map: result.map ?
|
|
296
|
+
/** @type {RawSourceMap} **/
|
|
297
|
+
result.map : undefined,
|
|
234
298
|
extractedComments
|
|
235
299
|
};
|
|
236
300
|
}
|
|
@@ -324,21 +388,33 @@ async function uglifyJsMinify(input, sourceMap, minimizerOptions, extractComment
|
|
|
324
388
|
}
|
|
325
389
|
|
|
326
390
|
if (condition[key] === "some") {
|
|
327
|
-
condition[key] =
|
|
391
|
+
condition[key] =
|
|
392
|
+
/** @type {ExtractCommentsFunction} */
|
|
393
|
+
(astNode, comment) => (comment.type === "comment2" || comment.type === "comment1") && /@preserve|@lic|@cc_on|^\**!/i.test(comment.value);
|
|
328
394
|
|
|
329
395
|
break;
|
|
330
396
|
}
|
|
331
397
|
|
|
332
|
-
regexStr =
|
|
398
|
+
regexStr =
|
|
399
|
+
/** @type {string} */
|
|
400
|
+
condition[key];
|
|
333
401
|
|
|
334
|
-
condition[key] =
|
|
402
|
+
condition[key] =
|
|
403
|
+
/** @type {ExtractCommentsFunction} */
|
|
404
|
+
(astNode, comment) => new RegExp(
|
|
405
|
+
/** @type {string} */
|
|
406
|
+
regexStr).test(comment.value);
|
|
335
407
|
|
|
336
408
|
break;
|
|
337
409
|
|
|
338
410
|
default:
|
|
339
|
-
regex =
|
|
411
|
+
regex =
|
|
412
|
+
/** @type {RegExp} */
|
|
413
|
+
condition[key];
|
|
340
414
|
|
|
341
|
-
condition[key] =
|
|
415
|
+
condition[key] =
|
|
416
|
+
/** @type {ExtractCommentsFunction} */
|
|
417
|
+
(astNode, comment) =>
|
|
342
418
|
/** @type {RegExp} */
|
|
343
419
|
regex.test(comment.value);
|
|
344
420
|
|
|
@@ -556,10 +632,10 @@ async function esbuildMinify(input, sourceMap, minimizerOptions) {
|
|
|
556
632
|
}; // eslint-disable-next-line import/no-extraneous-dependencies, global-require
|
|
557
633
|
|
|
558
634
|
|
|
559
|
-
const esbuild = require('@umijs/bundler-utils/compiled/esbuild'); // Copy `
|
|
635
|
+
const esbuild = require('@umijs/bundler-utils/compiled/esbuild'); // Copy `esbuild` options
|
|
560
636
|
|
|
561
637
|
|
|
562
|
-
const esbuildOptions = buildEsbuildOptions(minimizerOptions); // Let `
|
|
638
|
+
const esbuildOptions = buildEsbuildOptions(minimizerOptions); // Let `esbuild` generate a SourceMap
|
|
563
639
|
|
|
564
640
|
if (sourceMap) {
|
|
565
641
|
esbuildOptions.sourcemap = true;
|
|
@@ -573,7 +649,16 @@ async function esbuildMinify(input, sourceMap, minimizerOptions) {
|
|
|
573
649
|
code: result.code,
|
|
574
650
|
// eslint-disable-next-line no-undefined
|
|
575
651
|
map: result.map ? JSON.parse(result.map) : undefined,
|
|
576
|
-
warnings: result.warnings ? result.warnings.map(item =>
|
|
652
|
+
warnings: result.warnings.length > 0 ? result.warnings.map(item => {
|
|
653
|
+
return {
|
|
654
|
+
name: "Warning",
|
|
655
|
+
source: item.location && item.location.file,
|
|
656
|
+
line: item.location && item.location.line,
|
|
657
|
+
column: item.location && item.location.column,
|
|
658
|
+
plugin: item.pluginName,
|
|
659
|
+
message: `${item.text}${item.detail ? `\nDetails:\n${item.detail}` : ""}${item.notes.length > 0 ? `\n\nNotes:\n${item.notes.map(note => `${note.location ? `[${note.location.file}:${note.location.line}:${note.location.column}] ` : ""}${note.text}${note.location ? `\nSuggestion: ${note.location.suggestion}` : ""}${note.location ? `\nLine text:\n${note.location.lineText}\n` : ""}`).join("\n")}` : ""}`
|
|
660
|
+
};
|
|
661
|
+
}) : []
|
|
577
662
|
};
|
|
578
663
|
}
|
|
579
664
|
/**
|
|
@@ -591,4 +676,12 @@ esbuildMinify.getMinimizerVersion = () => {
|
|
|
591
676
|
}
|
|
592
677
|
|
|
593
678
|
return packageJson && packageJson.version;
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
module.exports = {
|
|
682
|
+
throttleAll,
|
|
683
|
+
terserMinify,
|
|
684
|
+
uglifyJsMinify,
|
|
685
|
+
swcMinify,
|
|
686
|
+
esbuildMinify
|
|
594
687
|
};
|