@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.
Files changed (94) hide show
  1. package/client/utils/formatWebpackMessages.js +27 -8
  2. package/compiled/autoprefixer/browserslist/index.d.ts +21 -1
  3. package/compiled/autoprefixer/index.js +2 -2
  4. package/compiled/autoprefixer/package.json +1 -1
  5. package/compiled/autoprefixer/postcss/lib/processor.d.ts +1 -1
  6. package/compiled/babel-loader/index.js +8 -2
  7. package/compiled/babel-loader/package.json +1 -1
  8. package/compiled/less-loader/index.js +1 -1
  9. package/compiled/less-loader/package.json +1 -1
  10. package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +22 -60
  11. package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +2 -10
  12. package/compiled/mini-css-extract-plugin/index.js +492 -696
  13. package/compiled/mini-css-extract-plugin/loader.js +54 -120
  14. package/compiled/mini-css-extract-plugin/package.json +1 -1
  15. package/compiled/mini-css-extract-plugin/utils.js +27 -44
  16. package/compiled/postcss-loader/index.js +1 -1
  17. package/compiled/postcss-loader/package.json +1 -1
  18. package/compiled/sass-loader/index.js +1 -1
  19. package/compiled/sass-loader/package.json +1 -1
  20. package/compiled/sass-loader/sass.default.dart.js +4 -0
  21. package/compiled/terser/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +90 -0
  22. package/compiled/terser/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
  23. package/compiled/terser/@jridgewell/gen-mapping/dist/types/types.d.ts +35 -0
  24. package/compiled/terser/@jridgewell/source-map/dist/types/source-map.d.ts +25 -0
  25. package/compiled/terser/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
  26. package/compiled/terser/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
  27. package/compiled/terser/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
  28. package/compiled/terser/index.js +1 -1
  29. package/compiled/terser/package.json +1 -1
  30. package/compiled/terser/tools/terser.d.ts +6 -3
  31. package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
  32. package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
  33. package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
  34. package/compiled/terser-webpack-plugin/index.js +1211 -3390
  35. package/compiled/terser-webpack-plugin/package.json +1 -1
  36. package/compiled/terser-webpack-plugin/types/index.d.ts +10 -10
  37. package/compiled/terser-webpack-plugin/types/utils.d.ts +10 -9
  38. package/compiled/terser-webpack-plugin/utils.js +36 -10
  39. package/compiled/webpack/package.json +1 -1
  40. package/compiled/webpack/types.d.ts +137 -126
  41. package/compiled/webpack-5-chain/index.js +1 -1
  42. package/compiled/webpack-5-chain/package.json +1 -1
  43. package/compiled/webpack-5-chain/types/index.d.ts +76 -20
  44. package/compiled/webpack-bundle-analyzer/index.js +7 -6
  45. package/compiled/webpack-bundle-analyzer/package.json +1 -1
  46. package/compiled/webpack-bundle-analyzer/public/viewer.js +2 -2
  47. package/compiled/webpack-bundle-analyzer/public/viewer.js.map +1 -1
  48. package/compiled/webpack-dev-middleware/index.js +5 -5
  49. package/compiled/webpack-dev-middleware/package.json +1 -1
  50. package/compiled/webpackbar/LICENSE +20 -0
  51. package/compiled/webpackbar/dist/index.d.ts +121 -0
  52. package/compiled/webpackbar/index.js +7 -0
  53. package/compiled/webpackbar/package.json +1 -0
  54. package/compiled/ws/LICENSE +13 -12
  55. package/compiled/ws/index.d.ts +73 -33
  56. package/compiled/ws/index.js +1 -1
  57. package/compiled/ws/package.json +1 -1
  58. package/dist/build.js +8 -2
  59. package/dist/cli.js +4 -1
  60. package/dist/config/compressPlugin.js +4 -1
  61. package/dist/config/config.js +41 -11
  62. package/dist/config/cssRules.js +17 -5
  63. package/dist/config/detectDeadCode.js +38 -8
  64. package/dist/config/detectDeadCodePlugin.js +8 -2
  65. package/dist/config/fastRefreshPlugin.js +4 -1
  66. package/dist/config/forkTSCheckerPlugin.js +4 -1
  67. package/dist/config/harmonyLinkingErrorPlugin.js +14 -11
  68. package/dist/config/javaScriptRules.js +21 -9
  69. package/dist/config/miniCSSExtractPlugin.js +4 -1
  70. package/dist/config/progressPlugin.js +16 -7
  71. package/dist/config/speedMeasureWebpackPlugin.js +7 -2
  72. package/dist/config/ssrPlugin.js +20 -6
  73. package/dist/config/svgRules.js +4 -1
  74. package/dist/dev.js +29 -13
  75. package/dist/loader/svgr.js +16 -11
  76. package/dist/loader/swc.d.ts +2 -2
  77. package/dist/loader/swc.js +66 -10
  78. package/dist/parcelCSS.js +4 -1
  79. package/dist/plugins/ProgressPlugin.js +6 -2
  80. package/dist/plugins/RuntimePublicPathPlugin.js +9 -6
  81. package/dist/plugins/_SamplePlugin.d.ts +1 -1
  82. package/dist/plugins/_SamplePlugin.js +1 -1
  83. package/dist/requireHook.js +4 -1
  84. package/dist/schema.js +62 -23
  85. package/dist/server/server.d.ts +1 -4
  86. package/dist/server/server.js +37 -23
  87. package/dist/server/ws.js +8 -3
  88. package/dist/swcPlugins/autoCSSModules.d.ts +5 -1
  89. package/dist/swcPlugins/autoCSSModules.js +4 -1
  90. package/dist/swcPlugins/lockCoreJS.js +8 -2
  91. package/dist/types.d.ts +15 -3
  92. package/dist/utils/formatWebpackMessages.js +31 -9
  93. package/dist/utils/getEsBuildTarget.js +7 -1
  94. package/package.json +30 -26
@@ -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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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(require.resolve("@umijs/bundler-webpack/compiled/style-loader")).options({ base: 0, esModule: true, ...userConfig.styleLoader });
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(require.resolve("@umijs/bundler-webpack/compiled/mini-css-extract-plugin/loader")).options({
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((0, import_utils.winPath)(ensureLastSlash(opt.context)), "") + "@" + localName).trim();
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(require.resolve("@umijs/bundler-webpack/compiled/postcss-loader")).options({
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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(compilation, chunk, module2, includedFileMap, unusedExportMap);
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(module2, chunk.runtime);
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((item) => usedExports && !usedExports.has(item));
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(import_utils.chalk.yellow.bold("\nWarning:"), import_utils.chalk.yellow(`There are ${numberOfUnusedExport} unused exports in ${Object.keys(unusedExportMap).length} files:`), logStr, import_utils.chalk.red.bold("\nPlease be careful if you want to remove them (\xAC\xBA-\xB0)\xAC.\n"));
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(compilation.compiler.outputPath);
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(import_utils.chalk.yellow.bold("\nWarning:"), import_utils.chalk.yellow(`There are ${unusedFiles.length} unused files:`), ...unusedFiles.map((file, index) => `
137
- ${index + 1}. ${import_utils.chalk.yellow(file)}`), import_utils.chalk.red.bold("\nPlease be careful if you want to remove them (\xAC\xBA-\xB0)\xAC.\n"));
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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("DetectDeadCodePlugin", this.handleAfterEmit);
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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("HarmonyLinkingErrorPlugin", (compilation) => {
30
- if (!compilation.warnings.length) {
31
- return;
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
- const harmonyLinkingErrors = compilation.warnings.filter((w) => {
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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)(import_utils.resolve.sync(`${p}/package.json`, {
60
- basedir: cwd,
61
- preserveSymlinks: false
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
- plugin: (m) => new AutoCSSModule().visitProgram(m)
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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
- config.plugin("progress-plugin").use(import_ProgressPlugin.default, [
32
- {
33
- name
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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((plugin) => plugin.constructor.name === "MiniCssExtractPlugin");
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",
@@ -45,7 +45,10 @@ var SSRPlugin = class {
45
45
  });
46
46
  assets.forEach((asset) => {
47
47
  if (asset.info.sourceFilename) {
48
- this.manifest.set(asset.info.sourceFilename, publicPath + asset.name);
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
- assets: Object.fromEntries(this.manifest)
68
- }, null, 2);
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("build-manifest.json", new import_webpack.sources.RawSource(assetsSource, false));
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)((0, import_path.join)(outputPath, "build-manifest.json"), assetsSource, "utf-8");
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
  });
@@ -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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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(JSON.stringify(obj, (_key, value) => {
40
- if (typeof value === "function") {
41
- return value.toString();
42
- }
43
- return value;
44
- }, 2));
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)(opts.rootDir || opts.cwd, opts.config.cacheDirectoryPath || "node_modules/.cache");
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)(cacheDirectoryPath, opts.mfsuStrategy === "eager" ? "bundler-webpack-eager" : "bundler-webpack")
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)(webpackConfig.cache.cacheDirectory, `default-development`, "index.pack");
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) {
@@ -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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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)(async (contents, options, state) => {
35
- const jsCode = await (0, import_core.transform)(contents, options, state);
36
- const result = await (0, import_esbuild.transform)(jsCode, {
37
- loader: "tsx",
38
- target: "es2015"
39
- });
40
- if (!(result == null ? void 0 : result.code)) {
41
- throw new Error(`Error while transforming using Esbuild`);
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
- return result.code;
44
- });
49
+ );
45
50
  function svgrLoader(contents) {
46
51
  this.cacheable && this.cacheable();
47
52
  const callback = this.async();
@@ -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;