@umijs/bundler-webpack 4.0.42 → 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 (84) hide show
  1. package/client/utils/formatWebpackMessages.js +27 -8
  2. package/compiled/babel-loader/index.js +8 -2
  3. package/compiled/babel-loader/package.json +1 -1
  4. package/compiled/less-loader/index.js +1 -1
  5. package/compiled/less-loader/package.json +1 -1
  6. package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +22 -60
  7. package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +2 -10
  8. package/compiled/mini-css-extract-plugin/index.js +492 -696
  9. package/compiled/mini-css-extract-plugin/loader.js +54 -120
  10. package/compiled/mini-css-extract-plugin/package.json +1 -1
  11. package/compiled/mini-css-extract-plugin/utils.js +27 -44
  12. package/compiled/postcss-loader/index.js +1 -1
  13. package/compiled/postcss-loader/package.json +1 -1
  14. package/compiled/sass-loader/index.js +1 -1
  15. package/compiled/sass-loader/package.json +1 -1
  16. package/compiled/sass-loader/sass.default.dart.js +4 -0
  17. package/compiled/terser/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +90 -0
  18. package/compiled/terser/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
  19. package/compiled/terser/@jridgewell/gen-mapping/dist/types/types.d.ts +35 -0
  20. package/compiled/terser/@jridgewell/source-map/dist/types/source-map.d.ts +25 -0
  21. package/compiled/terser/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
  22. package/compiled/terser/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
  23. package/compiled/terser/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
  24. package/compiled/terser/index.js +1 -1
  25. package/compiled/terser/package.json +1 -1
  26. package/compiled/terser/tools/terser.d.ts +6 -3
  27. package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
  28. package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
  29. package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
  30. package/compiled/terser-webpack-plugin/index.js +1211 -3390
  31. package/compiled/terser-webpack-plugin/package.json +1 -1
  32. package/compiled/terser-webpack-plugin/types/index.d.ts +10 -10
  33. package/compiled/terser-webpack-plugin/types/utils.d.ts +10 -9
  34. package/compiled/terser-webpack-plugin/utils.js +36 -10
  35. package/compiled/webpack/package.json +1 -1
  36. package/compiled/webpack/types.d.ts +137 -126
  37. package/compiled/webpack-5-chain/index.js +1 -1
  38. package/compiled/webpack-5-chain/package.json +1 -1
  39. package/compiled/webpack-5-chain/types/index.d.ts +76 -20
  40. package/compiled/webpack-bundle-analyzer/index.js +7 -6
  41. package/compiled/webpack-bundle-analyzer/package.json +1 -1
  42. package/compiled/webpack-bundle-analyzer/public/viewer.js +2 -2
  43. package/compiled/webpack-bundle-analyzer/public/viewer.js.map +1 -1
  44. package/compiled/webpack-dev-middleware/index.js +5 -5
  45. package/compiled/webpack-dev-middleware/package.json +1 -1
  46. package/compiled/ws/LICENSE +13 -12
  47. package/compiled/ws/index.d.ts +73 -33
  48. package/compiled/ws/index.js +1 -1
  49. package/compiled/ws/package.json +1 -1
  50. package/dist/build.js +8 -2
  51. package/dist/cli.js +4 -1
  52. package/dist/config/compressPlugin.js +4 -1
  53. package/dist/config/config.js +41 -11
  54. package/dist/config/cssRules.js +17 -5
  55. package/dist/config/detectDeadCode.js +38 -8
  56. package/dist/config/detectDeadCodePlugin.js +8 -2
  57. package/dist/config/fastRefreshPlugin.js +4 -1
  58. package/dist/config/forkTSCheckerPlugin.js +4 -1
  59. package/dist/config/harmonyLinkingErrorPlugin.js +14 -11
  60. package/dist/config/javaScriptRules.js +10 -5
  61. package/dist/config/miniCSSExtractPlugin.js +4 -1
  62. package/dist/config/progressPlugin.js +9 -2
  63. package/dist/config/speedMeasureWebpackPlugin.js +7 -2
  64. package/dist/config/ssrPlugin.js +20 -6
  65. package/dist/config/svgRules.js +4 -1
  66. package/dist/dev.js +29 -10
  67. package/dist/loader/svgr.js +16 -11
  68. package/dist/loader/swc.js +26 -8
  69. package/dist/parcelCSS.js +4 -1
  70. package/dist/plugins/ProgressPlugin.js +6 -2
  71. package/dist/plugins/RuntimePublicPathPlugin.js +9 -6
  72. package/dist/plugins/_SamplePlugin.d.ts +1 -1
  73. package/dist/plugins/_SamplePlugin.js +1 -1
  74. package/dist/requireHook.js +4 -1
  75. package/dist/schema.js +58 -23
  76. package/dist/server/server.d.ts +1 -4
  77. package/dist/server/server.js +37 -23
  78. package/dist/server/ws.js +8 -3
  79. package/dist/swcPlugins/autoCSSModules.js +4 -1
  80. package/dist/swcPlugins/lockCoreJS.js +8 -2
  81. package/dist/types.d.ts +2 -1
  82. package/dist/utils/formatWebpackMessages.js +31 -9
  83. package/dist/utils/getEsBuildTarget.js +7 -1
  84. package/package.json +25 -24
@@ -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/config.ts
@@ -87,10 +90,20 @@ async function getConfig(opts) {
87
90
  }
88
91
  entry.add(opts.entry[key]);
89
92
  });
90
- config.devtool(isDev ? userConfig.devtool === false ? false : userConfig.devtool || import_constants.DEFAULT_DEVTOOL : userConfig.devtool);
91
- const absOutputPath = (0, import_path.resolve)(opts.cwd, userConfig.outputPath || import_constants.DEFAULT_OUTPUT_PATH);
93
+ config.devtool(
94
+ isDev ? userConfig.devtool === false ? false : userConfig.devtool || import_constants.DEFAULT_DEVTOOL : userConfig.devtool
95
+ );
96
+ const absOutputPath = (0, import_path.resolve)(
97
+ opts.cwd,
98
+ userConfig.outputPath || import_constants.DEFAULT_OUTPUT_PATH
99
+ );
92
100
  const disableCompress = process.env.COMPRESS === "none";
93
- 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]`).set("hashFunction", "xxhash64");
101
+ config.output.path(absOutputPath).filename(useHash ? `[name].[contenthash:8].js` : `[name].js`).chunkFilename(
102
+ useHash ? `[name].[contenthash:8].async.js` : `[name].async.js`
103
+ ).publicPath(userConfig.publicPath || "auto").pathinfo(isDev || disableCompress).set(
104
+ "assetModuleFilename",
105
+ `${applyOpts.staticPathPrefix}[name].[hash:8][ext]`
106
+ ).set("hashFunction", "xxhash64");
94
107
  config.resolve.set("symlinks", true).modules.add("node_modules").end().alias.merge(userConfig.alias || {}).end().extensions.merge([
95
108
  ".wasm",
96
109
  ".mjs",
@@ -140,22 +153,39 @@ async function getConfig(opts) {
140
153
  buildDependencies: {
141
154
  config: opts.cache.buildDependencies || []
142
155
  },
143
- cacheDirectory: opts.cache.cacheDirectory || (0, import_path.join)(opts.rootDir || opts.cwd, "node_modules", ".cache", "bundler-webpack")
156
+ cacheDirectory: opts.cache.cacheDirectory || (0, import_path.join)(
157
+ opts.rootDir || opts.cwd,
158
+ "node_modules",
159
+ ".cache",
160
+ "bundler-webpack"
161
+ )
144
162
  });
145
163
  if (require("@umijs/utils/package").__npminstall_done) {
146
164
  const nodeModulesPath = opts.cache.absNodeModulesPath || (0, import_path.join)(opts.rootDir || opts.cwd, "node_modules");
147
- 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) => {
165
+ const localLinkedNodeModules = Object.keys(
166
+ Object.assign(
167
+ {},
168
+ (_a = opts.pkg) == null ? void 0 : _a.dependencies,
169
+ (_b = opts.pkg) == null ? void 0 : _b.peerDependencies,
170
+ (_c = opts.pkg) == null ? void 0 : _c.devDependencies
171
+ )
172
+ ).map((pkg) => {
148
173
  try {
149
- return (0, import_path.resolve)(import_utils.resolve.sync(`${pkg}/package.json`, {
150
- basedir: opts.rootDir || opts.cwd,
151
- preserveSymlinks: false
152
- }), "../node_modules");
174
+ return (0, import_path.resolve)(
175
+ import_utils.resolve.sync(`${pkg}/package.json`, {
176
+ basedir: opts.rootDir || opts.cwd,
177
+ preserveSymlinks: false
178
+ }),
179
+ "../node_modules"
180
+ );
153
181
  } catch {
154
182
  return opts.rootDir || opts.cwd;
155
183
  }
156
184
  }).filter((pkg) => !pkg.startsWith(opts.rootDir || opts.cwd));
157
185
  if (localLinkedNodeModules.length) {
158
- import_utils.logger.info(`Detected local linked tnpm node_modules, to avoid oom, they will be treated as immutablePaths & managedPaths in webpack snapshot:`);
186
+ import_utils.logger.info(
187
+ `Detected local linked tnpm node_modules, to avoid oom, they will be treated as immutablePaths & managedPaths in webpack snapshot:`
188
+ );
159
189
  localLinkedNodeModules.forEach((p) => import_utils.logger.info(` ${p}`));
160
190
  }
161
191
  config.snapshot({
@@ -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,10 +59,12 @@ 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
70
  throw new Error("Cannot resolve extraBabelIncludes: " + p, {
@@ -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
@@ -25,15 +28,19 @@ __export(progressPlugin_exports, {
25
28
  addProgressPlugin: () => addProgressPlugin
26
29
  });
27
30
  module.exports = __toCommonJS(progressPlugin_exports);
31
+ var import_ProgressPlugin = __toESM(require("../plugins/ProgressPlugin"));
28
32
  var import_webpackbar = __toESM(require("../../compiled/webpackbar"));
33
+ var import_types = require("../types");
29
34
  async function addProgressPlugin(opts) {
30
35
  const { config, name, env } = opts;
31
- if (env === "production") {
36
+ if (env === import_types.Env.production) {
32
37
  config.plugin("progress-plugin").use(import_webpackbar.default, [
33
38
  {
34
39
  name: name || "webpack"
35
40
  }
36
41
  ]);
42
+ } else {
43
+ config.plugin("progress-plugin-dev").use(import_ProgressPlugin.default);
37
44
  }
38
45
  }
39
46
  // Annotate the CommonJS export names for ESM import in node:
@@ -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,16 +39,25 @@ 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) {
@@ -106,7 +118,10 @@ async function dev(opts) {
106
118
  analyze: process.env.ANALYZE,
107
119
  cache: opts.cache ? {
108
120
  ...opts.cache,
109
- 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
+ )
110
125
  } : void 0,
111
126
  pkg: opts.pkg
112
127
  });
@@ -137,7 +152,11 @@ async function dev(opts) {
137
152
  depConfig
138
153
  }));
139
154
  if (mfsu && webpackConfig.cache && typeof webpackConfig.cache === "object" && webpackConfig.cache.type === "filesystem") {
140
- 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
+ );
141
160
  const mfsuCacheExists = (0, import_fs.existsSync)(mfsu.getCacheFilePath());
142
161
  const webpackCacheExists = (0, import_fs.existsSync)(webpackCachePath);
143
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();
@@ -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/swc.ts
@@ -80,7 +83,11 @@ function swcLoader(contents, inputSourceMap) {
80
83
  return pattern.test(filename);
81
84
  });
82
85
  if (isSkip) {
83
- return callback(null, contents, parseMap ? JSON.parse(inputSourceMap) : inputSourceMap);
86
+ return callback(
87
+ null,
88
+ contents,
89
+ parseMap ? JSON.parse(inputSourceMap) : inputSourceMap
90
+ );
84
91
  }
85
92
  let swcOpts = {
86
93
  ...getBaseOpts({
@@ -109,13 +116,24 @@ function swcLoader(contents, inputSourceMap) {
109
116
  try {
110
117
  if (sync) {
111
118
  const output = (0, import_core.transformSync)(contents, swcOpts);
112
- callback(null, output.code, parseMap ? JSON.parse(output.map) : output.map);
119
+ callback(
120
+ null,
121
+ output.code,
122
+ parseMap ? JSON.parse(output.map) : output.map
123
+ );
113
124
  } else {
114
- (0, import_core.transform)(contents, swcOpts).then((output) => {
115
- callback(null, output.code, parseMap ? JSON.parse(output.map) : output.map);
116
- }, (err) => {
117
- callback(err);
118
- });
125
+ (0, import_core.transform)(contents, swcOpts).then(
126
+ (output) => {
127
+ callback(
128
+ null,
129
+ output.code,
130
+ parseMap ? JSON.parse(output.map) : output.map
131
+ );
132
+ },
133
+ (err) => {
134
+ callback(err);
135
+ }
136
+ );
119
137
  }
120
138
  } catch (e) {
121
139
  callback(e);
package/dist/parcelCSS.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/parcelCSS.ts