@umijs/bundler-webpack 4.0.41 → 4.0.43
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/utils/formatWebpackMessages.js +27 -8
- package/compiled/autoprefixer/browserslist/index.d.ts +21 -1
- package/compiled/autoprefixer/index.js +2 -2
- package/compiled/autoprefixer/package.json +1 -1
- package/compiled/autoprefixer/postcss/lib/processor.d.ts +1 -1
- package/compiled/babel-loader/index.js +8 -2
- package/compiled/babel-loader/package.json +1 -1
- 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 +22 -60
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +2 -10
- package/compiled/mini-css-extract-plugin/index.js +492 -696
- package/compiled/mini-css-extract-plugin/loader.js +54 -120
- package/compiled/mini-css-extract-plugin/package.json +1 -1
- package/compiled/mini-css-extract-plugin/utils.js +27 -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/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 +1211 -3390
- package/compiled/terser-webpack-plugin/package.json +1 -1
- package/compiled/terser-webpack-plugin/types/index.d.ts +10 -10
- package/compiled/terser-webpack-plugin/types/utils.d.ts +10 -9
- package/compiled/terser-webpack-plugin/utils.js +36 -10
- package/compiled/webpack/package.json +1 -1
- package/compiled/webpack/types.d.ts +137 -126
- 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 +5 -5
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/webpackbar/LICENSE +20 -0
- 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 +73 -33
- package/compiled/ws/index.js +1 -1
- package/compiled/ws/package.json +1 -1
- package/dist/build.js +8 -2
- package/dist/cli.js +4 -1
- package/dist/config/compressPlugin.js +4 -1
- package/dist/config/config.js +41 -11
- package/dist/config/cssRules.js +17 -5
- package/dist/config/detectDeadCode.js +38 -8
- package/dist/config/detectDeadCodePlugin.js +8 -2
- package/dist/config/fastRefreshPlugin.js +4 -1
- package/dist/config/forkTSCheckerPlugin.js +4 -1
- package/dist/config/harmonyLinkingErrorPlugin.js +14 -11
- package/dist/config/javaScriptRules.js +21 -9
- package/dist/config/miniCSSExtractPlugin.js +4 -1
- package/dist/config/progressPlugin.js +16 -7
- package/dist/config/speedMeasureWebpackPlugin.js +7 -2
- package/dist/config/ssrPlugin.js +20 -6
- package/dist/config/svgRules.js +4 -1
- package/dist/dev.js +29 -13
- package/dist/loader/svgr.js +16 -11
- package/dist/loader/swc.d.ts +2 -2
- package/dist/loader/swc.js +66 -10
- package/dist/parcelCSS.js +4 -1
- package/dist/plugins/ProgressPlugin.js +6 -2
- package/dist/plugins/RuntimePublicPathPlugin.js +9 -6
- package/dist/plugins/_SamplePlugin.d.ts +1 -1
- package/dist/plugins/_SamplePlugin.js +1 -1
- package/dist/requireHook.js +4 -1
- package/dist/schema.js +62 -23
- package/dist/server/server.d.ts +1 -4
- package/dist/server/server.js +37 -23
- package/dist/server/ws.js +8 -3
- package/dist/swcPlugins/autoCSSModules.d.ts +5 -1
- package/dist/swcPlugins/autoCSSModules.js +4 -1
- package/dist/swcPlugins/lockCoreJS.js +8 -2
- package/dist/types.d.ts +15 -3
- package/dist/utils/formatWebpackMessages.js +31 -9
- package/dist/utils/getEsBuildTarget.js +7 -1
- package/package.json +30 -26
package/dist/config/cssRules.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/config/cssRules.ts
|
|
@@ -64,9 +67,13 @@ async function addCSSRules(opts) {
|
|
|
64
67
|
].filter(Boolean);
|
|
65
68
|
for (const { rule: rule2, isCSSModules } of nestRulesConfig) {
|
|
66
69
|
if (userConfig.styleLoader) {
|
|
67
|
-
rule2.use("style-loader").loader(
|
|
70
|
+
rule2.use("style-loader").loader(
|
|
71
|
+
require.resolve("@umijs/bundler-webpack/compiled/style-loader")
|
|
72
|
+
).options({ base: 0, esModule: true, ...userConfig.styleLoader });
|
|
68
73
|
} else {
|
|
69
|
-
rule2.use("mini-css-extract-plugin").loader(
|
|
74
|
+
rule2.use("mini-css-extract-plugin").loader(
|
|
75
|
+
require.resolve("@umijs/bundler-webpack/compiled/mini-css-extract-plugin/loader")
|
|
76
|
+
).options({
|
|
70
77
|
publicPath: "./",
|
|
71
78
|
emit: true,
|
|
72
79
|
esModule: true
|
|
@@ -88,7 +95,10 @@ async function addCSSRules(opts) {
|
|
|
88
95
|
localIdentName: "[local]___[hash:base64:5]",
|
|
89
96
|
...userConfig.cssLoaderModules,
|
|
90
97
|
getLocalIdent: userConfig.ssr && ((context, localIdentName, localName, opt) => {
|
|
91
|
-
const classIdent = ((0, import_utils.winPath)(context.resourcePath).replace(
|
|
98
|
+
const classIdent = ((0, import_utils.winPath)(context.resourcePath).replace(
|
|
99
|
+
(0, import_utils.winPath)(ensureLastSlash(opt.context)),
|
|
100
|
+
""
|
|
101
|
+
) + "@" + localName).trim();
|
|
92
102
|
let hash = Buffer.from(classIdent).toString("base64").replace(/=/g, "");
|
|
93
103
|
hash = hash.substring(hash.length - 5);
|
|
94
104
|
const result = localIdentName.replace(/\[local]/g, localName).replace(/\[hash[^\[]*?]/g, hash);
|
|
@@ -98,7 +108,9 @@ async function addCSSRules(opts) {
|
|
|
98
108
|
} : {},
|
|
99
109
|
...userConfig.cssLoader
|
|
100
110
|
});
|
|
101
|
-
rule2.use("postcss-loader").loader(
|
|
111
|
+
rule2.use("postcss-loader").loader(
|
|
112
|
+
require.resolve("@umijs/bundler-webpack/compiled/postcss-loader")
|
|
113
|
+
).options({
|
|
102
114
|
postcssOptions: {
|
|
103
115
|
ident: "postcss",
|
|
104
116
|
plugins: [
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/config/detectDeadCode.ts
|
|
@@ -67,7 +70,13 @@ var getUnusedExportMap = (includedFileMap, compilation) => {
|
|
|
67
70
|
const unusedExportMap = {};
|
|
68
71
|
compilation.chunks.forEach((chunk) => {
|
|
69
72
|
compilation.chunkGraph.getChunkModules(chunk).forEach((module2) => {
|
|
70
|
-
outputUnusedExportMap(
|
|
73
|
+
outputUnusedExportMap(
|
|
74
|
+
compilation,
|
|
75
|
+
chunk,
|
|
76
|
+
module2,
|
|
77
|
+
includedFileMap,
|
|
78
|
+
unusedExportMap
|
|
79
|
+
);
|
|
71
80
|
});
|
|
72
81
|
});
|
|
73
82
|
return unusedExportMap;
|
|
@@ -80,14 +89,19 @@ var outputUnusedExportMap = (compilation, chunk, module2, includedFileMap, unuse
|
|
|
80
89
|
if (!/^((?!(node_modules)).)*$/.test(path2))
|
|
81
90
|
return;
|
|
82
91
|
const providedExports = compilation.chunkGraph.moduleGraph.getProvidedExports(module2);
|
|
83
|
-
const usedExports = compilation.chunkGraph.moduleGraph.getUsedExports(
|
|
92
|
+
const usedExports = compilation.chunkGraph.moduleGraph.getUsedExports(
|
|
93
|
+
module2,
|
|
94
|
+
chunk.runtime
|
|
95
|
+
);
|
|
84
96
|
if (usedExports !== true && providedExports !== true && includedFileMap[path2]) {
|
|
85
97
|
if (usedExports === false) {
|
|
86
98
|
if (providedExports == null ? void 0 : providedExports.length) {
|
|
87
99
|
unusedExportMap[path2] = providedExports;
|
|
88
100
|
}
|
|
89
101
|
} else if (providedExports instanceof Array) {
|
|
90
|
-
const unusedExports = providedExports.filter(
|
|
102
|
+
const unusedExports = providedExports.filter(
|
|
103
|
+
(item) => usedExports && !usedExports.has(item)
|
|
104
|
+
);
|
|
91
105
|
if (unusedExports.length) {
|
|
92
106
|
unusedExportMap[path2] = unusedExports;
|
|
93
107
|
}
|
|
@@ -112,10 +126,19 @@ ${fileIndex + 1}. `,
|
|
|
112
126
|
].join("");
|
|
113
127
|
numberOfUnusedExport += unusedExports.length;
|
|
114
128
|
});
|
|
115
|
-
console.log(
|
|
129
|
+
console.log(
|
|
130
|
+
import_utils.chalk.yellow.bold("\nWarning:"),
|
|
131
|
+
import_utils.chalk.yellow(
|
|
132
|
+
`There are ${numberOfUnusedExport} unused exports in ${Object.keys(unusedExportMap).length} files:`
|
|
133
|
+
),
|
|
134
|
+
logStr,
|
|
135
|
+
import_utils.chalk.red.bold("\nPlease be careful if you want to remove them (¬º-°)¬.\n")
|
|
136
|
+
);
|
|
116
137
|
};
|
|
117
138
|
var getWebpackAssets = (compilation) => {
|
|
118
|
-
const outputPath = compilation.getPath(
|
|
139
|
+
const outputPath = compilation.getPath(
|
|
140
|
+
compilation.compiler.outputPath
|
|
141
|
+
);
|
|
119
142
|
const assets = [
|
|
120
143
|
...Array.from(compilation.fileDependencies),
|
|
121
144
|
...compilation.getAssets().map((asset) => import_path.default.join(outputPath, asset.name))
|
|
@@ -133,8 +156,15 @@ var logUnusedFiles = (unusedFiles) => {
|
|
|
133
156
|
if (!(unusedFiles == null ? void 0 : unusedFiles.length)) {
|
|
134
157
|
return;
|
|
135
158
|
}
|
|
136
|
-
console.log(
|
|
137
|
-
|
|
159
|
+
console.log(
|
|
160
|
+
import_utils.chalk.yellow.bold("\nWarning:"),
|
|
161
|
+
import_utils.chalk.yellow(`There are ${unusedFiles.length} unused files:`),
|
|
162
|
+
...unusedFiles.map(
|
|
163
|
+
(file, index) => `
|
|
164
|
+
${index + 1}. ${import_utils.chalk.yellow(file)}`
|
|
165
|
+
),
|
|
166
|
+
import_utils.chalk.red.bold("\nPlease be careful if you want to remove them (¬º-°)¬.\n")
|
|
167
|
+
);
|
|
138
168
|
};
|
|
139
169
|
function isDirExist(p) {
|
|
140
170
|
return import_utils.fsExtra.existsSync(p) && import_utils.fsExtra.statSync(p).isDirectory();
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/config/detectDeadCodePlugin.ts
|
|
@@ -56,7 +59,10 @@ var DetectDeadCodePlugin = class {
|
|
|
56
59
|
context: compiler.context
|
|
57
60
|
};
|
|
58
61
|
}
|
|
59
|
-
compiler.hooks.afterEmit.tapAsync(
|
|
62
|
+
compiler.hooks.afterEmit.tapAsync(
|
|
63
|
+
"DetectDeadCodePlugin",
|
|
64
|
+
this.handleAfterEmit
|
|
65
|
+
);
|
|
60
66
|
}
|
|
61
67
|
};
|
|
62
68
|
async function addDetectDeadCodePlugin(opts) {
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/config/fastRefreshPlugin.ts
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/config/forkTSCheckerPlugin.ts
|
|
@@ -26,18 +26,21 @@ var LINKING_ERROR_TAG = "was not found in";
|
|
|
26
26
|
var CSS_NO_EXPORTS = /\.(css|sass|scss|styl|less)' \(module has no exports\)/;
|
|
27
27
|
var HarmonyLinkingErrorPlugin = class {
|
|
28
28
|
apply(compiler) {
|
|
29
|
-
compiler.hooks.afterCompile.tap(
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
compiler.hooks.afterCompile.tap(
|
|
30
|
+
"HarmonyLinkingErrorPlugin",
|
|
31
|
+
(compilation) => {
|
|
32
|
+
if (!compilation.warnings.length) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const harmonyLinkingErrors = compilation.warnings.filter((w) => {
|
|
36
|
+
return w.name === "ModuleDependencyWarning" && !w.module.resource.includes("node_modules") && w.message.includes(LINKING_ERROR_TAG) && !CSS_NO_EXPORTS.test(w.message);
|
|
37
|
+
});
|
|
38
|
+
if (!harmonyLinkingErrors.length) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
compilation.errors.push(...harmonyLinkingErrors);
|
|
32
42
|
}
|
|
33
|
-
|
|
34
|
-
return w.name === "ModuleDependencyWarning" && !w.module.resource.includes("node_modules") && w.message.includes(LINKING_ERROR_TAG) && !CSS_NO_EXPORTS.test(w.message);
|
|
35
|
-
});
|
|
36
|
-
if (!harmonyLinkingErrors.length) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
compilation.errors.push(...harmonyLinkingErrors);
|
|
40
|
-
});
|
|
43
|
+
);
|
|
41
44
|
}
|
|
42
45
|
};
|
|
43
46
|
async function addHarmonyLinkingErrorPlugin(opts) {
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/config/javaScriptRules.ts
|
|
@@ -56,13 +59,17 @@ async function addJavaScriptRules(opts) {
|
|
|
56
59
|
if (p.startsWith("./")) {
|
|
57
60
|
return require.resolve(p, { paths: [cwd] });
|
|
58
61
|
}
|
|
59
|
-
return (0, import_path.dirname)(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
return (0, import_path.dirname)(
|
|
63
|
+
import_utils.resolve.sync(`${p}/package.json`, {
|
|
64
|
+
basedir: cwd,
|
|
65
|
+
preserveSymlinks: false
|
|
66
|
+
})
|
|
67
|
+
);
|
|
63
68
|
} catch (e) {
|
|
64
69
|
if (e.code === "MODULE_NOT_FOUND") {
|
|
65
|
-
throw new Error("Cannot resolve extraBabelIncludes: " + p
|
|
70
|
+
throw new Error("Cannot resolve extraBabelIncludes: " + p, {
|
|
71
|
+
cause: e
|
|
72
|
+
});
|
|
66
73
|
}
|
|
67
74
|
throw e;
|
|
68
75
|
}
|
|
@@ -95,6 +102,7 @@ async function addJavaScriptRules(opts) {
|
|
|
95
102
|
srcRules.concat(depRules).forEach((rule) => rule.resolve.set("fullySpecified", false));
|
|
96
103
|
const srcTranspiler = userConfig.srcTranspiler || import_types.Transpiler.babel;
|
|
97
104
|
srcRules.forEach((rule) => {
|
|
105
|
+
var _a2, _b2;
|
|
98
106
|
if (srcTranspiler === import_types.Transpiler.babel) {
|
|
99
107
|
rule.use("babel-loader").loader(require.resolve("../../compiled/babel-loader")).options({
|
|
100
108
|
sourceType: "unambiguous",
|
|
@@ -125,14 +133,18 @@ async function addJavaScriptRules(opts) {
|
|
|
125
133
|
].filter(Boolean)
|
|
126
134
|
});
|
|
127
135
|
} else if (srcTranspiler === import_types.Transpiler.swc) {
|
|
128
|
-
const AutoCSSModule = require("../swcPlugins/autoCSSModules").default;
|
|
129
136
|
rule.use("swc-loader").loader(require.resolve("../loader/swc")).options({
|
|
130
|
-
|
|
137
|
+
excludeFiles: [
|
|
138
|
+
new RegExp(`/${import_mfsu.VIRTUAL_ENTRY_DIR}/[^\\/]+\\.js$`)
|
|
139
|
+
],
|
|
140
|
+
enableAutoCssModulesPlugin: userConfig.autoCSSModules,
|
|
141
|
+
mergeConfigs: (_a2 = userConfig.srcTranspilerOptions) == null ? void 0 : _a2.swc
|
|
131
142
|
});
|
|
132
143
|
} else if (srcTranspiler === import_types.Transpiler.esbuild) {
|
|
133
144
|
rule.use("esbuild-loader").loader(import_mfsu.esbuildLoader).options({
|
|
134
145
|
target: isDev ? "esnext" : "es2015",
|
|
135
|
-
handler: [import_mfsu.autoCssModulesHandler, ...opts.extraEsbuildLoaderHandler]
|
|
146
|
+
handler: [import_mfsu.autoCssModulesHandler, ...opts.extraEsbuildLoaderHandler],
|
|
147
|
+
...(_b2 = userConfig.srcTranspilerOptions) == null ? void 0 : _b2.esbuild
|
|
136
148
|
});
|
|
137
149
|
config.plugin("react-provide-plugin").use(import_webpack.ProvidePlugin, [
|
|
138
150
|
{
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/config/miniCSSExtractPlugin.ts
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/config/progressPlugin.ts
|
|
@@ -26,13 +29,19 @@ __export(progressPlugin_exports, {
|
|
|
26
29
|
});
|
|
27
30
|
module.exports = __toCommonJS(progressPlugin_exports);
|
|
28
31
|
var import_ProgressPlugin = __toESM(require("../plugins/ProgressPlugin"));
|
|
32
|
+
var import_webpackbar = __toESM(require("../../compiled/webpackbar"));
|
|
33
|
+
var import_types = require("../types");
|
|
29
34
|
async function addProgressPlugin(opts) {
|
|
30
|
-
const { config, name } = opts;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
const { config, name, env } = opts;
|
|
36
|
+
if (env === import_types.Env.production) {
|
|
37
|
+
config.plugin("progress-plugin").use(import_webpackbar.default, [
|
|
38
|
+
{
|
|
39
|
+
name: name || "webpack"
|
|
40
|
+
}
|
|
41
|
+
]);
|
|
42
|
+
} else {
|
|
43
|
+
config.plugin("progress-plugin-dev").use(import_ProgressPlugin.default);
|
|
44
|
+
}
|
|
36
45
|
}
|
|
37
46
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
47
|
0 && (module.exports = {
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/config/speedMeasureWebpackPlugin.ts
|
|
@@ -31,7 +34,9 @@ async function addSpeedMeasureWebpackPlugin(opts) {
|
|
|
31
34
|
var _a, _b;
|
|
32
35
|
let webpackConfig = opts.webpackConfig;
|
|
33
36
|
if (process.env.SPEED_MEASURE) {
|
|
34
|
-
const miniCssExtractPluginIdx = (_a = webpackConfig.plugins) == null ? void 0 : _a.findIndex(
|
|
37
|
+
const miniCssExtractPluginIdx = (_a = webpackConfig.plugins) == null ? void 0 : _a.findIndex(
|
|
38
|
+
(plugin) => plugin.constructor.name === "MiniCssExtractPlugin"
|
|
39
|
+
);
|
|
35
40
|
const miniCssExtractPlugin = (_b = webpackConfig.plugins) == null ? void 0 : _b[miniCssExtractPluginIdx];
|
|
36
41
|
const smpOption = process.env.SPEED_MEASURE === "JSON" ? {
|
|
37
42
|
outputFormat: "json",
|
package/dist/config/ssrPlugin.js
CHANGED
|
@@ -45,7 +45,10 @@ var SSRPlugin = class {
|
|
|
45
45
|
});
|
|
46
46
|
assets.forEach((asset) => {
|
|
47
47
|
if (asset.info.sourceFilename) {
|
|
48
|
-
this.manifest.set(
|
|
48
|
+
this.manifest.set(
|
|
49
|
+
asset.info.sourceFilename,
|
|
50
|
+
publicPath + asset.name
|
|
51
|
+
);
|
|
49
52
|
}
|
|
50
53
|
});
|
|
51
54
|
const stats = compilation.getStats().toJson({
|
|
@@ -63,15 +66,26 @@ var SSRPlugin = class {
|
|
|
63
66
|
}
|
|
64
67
|
});
|
|
65
68
|
});
|
|
66
|
-
const assetsSource = JSON.stringify(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
const assetsSource = JSON.stringify(
|
|
70
|
+
{
|
|
71
|
+
assets: Object.fromEntries(this.manifest)
|
|
72
|
+
},
|
|
73
|
+
null,
|
|
74
|
+
2
|
|
75
|
+
);
|
|
69
76
|
if (process.env.NODE_ENV === "production" || this.opts.userConfig.writeToDisk) {
|
|
70
|
-
compilation.emitAsset(
|
|
77
|
+
compilation.emitAsset(
|
|
78
|
+
"build-manifest.json",
|
|
79
|
+
new import_webpack.sources.RawSource(assetsSource, false)
|
|
80
|
+
);
|
|
71
81
|
} else {
|
|
72
82
|
const outputPath = compiler.options.output.path;
|
|
73
83
|
import_utils.fsExtra.mkdirpSync(outputPath);
|
|
74
|
-
(0, import_fs.writeFileSync)(
|
|
84
|
+
(0, import_fs.writeFileSync)(
|
|
85
|
+
(0, import_path.join)(outputPath, "build-manifest.json"),
|
|
86
|
+
assetsSource,
|
|
87
|
+
"utf-8"
|
|
88
|
+
);
|
|
75
89
|
}
|
|
76
90
|
});
|
|
77
91
|
});
|
package/dist/config/svgRules.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/config/svgRules.ts
|
package/dist/dev.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/dev.ts
|
|
@@ -36,22 +39,28 @@ var import_constants = require("./constants");
|
|
|
36
39
|
var import_server = require("./server/server");
|
|
37
40
|
var import_types = require("./types");
|
|
38
41
|
function ensureSerializableValue(obj) {
|
|
39
|
-
return JSON.parse(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
return JSON.parse(
|
|
43
|
+
JSON.stringify(
|
|
44
|
+
obj,
|
|
45
|
+
(_key, value) => {
|
|
46
|
+
if (typeof value === "function") {
|
|
47
|
+
return value.toString();
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
},
|
|
51
|
+
2
|
|
52
|
+
)
|
|
53
|
+
);
|
|
45
54
|
}
|
|
46
55
|
async function dev(opts) {
|
|
47
56
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
48
|
-
const cacheDirectoryPath = (0, import_path.resolve)(
|
|
57
|
+
const cacheDirectoryPath = (0, import_path.resolve)(
|
|
58
|
+
opts.rootDir || opts.cwd,
|
|
59
|
+
opts.config.cacheDirectoryPath || "node_modules/.cache"
|
|
60
|
+
);
|
|
49
61
|
const enableMFSU = opts.config.mfsu !== false;
|
|
50
62
|
let mfsu = null;
|
|
51
63
|
if (enableMFSU) {
|
|
52
|
-
if (opts.config.srcTranspiler === import_types.Transpiler.swc) {
|
|
53
|
-
import_utils.logger.warn(`Swc currently not supported for use with mfsu, recommended you use srcTranspiler: 'esbuild' in dev.`);
|
|
54
|
-
}
|
|
55
64
|
mfsu = new import_mfsu.MFSU({
|
|
56
65
|
strategy: opts.mfsuStrategy,
|
|
57
66
|
include: opts.mfsuInclude || [],
|
|
@@ -109,7 +118,10 @@ async function dev(opts) {
|
|
|
109
118
|
analyze: process.env.ANALYZE,
|
|
110
119
|
cache: opts.cache ? {
|
|
111
120
|
...opts.cache,
|
|
112
|
-
cacheDirectory: (0, import_path.join)(
|
|
121
|
+
cacheDirectory: (0, import_path.join)(
|
|
122
|
+
cacheDirectoryPath,
|
|
123
|
+
opts.mfsuStrategy === "eager" ? "bundler-webpack-eager" : "bundler-webpack"
|
|
124
|
+
)
|
|
113
125
|
} : void 0,
|
|
114
126
|
pkg: opts.pkg
|
|
115
127
|
});
|
|
@@ -140,7 +152,11 @@ async function dev(opts) {
|
|
|
140
152
|
depConfig
|
|
141
153
|
}));
|
|
142
154
|
if (mfsu && webpackConfig.cache && typeof webpackConfig.cache === "object" && webpackConfig.cache.type === "filesystem") {
|
|
143
|
-
const webpackCachePath = (0, import_path.join)(
|
|
155
|
+
const webpackCachePath = (0, import_path.join)(
|
|
156
|
+
webpackConfig.cache.cacheDirectory,
|
|
157
|
+
`default-development`,
|
|
158
|
+
"index.pack"
|
|
159
|
+
);
|
|
144
160
|
const mfsuCacheExists = (0, import_fs.existsSync)(mfsu.getCacheFilePath());
|
|
145
161
|
const webpackCacheExists = (0, import_fs.existsSync)(webpackCachePath);
|
|
146
162
|
if (webpackCacheExists && !mfsuCacheExists) {
|
package/dist/loader/svgr.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/loader/svgr.ts
|
|
@@ -31,17 +34,19 @@ var import_plugin_svgo = __toESM(require("@svgr/plugin-svgo"));
|
|
|
31
34
|
var import_esbuild = require("@umijs/bundler-utils/compiled/esbuild");
|
|
32
35
|
var import_path = require("path");
|
|
33
36
|
var import_util = require("util");
|
|
34
|
-
var tranformSvg = (0, import_util.callbackify)(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
var tranformSvg = (0, import_util.callbackify)(
|
|
38
|
+
async (contents, options, state) => {
|
|
39
|
+
const jsCode = await (0, import_core.transform)(contents, options, state);
|
|
40
|
+
const result = await (0, import_esbuild.transform)(jsCode, {
|
|
41
|
+
loader: "tsx",
|
|
42
|
+
target: "es2015"
|
|
43
|
+
});
|
|
44
|
+
if (!(result == null ? void 0 : result.code)) {
|
|
45
|
+
throw new Error(`Error while transforming using Esbuild`);
|
|
46
|
+
}
|
|
47
|
+
return result.code;
|
|
42
48
|
}
|
|
43
|
-
|
|
44
|
-
});
|
|
49
|
+
);
|
|
45
50
|
function svgrLoader(contents) {
|
|
46
51
|
this.cacheable && this.cacheable();
|
|
47
52
|
const callback = this.async();
|
package/dist/loader/swc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LoaderContext } from '../../compiled/webpack';
|
|
2
|
-
import { SwcOptions } from '../types';
|
|
3
|
-
declare function swcLoader(this: LoaderContext<SwcOptions>, contents: string): void;
|
|
2
|
+
import { type SwcOptions } from '../types';
|
|
3
|
+
declare function swcLoader(this: LoaderContext<SwcOptions>, contents: string, inputSourceMap: string | Record<string, any>): void;
|
|
4
4
|
export default swcLoader;
|