@umijs/bundler-webpack 4.0.0-canary.20220718.1 → 4.0.0-canary.20220727.1
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.d.ts +1 -0
- package/client/client/client.js +172 -192
- package/client/constants.d.ts +15 -0
- package/client/constants.js +28 -19
- package/client/utils/formatWebpackMessages.d.ts +12 -0
- package/client/utils/formatWebpackMessages.js +68 -86
- package/dist/build.d.ts +1 -2
- package/dist/build.js +105 -68
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +77 -69
- package/dist/config/_sampleFeature.d.ts +0 -1
- package/dist/config/_sampleFeature.js +33 -9
- package/dist/config/assetRules.d.ts +0 -1
- package/dist/config/assetRules.js +45 -36
- package/dist/config/bundleAnalyzerPlugin.d.ts +0 -1
- package/dist/config/bundleAnalyzerPlugin.js +39 -17
- package/dist/config/compressPlugin.d.ts +0 -1
- package/dist/config/compressPlugin.js +113 -95
- package/dist/config/config.d.ts +1 -1
- package/dist/config/config.js +204 -218
- package/dist/config/copyPlugin.d.ts +0 -1
- package/dist/config/copyPlugin.js +59 -40
- package/dist/config/cssRules.d.ts +0 -1
- package/dist/config/cssRules.js +136 -131
- package/dist/config/definePlugin.d.ts +0 -1
- package/dist/config/definePlugin.js +71 -35
- package/dist/config/detectDeadCode.d.ts +0 -1
- package/dist/config/detectDeadCode.js +120 -108
- package/dist/config/detectDeadCodePlugin.d.ts +0 -1
- package/dist/config/detectDeadCodePlugin.js +78 -63
- package/dist/config/fastRefreshPlugin.d.ts +0 -1
- package/dist/config/fastRefreshPlugin.js +39 -20
- package/dist/config/forkTSCheckerPlugin.d.ts +0 -1
- package/dist/config/forkTSCheckerPlugin.js +38 -18
- package/dist/config/harmonyLinkingErrorPlugin.d.ts +0 -1
- package/dist/config/harmonyLinkingErrorPlugin.js +48 -29
- package/dist/config/ignorePlugin.d.ts +0 -1
- package/dist/config/ignorePlugin.js +38 -14
- package/dist/config/javaScriptRules.d.ts +0 -1
- package/dist/config/javaScriptRules.js +147 -175
- package/dist/config/manifestPlugin.d.ts +0 -1
- package/dist/config/manifestPlugin.js +51 -15
- package/dist/config/miniCSSExtractPlugin.d.ts +0 -1
- package/dist/config/miniCSSExtractPlugin.js +42 -22
- package/dist/config/nodePolyfill.d.ts +0 -1
- package/dist/config/nodePolyfill.js +65 -26
- package/dist/config/nodePrefixPlugin.d.ts +0 -1
- package/dist/config/nodePrefixPlugin.js +36 -12
- package/dist/config/progressPlugin.d.ts +0 -1
- package/dist/config/progressPlugin.js +37 -13
- package/dist/config/purgecssWebpackPlugin.d.ts +0 -1
- package/dist/config/purgecssWebpackPlugin.js +41 -19
- package/dist/config/speedMeasureWebpackPlugin.d.ts +0 -1
- package/dist/config/speedMeasureWebpackPlugin.js +41 -20
- package/dist/config/ssrPlugin.d.ts +0 -1
- package/dist/config/ssrPlugin.js +83 -63
- package/dist/config/svgRules.d.ts +0 -1
- package/dist/config/svgRules.js +74 -46
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +57 -22
- package/dist/dev.d.ts +1 -2
- package/dist/dev.js +170 -135
- package/dist/index.d.ts +0 -1
- package/dist/index.js +22 -20
- package/dist/loader/svgr.d.ts +0 -1
- package/dist/loader/svgr.js +73 -54
- package/dist/loader/swc.d.ts +0 -1
- package/dist/loader/swc.js +110 -69
- package/dist/parcelCSS.d.ts +0 -1
- package/dist/parcelCSS.js +31 -27
- package/dist/plugins/ProgressPlugin.d.ts +0 -1
- package/dist/plugins/ProgressPlugin.js +66 -43
- package/dist/plugins/RuntimePublicPathPlugin.d.ts +0 -1
- package/dist/plugins/RuntimePublicPathPlugin.js +42 -25
- package/dist/plugins/_SamplePlugin.d.ts +0 -1
- package/dist/plugins/_SamplePlugin.js +39 -14
- package/dist/requireHook.d.ts +0 -1
- package/dist/requireHook.js +37 -27
- package/dist/schema.d.ts +0 -1
- package/dist/schema.js +120 -97
- package/dist/server/server.d.ts +0 -2
- package/dist/server/server.js +214 -184
- package/dist/server/ws.d.ts +0 -3
- package/dist/server/ws.js +63 -38
- package/dist/swcPlugins/autoCSSModules.d.ts +0 -1
- package/dist/swcPlugins/autoCSSModules.js +50 -31
- package/dist/swcPlugins/changeImportFromString.d.ts +0 -1
- package/dist/swcPlugins/changeImportFromString.js +31 -9
- package/dist/swcPlugins/lockCoreJS.d.ts +0 -1
- package/dist/swcPlugins/lockCoreJS.js +44 -20
- package/dist/types.d.ts +2 -2
- package/dist/types.js +61 -30
- package/dist/utils/browsersList.d.ts +0 -1
- package/dist/utils/browsersList.js +31 -8
- package/dist/utils/depMatch.d.ts +0 -1
- package/dist/utils/depMatch.js +63 -39
- package/dist/utils/formatWebpackMessages.d.ts +0 -1
- package/dist/utils/formatWebpackMessages.js +93 -91
- package/dist/utils/getEsBuildTarget.d.ts +0 -1
- package/dist/utils/getEsBuildTarget.js +32 -10
- package/package.json +10 -15
- package/compiled/react-refresh/LICENSE +0 -21
- package/compiled/react-refresh/index.js +0 -21
- package/compiled/react-refresh/package.json +0 -1
- package/dist/build.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/client/client.d.ts +0 -2
- package/dist/client/client.d.ts.map +0 -1
- package/dist/client/client.js +0 -245
- package/dist/config/_sampleFeature.d.ts.map +0 -1
- package/dist/config/assetRules.d.ts.map +0 -1
- package/dist/config/bundleAnalyzerPlugin.d.ts.map +0 -1
- package/dist/config/compressPlugin.d.ts.map +0 -1
- package/dist/config/config.d.ts.map +0 -1
- package/dist/config/copyPlugin.d.ts.map +0 -1
- package/dist/config/cssRules.d.ts.map +0 -1
- package/dist/config/definePlugin.d.ts.map +0 -1
- package/dist/config/detectDeadCode.d.ts.map +0 -1
- package/dist/config/detectDeadCodePlugin.d.ts.map +0 -1
- package/dist/config/fastRefreshPlugin.d.ts.map +0 -1
- package/dist/config/forkTSCheckerPlugin.d.ts.map +0 -1
- package/dist/config/harmonyLinkingErrorPlugin.d.ts.map +0 -1
- package/dist/config/ignorePlugin.d.ts.map +0 -1
- package/dist/config/javaScriptRules.d.ts.map +0 -1
- package/dist/config/manifestPlugin.d.ts.map +0 -1
- package/dist/config/miniCSSExtractPlugin.d.ts.map +0 -1
- package/dist/config/nodePolyfill.d.ts.map +0 -1
- package/dist/config/nodePrefixPlugin.d.ts.map +0 -1
- package/dist/config/progressPlugin.d.ts.map +0 -1
- package/dist/config/purgecssWebpackPlugin.d.ts.map +0 -1
- package/dist/config/speedMeasureWebpackPlugin.d.ts.map +0 -1
- package/dist/config/ssrPlugin.d.ts.map +0 -1
- package/dist/config/svgRules.d.ts.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/dev.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/loader/svgr.d.ts.map +0 -1
- package/dist/loader/swc.d.ts.map +0 -1
- package/dist/parcelCSS.d.ts.map +0 -1
- package/dist/plugins/ProgressPlugin.d.ts.map +0 -1
- package/dist/plugins/RuntimePublicPathPlugin.d.ts.map +0 -1
- package/dist/plugins/_SamplePlugin.d.ts.map +0 -1
- package/dist/requireHook.d.ts.map +0 -1
- package/dist/schema.d.ts.map +0 -1
- package/dist/server/server.d.ts.map +0 -1
- package/dist/server/ws.d.ts.map +0 -1
- package/dist/swcPlugins/autoCSSModules.d.ts.map +0 -1
- package/dist/swcPlugins/changeImportFromString.d.ts.map +0 -1
- package/dist/swcPlugins/lockCoreJS.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/browsersList.d.ts.map +0 -1
- package/dist/utils/depMatch.d.ts.map +0 -1
- package/dist/utils/formatWebpackMessages.d.ts.map +0 -1
- package/dist/utils/getEsBuildTarget.d.ts.map +0 -1
|
@@ -1,102 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __export = (target, all) => {
|
|
22
|
+
for (var name in all)
|
|
23
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
|
+
};
|
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
4
32
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
|
|
36
|
+
// compressPlugin.ts
|
|
37
|
+
var compressPlugin_exports = {};
|
|
38
|
+
__export(compressPlugin_exports, {
|
|
39
|
+
addCompressPlugin: () => addCompressPlugin
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(compressPlugin_exports);
|
|
42
|
+
var import_css_minimizer_webpack_plugin = __toESM(require("@umijs/bundler-webpack/compiled/css-minimizer-webpack-plugin"));
|
|
43
|
+
var import_terser_webpack_plugin = __toESM(require("../../compiled/terser-webpack-plugin"));
|
|
44
|
+
var import_types = require("../types");
|
|
45
|
+
var import_getEsBuildTarget = require("../utils/getEsBuildTarget");
|
|
12
46
|
async function addCompressPlugin(opts) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let terserOptions;
|
|
29
|
-
if (jsMinifier === types_1.JSMinifier.esbuild) {
|
|
30
|
-
minify = terser_webpack_plugin_1.default.esbuildMinify;
|
|
31
|
-
terserOptions = {
|
|
32
|
-
target: esbuildTarget,
|
|
33
|
-
// remove all comments
|
|
34
|
-
legalComments: 'none',
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
else if (jsMinifier === types_1.JSMinifier.terser) {
|
|
38
|
-
minify = terser_webpack_plugin_1.default.terserMinify;
|
|
39
|
-
terserOptions = {
|
|
40
|
-
format: {
|
|
41
|
-
comments: false,
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
else if (jsMinifier === types_1.JSMinifier.swc) {
|
|
46
|
-
minify = terser_webpack_plugin_1.default.swcMinify;
|
|
47
|
-
}
|
|
48
|
-
else if (jsMinifier === types_1.JSMinifier.uglifyJs) {
|
|
49
|
-
minify = terser_webpack_plugin_1.default.uglifyJsMinify;
|
|
50
|
-
terserOptions = {
|
|
51
|
-
output: {
|
|
52
|
-
comments: false,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
else if (jsMinifier !== types_1.JSMinifier.none) {
|
|
57
|
-
throw new Error(`Unsupported jsMinifier ${userConfig.jsMinifier}.`);
|
|
58
|
-
}
|
|
47
|
+
const { config, userConfig, env } = opts;
|
|
48
|
+
const jsMinifier = userConfig.jsMinifier || import_types.JSMinifier.esbuild;
|
|
49
|
+
const cssMinifier = userConfig.cssMinifier || import_types.CSSMinifier.esbuild;
|
|
50
|
+
if (env === import_types.Env.development || process.env.COMPRESS === "none" || jsMinifier === import_types.JSMinifier.none && cssMinifier === import_types.CSSMinifier.none) {
|
|
51
|
+
config.optimization.minimize(false);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
config.optimization.minimize(true);
|
|
55
|
+
const esbuildTarget = (0, import_getEsBuildTarget.getEsBuildTarget)({
|
|
56
|
+
targets: userConfig.targets || {}
|
|
57
|
+
});
|
|
58
|
+
let minify;
|
|
59
|
+
let terserOptions;
|
|
60
|
+
if (jsMinifier === import_types.JSMinifier.esbuild) {
|
|
61
|
+
minify = import_terser_webpack_plugin.default.esbuildMinify;
|
|
59
62
|
terserOptions = {
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
target: esbuildTarget,
|
|
64
|
+
legalComments: "none"
|
|
62
65
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
]);
|
|
71
|
-
}
|
|
72
|
-
let cssMinify;
|
|
73
|
-
let minimizerOptions;
|
|
74
|
-
if (cssMinifier === types_1.CSSMinifier.esbuild) {
|
|
75
|
-
cssMinify = css_minimizer_webpack_plugin_1.default.esbuildMinify;
|
|
76
|
-
minimizerOptions = {
|
|
77
|
-
target: esbuildTarget,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
else if (cssMinifier === types_1.CSSMinifier.cssnano) {
|
|
81
|
-
cssMinify = css_minimizer_webpack_plugin_1.default.cssnanoMinify;
|
|
82
|
-
}
|
|
83
|
-
else if (cssMinifier === types_1.CSSMinifier.parcelCSS) {
|
|
84
|
-
cssMinify = css_minimizer_webpack_plugin_1.default.parcelCssMinify;
|
|
85
|
-
}
|
|
86
|
-
else if (cssMinifier !== types_1.CSSMinifier.none) {
|
|
87
|
-
throw new Error(`Unsupported cssMinifier ${userConfig.cssMinifier}.`);
|
|
88
|
-
}
|
|
89
|
-
minimizerOptions = {
|
|
90
|
-
...minimizerOptions,
|
|
91
|
-
...userConfig.cssMinifierOptions,
|
|
66
|
+
} else if (jsMinifier === import_types.JSMinifier.terser) {
|
|
67
|
+
minify = import_terser_webpack_plugin.default.terserMinify;
|
|
68
|
+
terserOptions = {
|
|
69
|
+
format: {
|
|
70
|
+
comments: false
|
|
71
|
+
}
|
|
92
72
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
73
|
+
} else if (jsMinifier === import_types.JSMinifier.swc) {
|
|
74
|
+
minify = import_terser_webpack_plugin.default.swcMinify;
|
|
75
|
+
} else if (jsMinifier === import_types.JSMinifier.uglifyJs) {
|
|
76
|
+
minify = import_terser_webpack_plugin.default.uglifyJsMinify;
|
|
77
|
+
terserOptions = {
|
|
78
|
+
output: {
|
|
79
|
+
comments: false
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
} else if (jsMinifier !== import_types.JSMinifier.none) {
|
|
83
|
+
throw new Error(`Unsupported jsMinifier ${userConfig.jsMinifier}.`);
|
|
84
|
+
}
|
|
85
|
+
terserOptions = __spreadValues(__spreadValues({}, terserOptions), userConfig.jsMinifierOptions);
|
|
86
|
+
if (jsMinifier !== import_types.JSMinifier.none) {
|
|
87
|
+
config.optimization.minimizer(`js-${jsMinifier}`).use(import_terser_webpack_plugin.default, [
|
|
88
|
+
{
|
|
89
|
+
extractComments: false,
|
|
90
|
+
minify,
|
|
91
|
+
terserOptions
|
|
92
|
+
}
|
|
100
93
|
]);
|
|
94
|
+
}
|
|
95
|
+
let cssMinify;
|
|
96
|
+
let minimizerOptions;
|
|
97
|
+
if (cssMinifier === import_types.CSSMinifier.esbuild) {
|
|
98
|
+
cssMinify = import_css_minimizer_webpack_plugin.default.esbuildMinify;
|
|
99
|
+
minimizerOptions = {
|
|
100
|
+
target: esbuildTarget
|
|
101
|
+
};
|
|
102
|
+
} else if (cssMinifier === import_types.CSSMinifier.cssnano) {
|
|
103
|
+
cssMinify = import_css_minimizer_webpack_plugin.default.cssnanoMinify;
|
|
104
|
+
} else if (cssMinifier === import_types.CSSMinifier.parcelCSS) {
|
|
105
|
+
cssMinify = import_css_minimizer_webpack_plugin.default.parcelCssMinify;
|
|
106
|
+
} else if (cssMinifier !== import_types.CSSMinifier.none) {
|
|
107
|
+
throw new Error(`Unsupported cssMinifier ${userConfig.cssMinifier}.`);
|
|
108
|
+
}
|
|
109
|
+
minimizerOptions = __spreadValues(__spreadValues({}, minimizerOptions), userConfig.cssMinifierOptions);
|
|
110
|
+
config.optimization.minimizer(`css-${cssMinifier}`).use(import_css_minimizer_webpack_plugin.default, [
|
|
111
|
+
{
|
|
112
|
+
minify: cssMinify,
|
|
113
|
+
minimizerOptions
|
|
114
|
+
}
|
|
115
|
+
]);
|
|
101
116
|
}
|
|
102
|
-
|
|
117
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
118
|
+
0 && (module.exports = {
|
|
119
|
+
addCompressPlugin
|
|
120
|
+
});
|
package/dist/config/config.d.ts
CHANGED
package/dist/config/config.js
CHANGED
|
@@ -1,226 +1,212 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __export = (target, all) => {
|
|
22
|
+
for (var name in all)
|
|
23
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
24
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
|
|
36
|
+
// config.ts
|
|
37
|
+
var config_exports = {};
|
|
38
|
+
__export(config_exports, {
|
|
39
|
+
getConfig: () => getConfig
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(config_exports);
|
|
42
|
+
var import_case_sensitive_paths_webpack_plugin = __toESM(require("@umijs/case-sensitive-paths-webpack-plugin"));
|
|
43
|
+
var import_utils = require("@umijs/utils");
|
|
44
|
+
var import_path = require("path");
|
|
45
|
+
var import_webpack = __toESM(require("../../compiled/webpack"));
|
|
46
|
+
var import_webpack_5_chain = __toESM(require("../../compiled/webpack-5-chain"));
|
|
47
|
+
var import_constants = require("../constants");
|
|
48
|
+
var import_RuntimePublicPathPlugin = require("../plugins/RuntimePublicPathPlugin");
|
|
49
|
+
var import_types = require("../types");
|
|
50
|
+
var import_browsersList = require("../utils/browsersList");
|
|
51
|
+
var import_assetRules = require("./assetRules");
|
|
52
|
+
var import_bundleAnalyzerPlugin = require("./bundleAnalyzerPlugin");
|
|
53
|
+
var import_compressPlugin = require("./compressPlugin");
|
|
54
|
+
var import_copyPlugin = require("./copyPlugin");
|
|
55
|
+
var import_cssRules = require("./cssRules");
|
|
56
|
+
var import_definePlugin = require("./definePlugin");
|
|
57
|
+
var import_detectDeadCodePlugin = require("./detectDeadCodePlugin");
|
|
58
|
+
var import_fastRefreshPlugin = require("./fastRefreshPlugin");
|
|
59
|
+
var import_forkTSCheckerPlugin = require("./forkTSCheckerPlugin");
|
|
60
|
+
var import_harmonyLinkingErrorPlugin = require("./harmonyLinkingErrorPlugin");
|
|
61
|
+
var import_ignorePlugin = require("./ignorePlugin");
|
|
62
|
+
var import_javaScriptRules = require("./javaScriptRules");
|
|
63
|
+
var import_manifestPlugin = require("./manifestPlugin");
|
|
64
|
+
var import_miniCSSExtractPlugin = require("./miniCSSExtractPlugin");
|
|
65
|
+
var import_nodePolyfill = require("./nodePolyfill");
|
|
66
|
+
var import_progressPlugin = require("./progressPlugin");
|
|
67
|
+
var import_speedMeasureWebpackPlugin = require("./speedMeasureWebpackPlugin");
|
|
68
|
+
var import_ssrPlugin = __toESM(require("./ssrPlugin"));
|
|
69
|
+
var import_svgRules = require("./svgRules");
|
|
34
70
|
async function getConfig(opts) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const entry = config.entry(key);
|
|
63
|
-
if (isDev && opts.hmr) {
|
|
64
|
-
entry.add(require.resolve('../../client/client/client'));
|
|
65
|
-
}
|
|
66
|
-
entry.add(opts.entry[key]);
|
|
67
|
-
});
|
|
68
|
-
// devtool
|
|
69
|
-
config.devtool(isDev
|
|
70
|
-
? userConfig.devtool === false
|
|
71
|
-
? false
|
|
72
|
-
: userConfig.devtool || constants_1.DEFAULT_DEVTOOL
|
|
73
|
-
: userConfig.devtool);
|
|
74
|
-
// output
|
|
75
|
-
const absOutputPath = (0, path_1.resolve)(opts.cwd, userConfig.outputPath || constants_1.DEFAULT_OUTPUT_PATH);
|
|
76
|
-
const disableCompress = process.env.COMPRESS === 'none';
|
|
77
|
-
config.output
|
|
78
|
-
.path(absOutputPath)
|
|
79
|
-
.filename(useHash ? `[name].[contenthash:8].js` : `[name].js`)
|
|
80
|
-
.chunkFilename(useHash ? `[name].[contenthash:8].async.js` : `[name].async.js`)
|
|
81
|
-
.publicPath(userConfig.publicPath || 'auto')
|
|
82
|
-
.pathinfo(isDev || disableCompress)
|
|
83
|
-
.set('assetModuleFilename', `${applyOpts.staticPathPrefix}[name].[hash:8][ext]`);
|
|
84
|
-
// resolve
|
|
85
|
-
// prettier-ignore
|
|
86
|
-
config.resolve
|
|
87
|
-
.set('symlinks', true)
|
|
88
|
-
.modules
|
|
89
|
-
.add('node_modules')
|
|
90
|
-
.end()
|
|
91
|
-
.alias
|
|
92
|
-
.merge(userConfig.alias || {})
|
|
93
|
-
.end()
|
|
94
|
-
.extensions
|
|
95
|
-
.merge([
|
|
96
|
-
'.wasm',
|
|
97
|
-
'.mjs',
|
|
98
|
-
'.js',
|
|
99
|
-
'.jsx',
|
|
100
|
-
'.ts',
|
|
101
|
-
'.tsx',
|
|
102
|
-
'.json'
|
|
103
|
-
])
|
|
104
|
-
.end();
|
|
105
|
-
// externals
|
|
106
|
-
config.externals(userConfig.externals || []);
|
|
107
|
-
// target
|
|
108
|
-
config.target(['web', 'es5']);
|
|
109
|
-
// experiments
|
|
110
|
-
config.experiments({
|
|
111
|
-
topLevelAwait: true,
|
|
112
|
-
outputModule: !!userConfig.esm,
|
|
113
|
-
});
|
|
114
|
-
// node polyfill
|
|
115
|
-
await (0, nodePolyfill_1.addNodePolyfill)(applyOpts);
|
|
116
|
-
// rules
|
|
117
|
-
await (0, javaScriptRules_1.addJavaScriptRules)(applyOpts);
|
|
118
|
-
await (0, cssRules_1.addCSSRules)(applyOpts);
|
|
119
|
-
await (0, assetRules_1.addAssetRules)(applyOpts);
|
|
120
|
-
await (0, svgRules_1.addSVGRules)(applyOpts);
|
|
121
|
-
// plugins
|
|
122
|
-
// mini-css-extract-plugin
|
|
123
|
-
await (0, miniCSSExtractPlugin_1.addMiniCSSExtractPlugin)(applyOpts);
|
|
124
|
-
// ignoreMomentLocale
|
|
125
|
-
await (0, ignorePlugin_1.addIgnorePlugin)(applyOpts);
|
|
126
|
-
// define
|
|
127
|
-
await (0, definePlugin_1.addDefinePlugin)(applyOpts);
|
|
128
|
-
// fast refresh
|
|
129
|
-
await (0, fastRefreshPlugin_1.addFastRefreshPlugin)(applyOpts);
|
|
130
|
-
// progress
|
|
131
|
-
await (0, progressPlugin_1.addProgressPlugin)(applyOpts);
|
|
132
|
-
// detect-dead-code-plugin
|
|
133
|
-
await (0, detectDeadCodePlugin_1.addDetectDeadCodePlugin)(applyOpts);
|
|
134
|
-
// fork-ts-checker
|
|
135
|
-
await (0, forkTSCheckerPlugin_1.addForkTSCheckerPlugin)(applyOpts);
|
|
136
|
-
// copy
|
|
137
|
-
await (0, copyPlugin_1.addCopyPlugin)(applyOpts);
|
|
138
|
-
// manifest
|
|
139
|
-
await (0, manifestPlugin_1.addManifestPlugin)(applyOpts);
|
|
140
|
-
// hmr
|
|
71
|
+
var _a, _b, _c;
|
|
72
|
+
const { userConfig } = opts;
|
|
73
|
+
const isDev = opts.env === import_types.Env.development;
|
|
74
|
+
const config = new import_webpack_5_chain.default();
|
|
75
|
+
userConfig.targets || (userConfig.targets = import_constants.DEFAULT_BROWSER_TARGETS);
|
|
76
|
+
const useHash = !!(opts.hash || userConfig.hash && !isDev);
|
|
77
|
+
const applyOpts = {
|
|
78
|
+
name: opts.name,
|
|
79
|
+
config,
|
|
80
|
+
userConfig,
|
|
81
|
+
cwd: opts.cwd,
|
|
82
|
+
env: opts.env,
|
|
83
|
+
babelPreset: opts.babelPreset,
|
|
84
|
+
extraBabelPlugins: opts.extraBabelPlugins || [],
|
|
85
|
+
extraBabelPresets: opts.extraBabelPresets || [],
|
|
86
|
+
extraBabelIncludes: opts.extraBabelIncludes || [],
|
|
87
|
+
extraEsbuildLoaderHandler: opts.extraEsbuildLoaderHandler || [],
|
|
88
|
+
browsers: (0, import_browsersList.getBrowsersList)({
|
|
89
|
+
targets: userConfig.targets
|
|
90
|
+
}),
|
|
91
|
+
useHash,
|
|
92
|
+
staticPathPrefix: opts.staticPathPrefix !== void 0 ? opts.staticPathPrefix : "static/"
|
|
93
|
+
};
|
|
94
|
+
config.mode(opts.env);
|
|
95
|
+
config.stats("none");
|
|
96
|
+
Object.keys(opts.entry).forEach((key) => {
|
|
97
|
+
const entry = config.entry(key);
|
|
141
98
|
if (isDev && opts.hmr) {
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
// ssr
|
|
145
|
-
await (0, ssrPlugin_1.default)(applyOpts);
|
|
146
|
-
// compress
|
|
147
|
-
await (0, compressPlugin_1.addCompressPlugin)(applyOpts);
|
|
148
|
-
// purgecss
|
|
149
|
-
// await applyPurgeCSSWebpackPlugin(applyOpts);
|
|
150
|
-
// handle HarmonyLinkingError
|
|
151
|
-
await (0, harmonyLinkingErrorPlugin_1.addHarmonyLinkingErrorPlugin)(applyOpts);
|
|
152
|
-
// remove node: prefix
|
|
153
|
-
// disable for performance
|
|
154
|
-
// await addNodePrefixPlugin(applyOpts);
|
|
155
|
-
// runtimePublicPath
|
|
156
|
-
if (userConfig.runtimePublicPath) {
|
|
157
|
-
config.plugin('runtimePublicPath').use(RuntimePublicPathPlugin_1.RuntimePublicPathPlugin);
|
|
99
|
+
entry.add(require.resolve("../../client/client/client"));
|
|
158
100
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
101
|
+
entry.add(opts.entry[key]);
|
|
102
|
+
});
|
|
103
|
+
config.devtool(isDev ? userConfig.devtool === false ? false : userConfig.devtool || import_constants.DEFAULT_DEVTOOL : userConfig.devtool);
|
|
104
|
+
const absOutputPath = (0, import_path.resolve)(opts.cwd, userConfig.outputPath || import_constants.DEFAULT_OUTPUT_PATH);
|
|
105
|
+
const disableCompress = process.env.COMPRESS === "none";
|
|
106
|
+
config.output.path(absOutputPath).filename(useHash ? `[name].[contenthash:8].js` : `[name].js`).chunkFilename(useHash ? `[name].[contenthash:8].async.js` : `[name].async.js`).publicPath(userConfig.publicPath || "auto").pathinfo(isDev || disableCompress).set("assetModuleFilename", `${applyOpts.staticPathPrefix}[name].[hash:8][ext]`);
|
|
107
|
+
config.resolve.set("symlinks", true).modules.add("node_modules").end().alias.merge(userConfig.alias || {}).end().extensions.merge([
|
|
108
|
+
".wasm",
|
|
109
|
+
".mjs",
|
|
110
|
+
".js",
|
|
111
|
+
".jsx",
|
|
112
|
+
".ts",
|
|
113
|
+
".tsx",
|
|
114
|
+
".json"
|
|
115
|
+
]).end();
|
|
116
|
+
config.externals(userConfig.externals || []);
|
|
117
|
+
config.target(["web", "es5"]);
|
|
118
|
+
config.experiments({
|
|
119
|
+
topLevelAwait: true,
|
|
120
|
+
outputModule: !!userConfig.esm
|
|
121
|
+
});
|
|
122
|
+
await (0, import_nodePolyfill.addNodePolyfill)(applyOpts);
|
|
123
|
+
await (0, import_javaScriptRules.addJavaScriptRules)(applyOpts);
|
|
124
|
+
await (0, import_cssRules.addCSSRules)(applyOpts);
|
|
125
|
+
await (0, import_assetRules.addAssetRules)(applyOpts);
|
|
126
|
+
await (0, import_svgRules.addSVGRules)(applyOpts);
|
|
127
|
+
await (0, import_miniCSSExtractPlugin.addMiniCSSExtractPlugin)(applyOpts);
|
|
128
|
+
await (0, import_ignorePlugin.addIgnorePlugin)(applyOpts);
|
|
129
|
+
await (0, import_definePlugin.addDefinePlugin)(applyOpts);
|
|
130
|
+
await (0, import_fastRefreshPlugin.addFastRefreshPlugin)(applyOpts);
|
|
131
|
+
await (0, import_progressPlugin.addProgressPlugin)(applyOpts);
|
|
132
|
+
await (0, import_detectDeadCodePlugin.addDetectDeadCodePlugin)(applyOpts);
|
|
133
|
+
await (0, import_forkTSCheckerPlugin.addForkTSCheckerPlugin)(applyOpts);
|
|
134
|
+
await (0, import_copyPlugin.addCopyPlugin)(applyOpts);
|
|
135
|
+
await (0, import_manifestPlugin.addManifestPlugin)(applyOpts);
|
|
136
|
+
if (isDev && opts.hmr) {
|
|
137
|
+
config.plugin("hmr").use(import_webpack.default.HotModuleReplacementPlugin);
|
|
138
|
+
}
|
|
139
|
+
await (0, import_ssrPlugin.default)(applyOpts);
|
|
140
|
+
await (0, import_compressPlugin.addCompressPlugin)(applyOpts);
|
|
141
|
+
await (0, import_harmonyLinkingErrorPlugin.addHarmonyLinkingErrorPlugin)(applyOpts);
|
|
142
|
+
if (userConfig.runtimePublicPath) {
|
|
143
|
+
config.plugin("runtimePublicPath").use(import_RuntimePublicPathPlugin.RuntimePublicPathPlugin);
|
|
144
|
+
}
|
|
145
|
+
config.plugin("case-sensitive-paths").use(import_case_sensitive_paths_webpack_plugin.default);
|
|
146
|
+
if (opts.cache) {
|
|
147
|
+
config.cache({
|
|
148
|
+
type: "filesystem",
|
|
149
|
+
version: require("../../package.json").version,
|
|
150
|
+
buildDependencies: {
|
|
151
|
+
config: opts.cache.buildDependencies || []
|
|
152
|
+
},
|
|
153
|
+
cacheDirectory: opts.cache.cacheDirectory || (0, import_path.join)(opts.rootDir || opts.cwd, "node_modules", ".cache", "bundler-webpack")
|
|
154
|
+
});
|
|
155
|
+
if (require("@umijs/utils/package").__npminstall_done) {
|
|
156
|
+
const nodeModulesPath = opts.cache.absNodeModulesPath || (0, import_path.join)(opts.rootDir || opts.cwd, "node_modules");
|
|
157
|
+
const localLinkedNodeModules = Object.keys(Object.assign({}, (_a = opts.pkg) == null ? void 0 : _a.dependencies, (_b = opts.pkg) == null ? void 0 : _b.peerDependencies, (_c = opts.pkg) == null ? void 0 : _c.devDependencies)).map((pkg) => {
|
|
158
|
+
try {
|
|
159
|
+
return (0, import_path.resolve)(import_utils.resolve.sync(`${pkg}/package.json`, {
|
|
160
|
+
basedir: opts.rootDir || opts.cwd,
|
|
161
|
+
preserveSymlinks: false
|
|
162
|
+
}), "../node_modules");
|
|
163
|
+
} catch {
|
|
164
|
+
return opts.rootDir || opts.cwd;
|
|
185
165
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
// analyzer
|
|
196
|
-
if (opts.analyze) {
|
|
197
|
-
await (0, bundleAnalyzerPlugin_1.addBundleAnalyzerPlugin)(applyOpts);
|
|
198
|
-
}
|
|
199
|
-
// chain webpack
|
|
200
|
-
if (opts.chainWebpack) {
|
|
201
|
-
await opts.chainWebpack(config, {
|
|
202
|
-
env: opts.env,
|
|
203
|
-
webpack: webpack_1.default,
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
if (userConfig.chainWebpack) {
|
|
207
|
-
await userConfig.chainWebpack(config, {
|
|
208
|
-
env: opts.env,
|
|
209
|
-
webpack: webpack_1.default,
|
|
210
|
-
});
|
|
166
|
+
}).filter((pkg) => !pkg.startsWith(opts.rootDir || opts.cwd));
|
|
167
|
+
if (localLinkedNodeModules.length) {
|
|
168
|
+
import_utils.logger.info(`Detected local linked tnpm node_modules, to avoid oom, they will be treated as immutablePaths & managedPaths in webpack snapshot:`);
|
|
169
|
+
localLinkedNodeModules.forEach((p) => import_utils.logger.info(` ${p}`));
|
|
170
|
+
}
|
|
171
|
+
config.snapshot({
|
|
172
|
+
immutablePaths: [nodeModulesPath, ...localLinkedNodeModules],
|
|
173
|
+
managedPaths: [nodeModulesPath, ...localLinkedNodeModules]
|
|
174
|
+
});
|
|
211
175
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
176
|
+
config.infrastructureLogging(__spreadValues({
|
|
177
|
+
level: "error"
|
|
178
|
+
}, process.env.WEBPACK_FS_CACHE_DEBUG ? {
|
|
179
|
+
debug: /webpack\.cache/
|
|
180
|
+
} : {}));
|
|
181
|
+
}
|
|
182
|
+
if (opts.analyze) {
|
|
183
|
+
await (0, import_bundleAnalyzerPlugin.addBundleAnalyzerPlugin)(applyOpts);
|
|
184
|
+
}
|
|
185
|
+
if (opts.chainWebpack) {
|
|
186
|
+
await opts.chainWebpack(config, {
|
|
187
|
+
env: opts.env,
|
|
188
|
+
webpack: import_webpack.default
|
|
217
189
|
});
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
190
|
+
}
|
|
191
|
+
if (userConfig.chainWebpack) {
|
|
192
|
+
await userConfig.chainWebpack(config, {
|
|
193
|
+
env: opts.env,
|
|
194
|
+
webpack: import_webpack.default
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
let webpackConfig = config.toConfig();
|
|
198
|
+
webpackConfig = await (0, import_speedMeasureWebpackPlugin.addSpeedMeasureWebpackPlugin)({
|
|
199
|
+
webpackConfig
|
|
200
|
+
});
|
|
201
|
+
if (opts.modifyWebpackConfig) {
|
|
202
|
+
webpackConfig = await opts.modifyWebpackConfig(webpackConfig, {
|
|
203
|
+
env: opts.env,
|
|
204
|
+
webpack: import_webpack.default
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return webpackConfig;
|
|
225
208
|
}
|
|
226
|
-
|
|
209
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
210
|
+
0 && (module.exports = {
|
|
211
|
+
getConfig
|
|
212
|
+
});
|