@umijs/bundler-webpack 4.0.7 → 4.0.10
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/{dist → client}/client/client.d.ts +0 -0
- package/client/client/client.js +295 -194
- 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 -1
- package/dist/build.js +105 -68
- package/dist/cli.js +77 -69
- package/dist/config/_sampleFeature.js +33 -9
- package/dist/config/assetRules.js +45 -36
- package/dist/config/bundleAnalyzerPlugin.js +39 -17
- package/dist/config/compressPlugin.js +114 -95
- package/dist/config/config.d.ts +1 -0
- package/dist/config/config.js +204 -215
- package/dist/config/copyPlugin.js +59 -40
- package/dist/config/cssRules.js +136 -131
- package/dist/config/definePlugin.js +71 -35
- package/dist/config/detectDeadCode.js +120 -108
- package/dist/config/detectDeadCodePlugin.js +78 -63
- package/dist/config/fastRefreshPlugin.js +39 -20
- package/dist/config/forkTSCheckerPlugin.js +38 -19
- package/dist/config/harmonyLinkingErrorPlugin.js +48 -29
- package/dist/config/ignorePlugin.js +38 -14
- package/dist/config/javaScriptRules.js +147 -173
- package/dist/config/manifestPlugin.js +51 -15
- package/dist/config/miniCSSExtractPlugin.js +42 -22
- package/dist/config/nodePolyfill.js +65 -26
- package/dist/config/nodePrefixPlugin.js +36 -12
- package/dist/config/progressPlugin.js +37 -13
- package/dist/config/purgecssWebpackPlugin.js +41 -19
- package/dist/config/speedMeasureWebpackPlugin.js +41 -20
- package/dist/config/ssrPlugin.js +83 -63
- package/dist/config/svgRules.js +74 -46
- package/dist/constants.js +57 -22
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +174 -134
- package/dist/index.js +22 -20
- package/dist/loader/svgr.js +73 -54
- package/dist/loader/swc.js +110 -69
- package/dist/parcelCSS.js +31 -27
- package/dist/plugins/ProgressPlugin.js +66 -43
- package/dist/plugins/RuntimePublicPathPlugin.js +42 -23
- package/dist/plugins/_SamplePlugin.js +39 -14
- package/dist/requireHook.js +37 -27
- package/dist/schema.js +123 -96
- package/dist/server/server.d.ts +0 -1
- package/dist/server/server.js +214 -184
- package/dist/server/ws.d.ts +0 -2
- package/dist/server/ws.js +63 -38
- package/dist/swcPlugins/autoCSSModules.js +50 -31
- package/dist/swcPlugins/changeImportFromString.js +31 -9
- package/dist/swcPlugins/lockCoreJS.js +44 -20
- package/dist/types.d.ts +2 -1
- package/dist/types.js +61 -30
- package/dist/utils/browsersList.js +31 -8
- package/dist/utils/depMatch.js +63 -39
- package/dist/utils/formatWebpackMessages.js +93 -91
- package/dist/utils/getEsBuildTarget.d.ts +3 -1
- package/dist/utils/getEsBuildTarget.js +39 -11
- package/package.json +12 -16
- package/compiled/fork-ts-checker-webpack-plugin/LICENSE +0 -21
- package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
- package/compiled/fork-ts-checker-webpack-plugin/index.js +0 -42
- package/compiled/fork-ts-checker-webpack-plugin/package.json +0 -1
- 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/client/client.js +0 -245
|
@@ -1,19 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/config/bundleAnalyzerPlugin.ts
|
|
20
|
+
var bundleAnalyzerPlugin_exports = {};
|
|
21
|
+
__export(bundleAnalyzerPlugin_exports, {
|
|
22
|
+
addBundleAnalyzerPlugin: () => addBundleAnalyzerPlugin
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(bundleAnalyzerPlugin_exports);
|
|
25
|
+
var import_webpack_bundle_analyzer = require("@umijs/bundler-webpack/compiled/webpack-bundle-analyzer");
|
|
6
26
|
async function addBundleAnalyzerPlugin(opts) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
]);
|
|
27
|
+
const { config } = opts;
|
|
28
|
+
config.plugin("webpack-bundle-analyzer").use(import_webpack_bundle_analyzer.BundleAnalyzerPlugin, [
|
|
29
|
+
{
|
|
30
|
+
analyzerMode: "server",
|
|
31
|
+
analyzerPort: process.env.ANALYZE_PORT || 8888,
|
|
32
|
+
openAnalyzer: false,
|
|
33
|
+
logLevel: "info",
|
|
34
|
+
defaultSizes: "parsed"
|
|
35
|
+
}
|
|
36
|
+
]);
|
|
18
37
|
}
|
|
19
|
-
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
addBundleAnalyzerPlugin
|
|
41
|
+
});
|
|
@@ -1,102 +1,121 @@
|
|
|
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
|
+
// src/config/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
|
-
|
|
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
|
+
jsMinifier
|
|
58
|
+
});
|
|
59
|
+
let minify;
|
|
60
|
+
let terserOptions;
|
|
61
|
+
if (jsMinifier === import_types.JSMinifier.esbuild) {
|
|
62
|
+
minify = import_terser_webpack_plugin.default.esbuildMinify;
|
|
59
63
|
terserOptions = {
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
target: esbuildTarget,
|
|
65
|
+
legalComments: "none"
|
|
62
66
|
};
|
|
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,
|
|
67
|
+
} else if (jsMinifier === import_types.JSMinifier.terser) {
|
|
68
|
+
minify = import_terser_webpack_plugin.default.terserMinify;
|
|
69
|
+
terserOptions = {
|
|
70
|
+
format: {
|
|
71
|
+
comments: false
|
|
72
|
+
}
|
|
92
73
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
74
|
+
} else if (jsMinifier === import_types.JSMinifier.swc) {
|
|
75
|
+
minify = import_terser_webpack_plugin.default.swcMinify;
|
|
76
|
+
} else if (jsMinifier === import_types.JSMinifier.uglifyJs) {
|
|
77
|
+
minify = import_terser_webpack_plugin.default.uglifyJsMinify;
|
|
78
|
+
terserOptions = {
|
|
79
|
+
output: {
|
|
80
|
+
comments: false
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
} else if (jsMinifier !== import_types.JSMinifier.none) {
|
|
84
|
+
throw new Error(`Unsupported jsMinifier ${userConfig.jsMinifier}.`);
|
|
85
|
+
}
|
|
86
|
+
terserOptions = __spreadValues(__spreadValues({}, terserOptions), userConfig.jsMinifierOptions);
|
|
87
|
+
if (jsMinifier !== import_types.JSMinifier.none) {
|
|
88
|
+
config.optimization.minimizer(`js-${jsMinifier}`).use(import_terser_webpack_plugin.default, [
|
|
89
|
+
{
|
|
90
|
+
extractComments: false,
|
|
91
|
+
minify,
|
|
92
|
+
terserOptions
|
|
93
|
+
}
|
|
100
94
|
]);
|
|
95
|
+
}
|
|
96
|
+
let cssMinify;
|
|
97
|
+
let minimizerOptions;
|
|
98
|
+
if (cssMinifier === import_types.CSSMinifier.esbuild) {
|
|
99
|
+
cssMinify = import_css_minimizer_webpack_plugin.default.esbuildMinify;
|
|
100
|
+
minimizerOptions = {
|
|
101
|
+
target: esbuildTarget
|
|
102
|
+
};
|
|
103
|
+
} else if (cssMinifier === import_types.CSSMinifier.cssnano) {
|
|
104
|
+
cssMinify = import_css_minimizer_webpack_plugin.default.cssnanoMinify;
|
|
105
|
+
} else if (cssMinifier === import_types.CSSMinifier.parcelCSS) {
|
|
106
|
+
cssMinify = import_css_minimizer_webpack_plugin.default.parcelCssMinify;
|
|
107
|
+
} else if (cssMinifier !== import_types.CSSMinifier.none) {
|
|
108
|
+
throw new Error(`Unsupported cssMinifier ${userConfig.cssMinifier}.`);
|
|
109
|
+
}
|
|
110
|
+
minimizerOptions = __spreadValues(__spreadValues({}, minimizerOptions), userConfig.cssMinifierOptions);
|
|
111
|
+
config.optimization.minimizer(`css-${cssMinifier}`).use(import_css_minimizer_webpack_plugin.default, [
|
|
112
|
+
{
|
|
113
|
+
minify: cssMinify,
|
|
114
|
+
minimizerOptions
|
|
115
|
+
}
|
|
116
|
+
]);
|
|
101
117
|
}
|
|
102
|
-
|
|
118
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
+
0 && (module.exports = {
|
|
120
|
+
addCompressPlugin
|
|
121
|
+
});
|