@umijs/bundler-webpack 4.0.0-beta.9 → 4.0.0-canary-20240513.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/client/client/client.js +255 -167
- package/client/constants.d.ts +15 -0
- package/client/constants.js +30 -12
- package/client/utils/formatWebpackMessages.d.ts +12 -0
- package/client/utils/formatWebpackMessages.js +87 -86
- package/compiled/autoprefixer/browserslist/index.d.ts +33 -7
- package/compiled/autoprefixer/index.js +3 -3
- package/compiled/autoprefixer/package.json +1 -1
- 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 +2 -2
- 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 +38 -4
- package/compiled/autoprefixer/postcss/lib/postcss.d.ts +31 -30
- package/compiled/autoprefixer/postcss/lib/processor.d.ts +6 -5
- 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 +8 -2
- package/compiled/babel-loader/package.json +1 -1
- package/compiled/copy-webpack-plugin/939.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 +23 -22
- package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/utils.js +305 -54
- package/compiled/cssnano/index.js +12 -11
- package/compiled/cssnano/package.json +1 -1
- package/compiled/express.d.ts +2 -0
- package/compiled/file-loader/index.js +3 -0
- package/compiled/file-loader/package.json +1 -0
- package/compiled/less-loader/index.js +1 -1
- package/compiled/less-loader/package.json +1 -1
- package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -46
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +10 -6
- package/compiled/mini-css-extract-plugin/index.js +10669 -10348
- package/compiled/mini-css-extract-plugin/loader.js +159 -100
- package/compiled/mini-css-extract-plugin/package.json +1 -1
- package/compiled/mini-css-extract-plugin/utils.js +88 -44
- package/compiled/postcss-loader/index.js +1 -1
- package/compiled/postcss-loader/package.json +1 -1
- package/compiled/sass-loader/index.js +1 -1
- package/compiled/sass-loader/package.json +1 -1
- package/compiled/sass-loader/sass.default.dart.js +4 -0
- 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/stylus-loader/LICENSE +20 -0
- package/compiled/stylus-loader/index.js +44 -0
- package/compiled/stylus-loader/package.json +1 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +90 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/types.d.ts +35 -0
- package/compiled/terser/@jridgewell/source-map/dist/types/source-map.d.ts +25 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/terser/index.js +1 -1
- package/compiled/terser/package.json +1 -1
- package/compiled/terser/tools/terser.d.ts +6 -3
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/terser-webpack-plugin/index.js +1390 -3693
- 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 +186 -152
- package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
- package/compiled/terser-webpack-plugin/types/utils.d.ts +20 -24
- package/compiled/terser-webpack-plugin/utils.js +153 -34
- package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
- package/compiled/webpack/BasicEvaluatedExpression.js +1 -0
- package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
- package/compiled/webpack/ExternalsPlugin.js +1 -0
- package/compiled/webpack/FetchCompileAsyncWasmPlugin.js +1 -0
- package/compiled/webpack/FetchCompileWasmPlugin.js +1 -0
- package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/compiled/webpack/LimitChunkCountPlugin.js +1 -0
- package/compiled/webpack/NodeTargetPlugin.js +1 -0
- package/compiled/webpack/NodeTemplatePlugin.js +1 -0
- package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
- package/compiled/webpack/RuleSetCompiler.js +1 -0
- package/compiled/webpack/StringXor.js +1 -0
- package/compiled/webpack/UseEffectRulePlugin.js +1 -0
- package/compiled/webpack/WebWorkerTemplatePlugin.js +1 -0
- package/compiled/webpack/deepImports.json +15 -1
- package/compiled/webpack/index.js +26404 -10329
- package/compiled/webpack/json-schema/index.d.ts +8 -1
- package/compiled/webpack/lazy-compilation-node.js +10 -0
- package/compiled/webpack/lazy-compilation-web.js +9 -0
- package/compiled/webpack/types.d.ts +823 -287
- package/compiled/webpack-5-chain/index.js +1 -1
- package/compiled/webpack-5-chain/package.json +1 -1
- package/compiled/webpack-5-chain/types/index.d.ts +76 -20
- package/compiled/webpack-bundle-analyzer/index.js +7 -6
- package/compiled/webpack-bundle-analyzer/package.json +1 -1
- package/compiled/webpack-bundle-analyzer/public/viewer.js +2 -2
- package/compiled/webpack-bundle-analyzer/public/viewer.js.map +1 -1
- package/compiled/webpack-dev-middleware/index.js +12 -5
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/{tapable → webpack-manifest-plugin}/LICENSE +2 -2
- 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/{express → webpackbar}/LICENSE +1 -5
- package/compiled/webpackbar/dist/index.d.ts +121 -0
- package/compiled/webpackbar/index.js +7 -0
- package/compiled/webpackbar/package.json +1 -0
- package/compiled/ws/LICENSE +13 -12
- package/compiled/ws/index.d.ts +74 -35
- package/compiled/ws/index.js +1 -1
- package/compiled/ws/package.json +1 -1
- package/dist/build.d.ts +8 -3
- package/dist/build.js +147 -68
- package/dist/cli.js +84 -81
- package/dist/config/_sampleFeature.js +33 -20
- package/dist/config/assetRules.js +46 -67
- package/dist/config/bundleAnalyzerPlugin.js +41 -28
- package/dist/config/compressPlugin.js +125 -74
- package/dist/config/config.d.ts +11 -2
- package/dist/config/config.js +235 -172
- package/dist/config/copyPlugin.js +61 -47
- package/dist/config/cssRules.js +162 -95
- package/dist/config/definePlugin.d.ts +2 -0
- package/dist/config/definePlugin.js +59 -39
- package/dist/config/detectCssModulesInDependence.d.ts +10 -0
- package/dist/config/detectCssModulesInDependence.js +151 -0
- package/dist/config/detectDeadCode.d.ts +12 -0
- package/dist/config/detectDeadCode.js +191 -0
- package/dist/config/detectDeadCodePlugin.d.ts +9 -0
- package/dist/config/detectDeadCodePlugin.js +82 -0
- package/dist/config/fastRefreshPlugin.js +46 -31
- package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
- package/dist/config/forkTSCheckerPlugin.js +49 -0
- package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
- package/dist/config/harmonyLinkingErrorPlugin.js +53 -0
- package/dist/config/ignorePlugin.js +38 -25
- package/dist/config/javaScriptRules.d.ts +2 -0
- package/dist/config/javaScriptRules.js +186 -150
- package/dist/config/manifestPlugin.d.ts +11 -0
- package/dist/config/manifestPlugin.js +40 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
- package/dist/config/miniCSSExtractPlugin.js +52 -31
- package/dist/config/nodePolyfill.js +49 -32
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +38 -0
- package/dist/config/progressPlugin.js +50 -24
- package/dist/config/purgecssWebpackPlugin.js +41 -30
- package/dist/config/speedMeasureWebpackPlugin.js +56 -31
- package/dist/config/ssrPlugin.d.ts +11 -0
- package/dist/config/ssrPlugin.js +98 -0
- package/dist/config/svgRules.d.ts +1 -0
- package/dist/config/svgRules.js +68 -41
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +59 -15
- package/dist/dev.d.ts +23 -2
- package/dist/dev.js +198 -81
- package/dist/index.d.ts +6 -1
- package/dist/index.js +31 -15
- package/dist/loader/svgr.d.ts +4 -0
- package/dist/loader/svgr.js +84 -0
- package/dist/loader/swc.d.ts +4 -0
- package/dist/loader/swc.js +149 -0
- package/dist/parcelCSS.d.ts +2 -0
- package/dist/parcelCSS.js +39 -0
- package/dist/plugins/EsbuildMinifyFix.d.ts +8 -0
- package/dist/plugins/EsbuildMinifyFix.js +136 -0
- package/dist/plugins/ProgressPlugin.js +68 -43
- package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
- package/dist/plugins/RuntimePublicPathPlugin.js +45 -0
- package/dist/plugins/_SamplePlugin.d.ts +1 -1
- package/dist/plugins/_SamplePlugin.js +37 -14
- package/dist/requireHook.js +44 -27
- package/dist/schema.d.ts +4 -3
- package/dist/schema.js +175 -69
- package/dist/server/server.d.ts +4 -3
- package/dist/server/server.js +219 -154
- package/dist/server/ws.d.ts +8 -3
- package/dist/server/ws.js +72 -38
- package/dist/swcPlugins/autoCSSModules.d.ts +11 -2
- package/dist/swcPlugins/autoCSSModules.js +60 -32
- package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
- package/dist/swcPlugins/changeImportFromString.js +32 -0
- package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
- package/dist/swcPlugins/lockCoreJS.js +56 -0
- package/dist/types.d.ts +53 -9
- package/dist/types.js +61 -29
- package/dist/utils/browsersList.js +31 -8
- package/dist/utils/depMatch.js +65 -39
- package/dist/utils/formatWebpackMessages.js +119 -91
- package/dist/utils/getEsBuildTarget.d.ts +7 -0
- package/dist/utils/getEsBuildTarget.js +46 -0
- package/dist/utils/pkgUpContainsName.d.ts +1 -0
- package/dist/utils/pkgUpContainsName.js +50 -0
- package/package.json +76 -68
- 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/css-loader/api.js +0 -102
- package/compiled/css-loader/getUrl.js +0 -29
- package/compiled/css-loader/index.js +0 -2
- package/compiled/css-loader/noSourceMaps.js +0 -5
- package/compiled/css-loader/package.json +0 -1
- package/compiled/css-loader/sourceMaps.js +0 -22
- package/compiled/express/body-parser/index.d.ts +0 -104
- package/compiled/express/connect/index.d.ts +0 -93
- package/compiled/express/express-serve-static-core/index.d.ts +0 -1252
- package/compiled/express/index.d.ts +0 -133
- package/compiled/express/index.js +0 -338
- package/compiled/express/mime/index.d.ts +0 -35
- package/compiled/express/package.json +0 -1
- package/compiled/express/qs/index.d.ts +0 -62
- package/compiled/express/range-parser/index.d.ts +0 -35
- package/compiled/express/serve-static/index.d.ts +0 -108
- package/compiled/http-proxy-middleware/LICENSE +0 -22
- package/compiled/http-proxy-middleware/dist/index.d.ts +0 -4
- package/compiled/http-proxy-middleware/dist/types.d.ts +0 -54
- package/compiled/http-proxy-middleware/http-proxy/index.d.ts +0 -226
- package/compiled/http-proxy-middleware/index.js +0 -66
- package/compiled/http-proxy-middleware/package.json +0 -1
- package/compiled/less/index.js +0 -31
- package/compiled/less/package.json +0 -1
- package/compiled/react-refresh/index.js +0 -19
- package/compiled/swc-loader/LICENSE +0 -25
- package/compiled/swc-loader/index.js +0 -1
- package/compiled/swc-loader/package.json +0 -1
- package/compiled/tapable/index.js +0 -1
- package/compiled/tapable/package.json +0 -1
- package/compiled/tapable/tapable.d.ts +0 -116
- package/dist/client/client.js +0 -239
- package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -65
- /package/{dist → client}/client/client.d.ts +0 -0
- /package/compiled/{css-loader → file-loader}/LICENSE +0 -0
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.terserMinify = terserMinify;
|
|
7
|
-
exports.uglifyJsMinify = uglifyJsMinify;
|
|
8
|
-
exports.swcMinify = swcMinify;
|
|
9
|
-
exports.esbuildMinify = esbuildMinify;
|
|
10
|
-
|
|
11
|
-
/** @typedef {import("source-map").RawSourceMap} RawSourceMap */
|
|
3
|
+
/** @typedef {import("@jridgewell/trace-mapping").SourceMapInput} SourceMapInput */
|
|
12
4
|
|
|
13
5
|
/** @typedef {import("terser").FormatOptions} TerserFormatOptions */
|
|
14
6
|
|
|
15
7
|
/** @typedef {import("terser").MinifyOptions} TerserOptions */
|
|
16
8
|
|
|
9
|
+
/** @typedef {import("terser").CompressOptions} TerserCompressOptions */
|
|
10
|
+
|
|
17
11
|
/** @typedef {import("terser").ECMA} TerserECMA */
|
|
18
12
|
|
|
19
13
|
/** @typedef {import("./index.js").ExtractCommentsOptions} ExtractCommentsOptions */
|
|
@@ -28,23 +22,79 @@ exports.esbuildMinify = esbuildMinify;
|
|
|
28
22
|
|
|
29
23
|
/** @typedef {import("./index.js").PredefinedOptions} PredefinedOptions */
|
|
30
24
|
|
|
25
|
+
/** @typedef {import("./index.js").CustomOptions} CustomOptions */
|
|
26
|
+
|
|
31
27
|
/**
|
|
32
|
-
* @typedef {
|
|
28
|
+
* @typedef {Array<string>} ExtractedComments
|
|
29
|
+
*/
|
|
30
|
+
const notSettled = Symbol(`not-settled`);
|
|
31
|
+
/**
|
|
32
|
+
* @template T
|
|
33
|
+
* @typedef {() => Promise<T>} Task
|
|
33
34
|
*/
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
|
-
*
|
|
37
|
+
* Run tasks with limited concurency.
|
|
38
|
+
* @template T
|
|
39
|
+
* @param {number} limit - Limit of tasks that run at once.
|
|
40
|
+
* @param {Task<T>[]} tasks - List of tasks to run.
|
|
41
|
+
* @returns {Promise<T[]>} A promise that fulfills to an array of the results
|
|
37
42
|
*/
|
|
38
43
|
|
|
44
|
+
function throttleAll(limit, tasks) {
|
|
45
|
+
if (!Number.isInteger(limit) || limit < 1) {
|
|
46
|
+
throw new TypeError(`Expected \`limit\` to be a finite number > 0, got \`${limit}\` (${typeof limit})`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!Array.isArray(tasks) || !tasks.every(task => typeof task === `function`)) {
|
|
50
|
+
throw new TypeError(`Expected \`tasks\` to be a list of functions returning a promise`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
const result = Array(tasks.length).fill(notSettled);
|
|
55
|
+
const entries = tasks.entries();
|
|
56
|
+
|
|
57
|
+
const next = () => {
|
|
58
|
+
const {
|
|
59
|
+
done,
|
|
60
|
+
value
|
|
61
|
+
} = entries.next();
|
|
62
|
+
|
|
63
|
+
if (done) {
|
|
64
|
+
const isLast = !result.includes(notSettled);
|
|
65
|
+
if (isLast) resolve(
|
|
66
|
+
/** @type{T[]} **/
|
|
67
|
+
result);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const [index, task] = value;
|
|
72
|
+
/**
|
|
73
|
+
* @param {T} x
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
const onFulfilled = x => {
|
|
77
|
+
result[index] = x;
|
|
78
|
+
next();
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
task().then(onFulfilled, reject);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
Array(limit).fill(0).forEach(next);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
39
87
|
/* istanbul ignore next */
|
|
40
88
|
|
|
41
89
|
/**
|
|
42
90
|
* @param {Input} input
|
|
43
|
-
* @param {
|
|
91
|
+
* @param {SourceMapInput | undefined} sourceMap
|
|
44
92
|
* @param {PredefinedOptions & CustomOptions} minimizerOptions
|
|
45
93
|
* @param {ExtractCommentsOptions | undefined} extractComments
|
|
46
94
|
* @return {Promise<MinimizedResult>}
|
|
47
95
|
*/
|
|
96
|
+
|
|
97
|
+
|
|
48
98
|
async function terserMinify(input, sourceMap, minimizerOptions, extractComments) {
|
|
49
99
|
/**
|
|
50
100
|
* @param {any} value
|
|
@@ -117,21 +167,33 @@ async function terserMinify(input, sourceMap, minimizerOptions, extractComments)
|
|
|
117
167
|
}
|
|
118
168
|
|
|
119
169
|
if (condition[key] === "some") {
|
|
120
|
-
condition[key] =
|
|
170
|
+
condition[key] =
|
|
171
|
+
/** @type {ExtractCommentsFunction} */
|
|
172
|
+
(astNode, comment) => (comment.type === "comment2" || comment.type === "comment1") && /@preserve|@lic|@cc_on|^\**!/i.test(comment.value);
|
|
121
173
|
|
|
122
174
|
break;
|
|
123
175
|
}
|
|
124
176
|
|
|
125
|
-
regexStr =
|
|
177
|
+
regexStr =
|
|
178
|
+
/** @type {string} */
|
|
179
|
+
condition[key];
|
|
126
180
|
|
|
127
|
-
condition[key] =
|
|
181
|
+
condition[key] =
|
|
182
|
+
/** @type {ExtractCommentsFunction} */
|
|
183
|
+
(astNode, comment) => new RegExp(
|
|
184
|
+
/** @type {string} */
|
|
185
|
+
regexStr).test(comment.value);
|
|
128
186
|
|
|
129
187
|
break;
|
|
130
188
|
|
|
131
189
|
default:
|
|
132
|
-
regex =
|
|
190
|
+
regex =
|
|
191
|
+
/** @type {RegExp} */
|
|
192
|
+
condition[key];
|
|
133
193
|
|
|
134
|
-
condition[key] =
|
|
194
|
+
condition[key] =
|
|
195
|
+
/** @type {ExtractCommentsFunction} */
|
|
196
|
+
(astNode, comment) =>
|
|
135
197
|
/** @type {RegExp} */
|
|
136
198
|
regex.test(comment.value);
|
|
137
199
|
|
|
@@ -158,14 +220,14 @@ async function terserMinify(input, sourceMap, minimizerOptions, extractComments)
|
|
|
158
220
|
};
|
|
159
221
|
/**
|
|
160
222
|
* @param {PredefinedOptions & TerserOptions} [terserOptions={}]
|
|
161
|
-
* @returns {TerserOptions & { sourceMap: undefined } & ({ output: TerserFormatOptions & { beautify: boolean } } | { format: TerserFormatOptions & { beautify: boolean } })}
|
|
223
|
+
* @returns {TerserOptions & { sourceMap: undefined } & { compress: TerserCompressOptions } & ({ output: TerserFormatOptions & { beautify: boolean } } | { format: TerserFormatOptions & { beautify: boolean } })}
|
|
162
224
|
*/
|
|
163
225
|
|
|
164
226
|
|
|
165
227
|
const buildTerserOptions = (terserOptions = {}) => {
|
|
166
228
|
// Need deep copy objects to avoid https://github.com/terser/terser/issues/366
|
|
167
229
|
return { ...terserOptions,
|
|
168
|
-
compress: typeof terserOptions.compress === "boolean" ? terserOptions.compress : { ...terserOptions.compress
|
|
230
|
+
compress: typeof terserOptions.compress === "boolean" ? terserOptions.compress ? {} : false : { ...terserOptions.compress
|
|
169
231
|
},
|
|
170
232
|
// ecma: terserOptions.ecma,
|
|
171
233
|
// ie8: terserOptions.ie8,
|
|
@@ -222,15 +284,31 @@ async function terserMinify(input, sourceMap, minimizerOptions, extractComments)
|
|
|
222
284
|
terserOptions.format.comments = buildComments(terserOptions, extractedComments);
|
|
223
285
|
}
|
|
224
286
|
|
|
287
|
+
if (terserOptions.compress) {
|
|
288
|
+
// More optimizations
|
|
289
|
+
if (typeof terserOptions.compress.ecma === "undefined") {
|
|
290
|
+
terserOptions.compress.ecma = terserOptions.ecma;
|
|
291
|
+
} // https://github.com/webpack/webpack/issues/16135
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
if (terserOptions.ecma === 5 && typeof terserOptions.compress.arrows === "undefined") {
|
|
295
|
+
terserOptions.compress.arrows = false;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
225
299
|
const [[filename, code]] = Object.entries(input);
|
|
226
300
|
const result = await minify({
|
|
227
301
|
[filename]: code
|
|
228
302
|
}, terserOptions);
|
|
229
303
|
return {
|
|
230
|
-
code:
|
|
304
|
+
code:
|
|
305
|
+
/** @type {string} **/
|
|
306
|
+
result.code,
|
|
231
307
|
// @ts-ignore
|
|
232
308
|
// eslint-disable-next-line no-undefined
|
|
233
|
-
map: result.map ?
|
|
309
|
+
map: result.map ?
|
|
310
|
+
/** @type {SourceMapInput} **/
|
|
311
|
+
result.map : undefined,
|
|
234
312
|
extractedComments
|
|
235
313
|
};
|
|
236
314
|
}
|
|
@@ -254,7 +332,7 @@ terserMinify.getMinimizerVersion = () => {
|
|
|
254
332
|
|
|
255
333
|
/**
|
|
256
334
|
* @param {Input} input
|
|
257
|
-
* @param {
|
|
335
|
+
* @param {SourceMapInput | undefined} sourceMap
|
|
258
336
|
* @param {PredefinedOptions & CustomOptions} minimizerOptions
|
|
259
337
|
* @param {ExtractCommentsOptions | undefined} extractComments
|
|
260
338
|
* @return {Promise<MinimizedResult>}
|
|
@@ -324,21 +402,33 @@ async function uglifyJsMinify(input, sourceMap, minimizerOptions, extractComment
|
|
|
324
402
|
}
|
|
325
403
|
|
|
326
404
|
if (condition[key] === "some") {
|
|
327
|
-
condition[key] =
|
|
405
|
+
condition[key] =
|
|
406
|
+
/** @type {ExtractCommentsFunction} */
|
|
407
|
+
(astNode, comment) => (comment.type === "comment2" || comment.type === "comment1") && /@preserve|@lic|@cc_on|^\**!/i.test(comment.value);
|
|
328
408
|
|
|
329
409
|
break;
|
|
330
410
|
}
|
|
331
411
|
|
|
332
|
-
regexStr =
|
|
412
|
+
regexStr =
|
|
413
|
+
/** @type {string} */
|
|
414
|
+
condition[key];
|
|
333
415
|
|
|
334
|
-
condition[key] =
|
|
416
|
+
condition[key] =
|
|
417
|
+
/** @type {ExtractCommentsFunction} */
|
|
418
|
+
(astNode, comment) => new RegExp(
|
|
419
|
+
/** @type {string} */
|
|
420
|
+
regexStr).test(comment.value);
|
|
335
421
|
|
|
336
422
|
break;
|
|
337
423
|
|
|
338
424
|
default:
|
|
339
|
-
regex =
|
|
425
|
+
regex =
|
|
426
|
+
/** @type {RegExp} */
|
|
427
|
+
condition[key];
|
|
340
428
|
|
|
341
|
-
condition[key] =
|
|
429
|
+
condition[key] =
|
|
430
|
+
/** @type {ExtractCommentsFunction} */
|
|
431
|
+
(astNode, comment) =>
|
|
342
432
|
/** @type {RegExp} */
|
|
343
433
|
regex.test(comment.value);
|
|
344
434
|
|
|
@@ -448,7 +538,7 @@ uglifyJsMinify.getMinimizerVersion = () => {
|
|
|
448
538
|
|
|
449
539
|
/**
|
|
450
540
|
* @param {Input} input
|
|
451
|
-
* @param {
|
|
541
|
+
* @param {SourceMapInput | undefined} sourceMap
|
|
452
542
|
* @param {PredefinedOptions & CustomOptions} minimizerOptions
|
|
453
543
|
* @return {Promise<MinimizedResult>}
|
|
454
544
|
*/
|
|
@@ -457,12 +547,12 @@ uglifyJsMinify.getMinimizerVersion = () => {
|
|
|
457
547
|
async function swcMinify(input, sourceMap, minimizerOptions) {
|
|
458
548
|
/**
|
|
459
549
|
* @param {PredefinedOptions & import("@swc/core").JsMinifyOptions} [swcOptions={}]
|
|
460
|
-
* @returns {import("@swc/core").JsMinifyOptions & { sourceMap: undefined }}
|
|
550
|
+
* @returns {import("@swc/core").JsMinifyOptions & { sourceMap: undefined } & { compress: import("@swc/core").TerserCompressOptions }}
|
|
461
551
|
*/
|
|
462
552
|
const buildSwcOptions = (swcOptions = {}) => {
|
|
463
553
|
// Need deep copy objects to avoid https://github.com/terser/terser/issues/366
|
|
464
554
|
return { ...swcOptions,
|
|
465
|
-
compress: typeof swcOptions.compress === "boolean" ? swcOptions.compress : { ...swcOptions.compress
|
|
555
|
+
compress: typeof swcOptions.compress === "boolean" ? swcOptions.compress ? {} : false : { ...swcOptions.compress
|
|
466
556
|
},
|
|
467
557
|
mangle: swcOptions.mangle == null ? true : typeof swcOptions.mangle === "boolean" ? swcOptions.mangle : { ...swcOptions.mangle
|
|
468
558
|
},
|
|
@@ -488,6 +578,18 @@ async function swcMinify(input, sourceMap, minimizerOptions) {
|
|
|
488
578
|
swcOptions.sourceMap = true;
|
|
489
579
|
}
|
|
490
580
|
|
|
581
|
+
if (swcOptions.compress) {
|
|
582
|
+
// More optimizations
|
|
583
|
+
if (typeof swcOptions.compress.ecma === "undefined") {
|
|
584
|
+
swcOptions.compress.ecma = swcOptions.ecma;
|
|
585
|
+
} // https://github.com/webpack/webpack/issues/16135
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
if (swcOptions.ecma === 5 && typeof swcOptions.compress.arrows === "undefined") {
|
|
589
|
+
swcOptions.compress.arrows = false;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
491
593
|
const [[filename, code]] = Object.entries(input);
|
|
492
594
|
const result = await swc.minify(code, swcOptions);
|
|
493
595
|
let map;
|
|
@@ -524,7 +626,7 @@ swcMinify.getMinimizerVersion = () => {
|
|
|
524
626
|
|
|
525
627
|
/**
|
|
526
628
|
* @param {Input} input
|
|
527
|
-
* @param {
|
|
629
|
+
* @param {SourceMapInput | undefined} sourceMap
|
|
528
630
|
* @param {PredefinedOptions & CustomOptions} minimizerOptions
|
|
529
631
|
* @return {Promise<MinimizedResult>}
|
|
530
632
|
*/
|
|
@@ -556,10 +658,10 @@ async function esbuildMinify(input, sourceMap, minimizerOptions) {
|
|
|
556
658
|
}; // eslint-disable-next-line import/no-extraneous-dependencies, global-require
|
|
557
659
|
|
|
558
660
|
|
|
559
|
-
const esbuild = require('@umijs/bundler-utils/compiled/esbuild'); // Copy `
|
|
661
|
+
const esbuild = require('@umijs/bundler-utils/compiled/esbuild'); // Copy `esbuild` options
|
|
560
662
|
|
|
561
663
|
|
|
562
|
-
const esbuildOptions = buildEsbuildOptions(minimizerOptions); // Let `
|
|
664
|
+
const esbuildOptions = buildEsbuildOptions(minimizerOptions); // Let `esbuild` generate a SourceMap
|
|
563
665
|
|
|
564
666
|
if (sourceMap) {
|
|
565
667
|
esbuildOptions.sourcemap = true;
|
|
@@ -573,7 +675,16 @@ async function esbuildMinify(input, sourceMap, minimizerOptions) {
|
|
|
573
675
|
code: result.code,
|
|
574
676
|
// eslint-disable-next-line no-undefined
|
|
575
677
|
map: result.map ? JSON.parse(result.map) : undefined,
|
|
576
|
-
warnings: result.warnings ? result.warnings.map(item =>
|
|
678
|
+
warnings: result.warnings.length > 0 ? result.warnings.map(item => {
|
|
679
|
+
return {
|
|
680
|
+
name: "Warning",
|
|
681
|
+
source: item.location && item.location.file,
|
|
682
|
+
line: item.location && item.location.line,
|
|
683
|
+
column: item.location && item.location.column,
|
|
684
|
+
plugin: item.pluginName,
|
|
685
|
+
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")}` : ""}`
|
|
686
|
+
};
|
|
687
|
+
}) : []
|
|
577
688
|
};
|
|
578
689
|
}
|
|
579
690
|
/**
|
|
@@ -591,4 +702,12 @@ esbuildMinify.getMinimizerVersion = () => {
|
|
|
591
702
|
}
|
|
592
703
|
|
|
593
704
|
return packageJson && packageJson.version;
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
module.exports = {
|
|
708
|
+
throttleAll,
|
|
709
|
+
terserMinify,
|
|
710
|
+
uglifyJsMinify,
|
|
711
|
+
swcMinify,
|
|
712
|
+
esbuildMinify
|
|
594
713
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').BasicEffectRulePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').BasicEvaluatedExpression;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').BasicMatcherRulePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').ExternalsPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').FetchCompileAsyncWasmPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').FetchCompileWasmPlugin;
|
|
@@ -28,7 +28,8 @@ module.exports = function () {
|
|
|
28
28
|
var currentStatus = "idle";
|
|
29
29
|
|
|
30
30
|
// while downloading
|
|
31
|
-
var blockingPromises;
|
|
31
|
+
var blockingPromises = 0;
|
|
32
|
+
var blockingPromisesWaiting = [];
|
|
32
33
|
|
|
33
34
|
// The update info
|
|
34
35
|
var currentUpdateApplyHandlers;
|
|
@@ -218,17 +219,28 @@ module.exports = function () {
|
|
|
218
219
|
return Promise.all(results);
|
|
219
220
|
}
|
|
220
221
|
|
|
222
|
+
function unblock() {
|
|
223
|
+
if (--blockingPromises === 0) {
|
|
224
|
+
setStatus("ready").then(function () {
|
|
225
|
+
if (blockingPromises === 0) {
|
|
226
|
+
var list = blockingPromisesWaiting;
|
|
227
|
+
blockingPromisesWaiting = [];
|
|
228
|
+
for (var i = 0; i < list.length; i++) {
|
|
229
|
+
list[i]();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
221
236
|
function trackBlockingPromise(promise) {
|
|
222
237
|
switch (currentStatus) {
|
|
223
238
|
case "ready":
|
|
224
239
|
setStatus("prepare");
|
|
225
|
-
|
|
226
|
-
waitForBlockingPromises(function () {
|
|
227
|
-
return setStatus("ready");
|
|
228
|
-
});
|
|
229
|
-
return promise;
|
|
240
|
+
/* fallthrough */
|
|
230
241
|
case "prepare":
|
|
231
|
-
blockingPromises
|
|
242
|
+
blockingPromises++;
|
|
243
|
+
promise.then(unblock, unblock);
|
|
232
244
|
return promise;
|
|
233
245
|
default:
|
|
234
246
|
return promise;
|
|
@@ -236,11 +248,11 @@ module.exports = function () {
|
|
|
236
248
|
}
|
|
237
249
|
|
|
238
250
|
function waitForBlockingPromises(fn) {
|
|
239
|
-
if (blockingPromises
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
251
|
+
if (blockingPromises === 0) return fn();
|
|
252
|
+
return new Promise(function (resolve) {
|
|
253
|
+
blockingPromisesWaiting.push(function () {
|
|
254
|
+
resolve(fn());
|
|
255
|
+
});
|
|
244
256
|
});
|
|
245
257
|
}
|
|
246
258
|
|
|
@@ -261,7 +273,6 @@ module.exports = function () {
|
|
|
261
273
|
|
|
262
274
|
return setStatus("prepare").then(function () {
|
|
263
275
|
var updatedModules = [];
|
|
264
|
-
blockingPromises = [];
|
|
265
276
|
currentUpdateApplyHandlers = [];
|
|
266
277
|
|
|
267
278
|
return Promise.all(
|
|
@@ -298,7 +309,11 @@ module.exports = function () {
|
|
|
298
309
|
function hotApply(options) {
|
|
299
310
|
if (currentStatus !== "ready") {
|
|
300
311
|
return Promise.resolve().then(function () {
|
|
301
|
-
throw new Error(
|
|
312
|
+
throw new Error(
|
|
313
|
+
"apply() is only allowed in ready status (state: " +
|
|
314
|
+
currentStatus +
|
|
315
|
+
")"
|
|
316
|
+
);
|
|
302
317
|
});
|
|
303
318
|
}
|
|
304
319
|
return internalApply(options);
|
|
@@ -443,15 +443,16 @@ module.exports = function () {
|
|
|
443
443
|
) {
|
|
444
444
|
promises.push($loadUpdateChunk$(chunkId, updatedModulesList));
|
|
445
445
|
currentUpdateChunks[chunkId] = true;
|
|
446
|
+
} else {
|
|
447
|
+
currentUpdateChunks[chunkId] = false;
|
|
446
448
|
}
|
|
447
449
|
});
|
|
448
450
|
if ($ensureChunkHandlers$) {
|
|
449
451
|
$ensureChunkHandlers$.$key$Hmr = function (chunkId, promises) {
|
|
450
452
|
if (
|
|
451
453
|
currentUpdateChunks &&
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
$installedChunks$[chunkId] !== undefined
|
|
454
|
+
$hasOwnProperty$(currentUpdateChunks, chunkId) &&
|
|
455
|
+
!currentUpdateChunks[chunkId]
|
|
455
456
|
) {
|
|
456
457
|
promises.push($loadUpdateChunk$(chunkId));
|
|
457
458
|
currentUpdateChunks[chunkId] = true;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').LimitChunkCountPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').NodeTargetPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').NodeTemplatePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').ObjectMatcherRulePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').RuleSetCompiler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').StringXor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').UseEffectRulePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./').WebWorkerTemplatePlugin;
|
|
@@ -8,5 +8,19 @@
|
|
|
8
8
|
"webpack/lib/RuntimeGlobals",
|
|
9
9
|
"webpack/lib/RuntimeModule",
|
|
10
10
|
"webpack/lib/SingleEntryPlugin",
|
|
11
|
-
"webpack/lib/Template"
|
|
11
|
+
"webpack/lib/Template",
|
|
12
|
+
"webpack/lib/rules/BasicEffectRulePlugin",
|
|
13
|
+
"webpack/lib/rules/BasicMatcherRulePlugin",
|
|
14
|
+
"webpack/lib/rules/ObjectMatcherRulePlugin",
|
|
15
|
+
"webpack/lib/rules/RuleSetCompiler",
|
|
16
|
+
"webpack/lib/rules/UseEffectRulePlugin",
|
|
17
|
+
"webpack/lib/node/NodeTargetPlugin",
|
|
18
|
+
"webpack/lib/webworker/WebWorkerTemplatePlugin",
|
|
19
|
+
"webpack/lib/ExternalsPlugin",
|
|
20
|
+
"webpack/lib/javascript/BasicEvaluatedExpression",
|
|
21
|
+
"webpack/lib/node/NodeTemplatePlugin",
|
|
22
|
+
"webpack/lib/optimize/LimitChunkCountPlugin",
|
|
23
|
+
"webpack/lib/web/FetchCompileAsyncWasmPlugin",
|
|
24
|
+
"webpack/lib/web/FetchCompileWasmPlugin",
|
|
25
|
+
"webpack/lib/util/StringXor"
|
|
12
26
|
]
|