@umijs/bundler-webpack 4.0.0-beta.9 → 4.0.0-canary-20240513.3

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 (260) hide show
  1. package/client/client/client.js +255 -167
  2. package/client/constants.d.ts +15 -0
  3. package/client/constants.js +30 -12
  4. package/client/utils/formatWebpackMessages.d.ts +12 -0
  5. package/client/utils/formatWebpackMessages.js +87 -86
  6. package/compiled/autoprefixer/browserslist/index.d.ts +33 -7
  7. package/compiled/autoprefixer/index.js +3 -3
  8. package/compiled/autoprefixer/package.json +1 -1
  9. package/compiled/autoprefixer/postcss/lib/at-rule.d.ts +1 -1
  10. package/compiled/autoprefixer/postcss/lib/comment.d.ts +1 -1
  11. package/compiled/autoprefixer/postcss/lib/container.d.ts +2 -2
  12. package/compiled/autoprefixer/postcss/lib/css-syntax-error.d.ts +55 -8
  13. package/compiled/autoprefixer/postcss/lib/declaration.d.ts +2 -2
  14. package/compiled/autoprefixer/postcss/lib/input.d.ts +26 -6
  15. package/compiled/autoprefixer/postcss/lib/lazy-result.d.ts +11 -10
  16. package/compiled/autoprefixer/postcss/lib/no-work-result.d.ts +37 -0
  17. package/compiled/autoprefixer/postcss/lib/node.d.ts +38 -4
  18. package/compiled/autoprefixer/postcss/lib/postcss.d.ts +31 -30
  19. package/compiled/autoprefixer/postcss/lib/processor.d.ts +6 -5
  20. package/compiled/autoprefixer/postcss/lib/result.d.ts +3 -2
  21. package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
  22. package/compiled/autoprefixer/postcss/lib/warning.d.ts +37 -3
  23. package/compiled/autoprefixer/source-map-js/source-map.d.ts +99 -82
  24. package/compiled/babel-loader/index.js +8 -2
  25. package/compiled/babel-loader/package.json +1 -1
  26. package/compiled/copy-webpack-plugin/939.index.js +1171 -0
  27. package/compiled/copy-webpack-plugin/index.js +16 -10
  28. package/compiled/copy-webpack-plugin/package.json +1 -1
  29. package/compiled/css-minimizer-webpack-plugin/index.js +8 -2
  30. package/compiled/css-minimizer-webpack-plugin/minify.js +23 -22
  31. package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
  32. package/compiled/css-minimizer-webpack-plugin/utils.js +305 -54
  33. package/compiled/cssnano/index.js +12 -11
  34. package/compiled/cssnano/package.json +1 -1
  35. package/compiled/express.d.ts +2 -0
  36. package/compiled/file-loader/index.js +3 -0
  37. package/compiled/file-loader/package.json +1 -0
  38. package/compiled/less-loader/index.js +1 -1
  39. package/compiled/less-loader/package.json +1 -1
  40. package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -46
  41. package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +10 -6
  42. package/compiled/mini-css-extract-plugin/index.js +10669 -10348
  43. package/compiled/mini-css-extract-plugin/loader.js +159 -100
  44. package/compiled/mini-css-extract-plugin/package.json +1 -1
  45. package/compiled/mini-css-extract-plugin/utils.js +88 -44
  46. package/compiled/postcss-loader/index.js +1 -1
  47. package/compiled/postcss-loader/package.json +1 -1
  48. package/compiled/sass-loader/index.js +1 -1
  49. package/compiled/sass-loader/package.json +1 -1
  50. package/compiled/sass-loader/sass.default.dart.js +4 -0
  51. package/compiled/schema-utils/ajv/dist/ajv.d.ts +16 -0
  52. package/compiled/schema-utils/ajv/dist/compile/codegen/code.d.ts +39 -0
  53. package/compiled/schema-utils/ajv/dist/compile/codegen/index.d.ts +79 -0
  54. package/compiled/schema-utils/ajv/dist/compile/codegen/scope.d.ts +79 -0
  55. package/compiled/schema-utils/ajv/dist/compile/errors.d.ts +13 -0
  56. package/compiled/schema-utils/ajv/dist/compile/index.d.ts +80 -0
  57. package/compiled/schema-utils/ajv/dist/compile/ref_error.d.ts +5 -0
  58. package/compiled/schema-utils/ajv/dist/compile/resolve.d.ts +12 -0
  59. package/compiled/schema-utils/ajv/dist/compile/rules.d.ts +28 -0
  60. package/compiled/schema-utils/ajv/dist/compile/util.d.ts +40 -0
  61. package/compiled/schema-utils/ajv/dist/compile/validate/index.d.ts +42 -0
  62. package/compiled/schema-utils/ajv/dist/compile/validate/subschema.d.ts +47 -0
  63. package/compiled/schema-utils/ajv/dist/core.d.ts +171 -0
  64. package/compiled/schema-utils/ajv/dist/runtime/validation_error.d.ts +7 -0
  65. package/compiled/schema-utils/ajv/dist/types/index.d.ts +177 -0
  66. package/compiled/schema-utils/ajv/dist/types/json-schema.d.ts +124 -0
  67. package/compiled/schema-utils/ajv/dist/types/jtd-schema.d.ts +168 -0
  68. package/compiled/schema-utils/declarations/validate.d.ts +4 -4
  69. package/compiled/schema-utils/index.js +8 -2
  70. package/compiled/schema-utils/uri-js/dist/es5/uri.all.d.ts +59 -0
  71. package/compiled/style-loader/index.js +1 -1
  72. package/compiled/stylus-loader/LICENSE +20 -0
  73. package/compiled/stylus-loader/index.js +44 -0
  74. package/compiled/stylus-loader/package.json +1 -0
  75. package/compiled/terser/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +90 -0
  76. package/compiled/terser/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
  77. package/compiled/terser/@jridgewell/gen-mapping/dist/types/types.d.ts +35 -0
  78. package/compiled/terser/@jridgewell/source-map/dist/types/source-map.d.ts +25 -0
  79. package/compiled/terser/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
  80. package/compiled/terser/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
  81. package/compiled/terser/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
  82. package/compiled/terser/index.js +1 -1
  83. package/compiled/terser/package.json +1 -1
  84. package/compiled/terser/tools/terser.d.ts +6 -3
  85. package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
  86. package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
  87. package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
  88. package/compiled/terser-webpack-plugin/index.js +1390 -3693
  89. package/compiled/terser-webpack-plugin/jest-worker/build/types.d.ts +1 -0
  90. package/compiled/terser-webpack-plugin/minify.js +10 -3
  91. package/compiled/terser-webpack-plugin/package.json +1 -1
  92. package/compiled/terser-webpack-plugin/types/index.d.ts +186 -152
  93. package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
  94. package/compiled/terser-webpack-plugin/types/utils.d.ts +20 -24
  95. package/compiled/terser-webpack-plugin/utils.js +153 -34
  96. package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
  97. package/compiled/webpack/BasicEvaluatedExpression.js +1 -0
  98. package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
  99. package/compiled/webpack/ExternalsPlugin.js +1 -0
  100. package/compiled/webpack/FetchCompileAsyncWasmPlugin.js +1 -0
  101. package/compiled/webpack/FetchCompileWasmPlugin.js +1 -0
  102. package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
  103. package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
  104. package/compiled/webpack/LimitChunkCountPlugin.js +1 -0
  105. package/compiled/webpack/NodeTargetPlugin.js +1 -0
  106. package/compiled/webpack/NodeTemplatePlugin.js +1 -0
  107. package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
  108. package/compiled/webpack/RuleSetCompiler.js +1 -0
  109. package/compiled/webpack/StringXor.js +1 -0
  110. package/compiled/webpack/UseEffectRulePlugin.js +1 -0
  111. package/compiled/webpack/WebWorkerTemplatePlugin.js +1 -0
  112. package/compiled/webpack/deepImports.json +15 -1
  113. package/compiled/webpack/index.js +26404 -10329
  114. package/compiled/webpack/json-schema/index.d.ts +8 -1
  115. package/compiled/webpack/lazy-compilation-node.js +10 -0
  116. package/compiled/webpack/lazy-compilation-web.js +9 -0
  117. package/compiled/webpack/types.d.ts +823 -287
  118. package/compiled/webpack-5-chain/index.js +1 -1
  119. package/compiled/webpack-5-chain/package.json +1 -1
  120. package/compiled/webpack-5-chain/types/index.d.ts +76 -20
  121. package/compiled/webpack-bundle-analyzer/index.js +7 -6
  122. package/compiled/webpack-bundle-analyzer/package.json +1 -1
  123. package/compiled/webpack-bundle-analyzer/public/viewer.js +2 -2
  124. package/compiled/webpack-bundle-analyzer/public/viewer.js.map +1 -1
  125. package/compiled/webpack-dev-middleware/index.js +12 -5
  126. package/compiled/webpack-dev-middleware/package.json +1 -1
  127. package/compiled/{tapable → webpack-manifest-plugin}/LICENSE +2 -2
  128. package/compiled/webpack-manifest-plugin/index.js +1 -0
  129. package/compiled/webpack-manifest-plugin/package.json +1 -0
  130. package/compiled/webpack-sources/index.js +1 -1
  131. package/compiled/{express → webpackbar}/LICENSE +1 -5
  132. package/compiled/webpackbar/dist/index.d.ts +121 -0
  133. package/compiled/webpackbar/index.js +7 -0
  134. package/compiled/webpackbar/package.json +1 -0
  135. package/compiled/ws/LICENSE +13 -12
  136. package/compiled/ws/index.d.ts +74 -35
  137. package/compiled/ws/index.js +1 -1
  138. package/compiled/ws/package.json +1 -1
  139. package/dist/build.d.ts +8 -3
  140. package/dist/build.js +147 -68
  141. package/dist/cli.js +84 -81
  142. package/dist/config/_sampleFeature.js +33 -20
  143. package/dist/config/assetRules.js +46 -67
  144. package/dist/config/bundleAnalyzerPlugin.js +41 -28
  145. package/dist/config/compressPlugin.js +125 -74
  146. package/dist/config/config.d.ts +11 -2
  147. package/dist/config/config.js +235 -172
  148. package/dist/config/copyPlugin.js +61 -47
  149. package/dist/config/cssRules.js +162 -95
  150. package/dist/config/definePlugin.d.ts +2 -0
  151. package/dist/config/definePlugin.js +59 -39
  152. package/dist/config/detectCssModulesInDependence.d.ts +10 -0
  153. package/dist/config/detectCssModulesInDependence.js +151 -0
  154. package/dist/config/detectDeadCode.d.ts +12 -0
  155. package/dist/config/detectDeadCode.js +191 -0
  156. package/dist/config/detectDeadCodePlugin.d.ts +9 -0
  157. package/dist/config/detectDeadCodePlugin.js +82 -0
  158. package/dist/config/fastRefreshPlugin.js +46 -31
  159. package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
  160. package/dist/config/forkTSCheckerPlugin.js +49 -0
  161. package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
  162. package/dist/config/harmonyLinkingErrorPlugin.js +53 -0
  163. package/dist/config/ignorePlugin.js +38 -25
  164. package/dist/config/javaScriptRules.d.ts +2 -0
  165. package/dist/config/javaScriptRules.js +186 -150
  166. package/dist/config/manifestPlugin.d.ts +11 -0
  167. package/dist/config/manifestPlugin.js +40 -0
  168. package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
  169. package/dist/config/miniCSSExtractPlugin.js +52 -31
  170. package/dist/config/nodePolyfill.js +49 -32
  171. package/dist/config/nodePrefixPlugin.d.ts +11 -0
  172. package/dist/config/nodePrefixPlugin.js +38 -0
  173. package/dist/config/progressPlugin.js +50 -24
  174. package/dist/config/purgecssWebpackPlugin.js +41 -30
  175. package/dist/config/speedMeasureWebpackPlugin.js +56 -31
  176. package/dist/config/ssrPlugin.d.ts +11 -0
  177. package/dist/config/ssrPlugin.js +98 -0
  178. package/dist/config/svgRules.d.ts +1 -0
  179. package/dist/config/svgRules.js +68 -41
  180. package/dist/constants.d.ts +4 -0
  181. package/dist/constants.js +59 -15
  182. package/dist/dev.d.ts +23 -2
  183. package/dist/dev.js +198 -81
  184. package/dist/index.d.ts +6 -1
  185. package/dist/index.js +31 -15
  186. package/dist/loader/svgr.d.ts +4 -0
  187. package/dist/loader/svgr.js +84 -0
  188. package/dist/loader/swc.d.ts +4 -0
  189. package/dist/loader/swc.js +149 -0
  190. package/dist/parcelCSS.d.ts +2 -0
  191. package/dist/parcelCSS.js +39 -0
  192. package/dist/plugins/EsbuildMinifyFix.d.ts +8 -0
  193. package/dist/plugins/EsbuildMinifyFix.js +136 -0
  194. package/dist/plugins/ProgressPlugin.js +68 -43
  195. package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
  196. package/dist/plugins/RuntimePublicPathPlugin.js +45 -0
  197. package/dist/plugins/_SamplePlugin.d.ts +1 -1
  198. package/dist/plugins/_SamplePlugin.js +37 -14
  199. package/dist/requireHook.js +44 -27
  200. package/dist/schema.d.ts +4 -3
  201. package/dist/schema.js +175 -69
  202. package/dist/server/server.d.ts +4 -3
  203. package/dist/server/server.js +219 -154
  204. package/dist/server/ws.d.ts +8 -3
  205. package/dist/server/ws.js +72 -38
  206. package/dist/swcPlugins/autoCSSModules.d.ts +11 -2
  207. package/dist/swcPlugins/autoCSSModules.js +60 -32
  208. package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
  209. package/dist/swcPlugins/changeImportFromString.js +32 -0
  210. package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
  211. package/dist/swcPlugins/lockCoreJS.js +56 -0
  212. package/dist/types.d.ts +53 -9
  213. package/dist/types.js +61 -29
  214. package/dist/utils/browsersList.js +31 -8
  215. package/dist/utils/depMatch.js +65 -39
  216. package/dist/utils/formatWebpackMessages.js +119 -91
  217. package/dist/utils/getEsBuildTarget.d.ts +7 -0
  218. package/dist/utils/getEsBuildTarget.js +46 -0
  219. package/dist/utils/pkgUpContainsName.d.ts +1 -0
  220. package/dist/utils/pkgUpContainsName.js +50 -0
  221. package/package.json +76 -68
  222. package/compiled/@svgr/webpack/LICENSE +0 -7
  223. package/compiled/@svgr/webpack/index.js +0 -266
  224. package/compiled/@svgr/webpack/package.json +0 -1
  225. package/compiled/css-loader/api.js +0 -102
  226. package/compiled/css-loader/getUrl.js +0 -29
  227. package/compiled/css-loader/index.js +0 -2
  228. package/compiled/css-loader/noSourceMaps.js +0 -5
  229. package/compiled/css-loader/package.json +0 -1
  230. package/compiled/css-loader/sourceMaps.js +0 -22
  231. package/compiled/express/body-parser/index.d.ts +0 -104
  232. package/compiled/express/connect/index.d.ts +0 -93
  233. package/compiled/express/express-serve-static-core/index.d.ts +0 -1252
  234. package/compiled/express/index.d.ts +0 -133
  235. package/compiled/express/index.js +0 -338
  236. package/compiled/express/mime/index.d.ts +0 -35
  237. package/compiled/express/package.json +0 -1
  238. package/compiled/express/qs/index.d.ts +0 -62
  239. package/compiled/express/range-parser/index.d.ts +0 -35
  240. package/compiled/express/serve-static/index.d.ts +0 -108
  241. package/compiled/http-proxy-middleware/LICENSE +0 -22
  242. package/compiled/http-proxy-middleware/dist/index.d.ts +0 -4
  243. package/compiled/http-proxy-middleware/dist/types.d.ts +0 -54
  244. package/compiled/http-proxy-middleware/http-proxy/index.d.ts +0 -226
  245. package/compiled/http-proxy-middleware/index.js +0 -66
  246. package/compiled/http-proxy-middleware/package.json +0 -1
  247. package/compiled/less/index.js +0 -31
  248. package/compiled/less/package.json +0 -1
  249. package/compiled/react-refresh/index.js +0 -19
  250. package/compiled/swc-loader/LICENSE +0 -25
  251. package/compiled/swc-loader/index.js +0 -1
  252. package/compiled/swc-loader/package.json +0 -1
  253. package/compiled/tapable/index.js +0 -1
  254. package/compiled/tapable/package.json +0 -1
  255. package/compiled/tapable/tapable.d.ts +0 -116
  256. package/dist/client/client.js +0 -239
  257. package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
  258. package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -65
  259. /package/{dist → client}/client/client.d.ts +0 -0
  260. /package/compiled/{css-loader → file-loader}/LICENSE +0 -0
@@ -0,0 +1,191 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/config/detectDeadCode.ts
30
+ var detectDeadCode_exports = {};
31
+ __export(detectDeadCode_exports, {
32
+ default: () => detectDeadCode_default,
33
+ ignores: () => ignores
34
+ });
35
+ module.exports = __toCommonJS(detectDeadCode_exports);
36
+ var import_webpack = require("@umijs/bundler-webpack/compiled/webpack");
37
+ var import_utils = require("@umijs/utils");
38
+ var import_path = __toESM(require("path"));
39
+ var ignores = [
40
+ "**/node_modules/**",
41
+ "**/.umi/**",
42
+ "**/.umi-production/**",
43
+ "**/.umi-test/**",
44
+ "coverage/**",
45
+ "dist/**",
46
+ "config/**",
47
+ "public/**",
48
+ "mock/**"
49
+ ];
50
+ var detectDeadCode = (compilation, options) => {
51
+ const assets = getWebpackAssets(compilation);
52
+ const compiledFilesDictionary = convertFilesToDict(assets);
53
+ const context = options.context;
54
+ if (!options.patterns.length) {
55
+ options.patterns = getDefaultSourcePattern({ cwd: context });
56
+ }
57
+ const includedFiles = options.patterns.map((pattern) => {
58
+ return import_utils.glob.sync(pattern, {
59
+ ignore: [...ignores, ...options.exclude],
60
+ cwd: context,
61
+ absolute: true
62
+ });
63
+ }).flat();
64
+ const unusedFiles = options.detectUnusedFiles ? includedFiles.filter((file) => !compiledFilesDictionary[file]) : [];
65
+ const unusedExportMap = options.detectUnusedExport ? getUnusedExportMap(convertFilesToDict(includedFiles), compilation) : {};
66
+ logUnusedFiles(unusedFiles);
67
+ logUnusedExportMap(unusedExportMap);
68
+ const hasUnusedThings = unusedFiles.length || Object.keys(unusedExportMap).length;
69
+ if (hasUnusedThings && options.failOnHint) {
70
+ process.exit(2);
71
+ }
72
+ };
73
+ var getUnusedExportMap = (includedFileMap, compilation) => {
74
+ const unusedExportMap = {};
75
+ compilation.chunks.forEach((chunk) => {
76
+ compilation.chunkGraph.getChunkModules(chunk).forEach((module2) => {
77
+ outputUnusedExportMap(
78
+ compilation,
79
+ chunk,
80
+ module2,
81
+ includedFileMap,
82
+ unusedExportMap
83
+ );
84
+ });
85
+ });
86
+ return unusedExportMap;
87
+ };
88
+ var outputUnusedExportMap = (compilation, chunk, module2, includedFileMap, unusedExportMap) => {
89
+ if (!(module2 instanceof import_webpack.NormalModule) || !module2.resource) {
90
+ return;
91
+ }
92
+ const path2 = (0, import_utils.winPath)(module2.resource);
93
+ if (!/^((?!(node_modules)).)*$/.test(path2))
94
+ return;
95
+ const providedExports = compilation.chunkGraph.moduleGraph.getProvidedExports(module2);
96
+ const usedExports = compilation.chunkGraph.moduleGraph.getUsedExports(
97
+ module2,
98
+ chunk.runtime
99
+ );
100
+ if (usedExports !== true && providedExports !== true && includedFileMap[path2]) {
101
+ if (usedExports === false) {
102
+ if (providedExports == null ? void 0 : providedExports.length) {
103
+ unusedExportMap[path2] = providedExports;
104
+ }
105
+ } else if (providedExports instanceof Array) {
106
+ const unusedExports = providedExports.filter(
107
+ (item) => usedExports && !usedExports.has(item)
108
+ );
109
+ if (unusedExports.length) {
110
+ unusedExportMap[path2] = unusedExports;
111
+ }
112
+ }
113
+ }
114
+ };
115
+ var logUnusedExportMap = (unusedExportMap) => {
116
+ if (!Object.keys(unusedExportMap).length) {
117
+ return;
118
+ }
119
+ let numberOfUnusedExport = 0;
120
+ let logStr = "";
121
+ Object.keys(unusedExportMap).forEach((filePath, fileIndex) => {
122
+ const unusedExports = unusedExportMap[filePath];
123
+ logStr += [
124
+ `
125
+ ${fileIndex + 1}. `,
126
+ import_utils.chalk.yellow(`${filePath}
127
+ `),
128
+ " >>> ",
129
+ import_utils.chalk.yellow(`${unusedExports.join(", ")}`)
130
+ ].join("");
131
+ numberOfUnusedExport += unusedExports.length;
132
+ });
133
+ console.log(
134
+ import_utils.chalk.yellow.bold("\nWarning:"),
135
+ import_utils.chalk.yellow(
136
+ `There are ${numberOfUnusedExport} unused exports in ${Object.keys(unusedExportMap).length} files:`
137
+ ),
138
+ logStr,
139
+ import_utils.chalk.red.bold("\nPlease be careful if you want to remove them (¬º-°)¬.\n")
140
+ );
141
+ };
142
+ var getWebpackAssets = (compilation) => {
143
+ const outputPath = compilation.getPath(
144
+ compilation.compiler.outputPath
145
+ );
146
+ const assets = [
147
+ ...Array.from(compilation.fileDependencies),
148
+ ...compilation.getAssets().map((asset) => import_path.default.join(outputPath, asset.name))
149
+ ];
150
+ return assets;
151
+ };
152
+ var convertFilesToDict = (assets) => {
153
+ return assets.filter((path2) => !/(node_modules|(\.umi))/.test(path2) && Boolean(path2)).reduce((fileDictionary, file) => {
154
+ const unixFile = (0, import_utils.winPath)(file);
155
+ fileDictionary[unixFile] = true;
156
+ return fileDictionary;
157
+ }, {});
158
+ };
159
+ var logUnusedFiles = (unusedFiles) => {
160
+ if (!(unusedFiles == null ? void 0 : unusedFiles.length)) {
161
+ return;
162
+ }
163
+ console.log(
164
+ import_utils.chalk.yellow.bold("\nWarning:"),
165
+ import_utils.chalk.yellow(`There are ${unusedFiles.length} unused files:`),
166
+ ...unusedFiles.map(
167
+ (file, index) => `
168
+ ${index + 1}. ${import_utils.chalk.yellow(file)}`
169
+ ),
170
+ import_utils.chalk.red.bold("\nPlease be careful if you want to remove them (¬º-°)¬.\n")
171
+ );
172
+ };
173
+ function isDirExist(p) {
174
+ return import_utils.fsExtra.existsSync(p) && import_utils.fsExtra.statSync(p).isDirectory();
175
+ }
176
+ function getDefaultSourcePattern(opts) {
177
+ const { cwd } = opts;
178
+ const srcPath = import_path.default.join(cwd, "src");
179
+ if (isDirExist(srcPath)) {
180
+ return ["src/**/*"];
181
+ }
182
+ const dirs = import_utils.fsExtra.readdirSync(cwd).filter((p) => {
183
+ return !p.startsWith(".") && isDirExist(p);
184
+ });
185
+ return dirs.map((dir) => `${dir}/**/*`);
186
+ }
187
+ var detectDeadCode_default = detectDeadCode;
188
+ // Annotate the CommonJS export names for ESM import in node:
189
+ 0 && (module.exports = {
190
+ ignores
191
+ });
@@ -0,0 +1,9 @@
1
+ import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
2
+ import { Env, IConfig } from '../types';
3
+ interface IOpts {
4
+ userConfig: IConfig;
5
+ config: Config;
6
+ env: Env;
7
+ }
8
+ export declare function addDetectDeadCodePlugin(opts: IOpts): Promise<void>;
9
+ export {};
@@ -0,0 +1,82 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/config/detectDeadCodePlugin.ts
30
+ var detectDeadCodePlugin_exports = {};
31
+ __export(detectDeadCodePlugin_exports, {
32
+ addDetectDeadCodePlugin: () => addDetectDeadCodePlugin
33
+ });
34
+ module.exports = __toCommonJS(detectDeadCodePlugin_exports);
35
+ var import_types = require("../types");
36
+ var import_detectDeadCode = __toESM(require("./detectDeadCode"));
37
+ var defaultOptions = {
38
+ patterns: [],
39
+ exclude: [],
40
+ failOnHint: false,
41
+ detectUnusedFiles: true,
42
+ detectUnusedExport: true
43
+ };
44
+ var DetectDeadCodePlugin = class {
45
+ constructor(options) {
46
+ this.options = defaultOptions;
47
+ this.handleAfterEmit = (compilation, callback) => {
48
+ (0, import_detectDeadCode.default)(compilation, this.options);
49
+ callback();
50
+ };
51
+ if (!options) {
52
+ return;
53
+ }
54
+ this.options = {
55
+ ...this.options,
56
+ ...options
57
+ };
58
+ }
59
+ apply(compiler) {
60
+ if (!this.options.context) {
61
+ this.options = {
62
+ ...this.options,
63
+ context: compiler.context
64
+ };
65
+ }
66
+ compiler.hooks.afterEmit.tapAsync(
67
+ "DetectDeadCodePlugin",
68
+ this.handleAfterEmit
69
+ );
70
+ }
71
+ };
72
+ async function addDetectDeadCodePlugin(opts) {
73
+ const { config, userConfig } = opts;
74
+ const isDev = opts.env === import_types.Env.development;
75
+ if (userConfig.deadCode && !isDev) {
76
+ config.plugin("detect-dead-code-plugin").use(DetectDeadCodePlugin, [userConfig.deadCode]);
77
+ }
78
+ }
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ addDetectDeadCodePlugin
82
+ });
@@ -1,34 +1,49 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
13
18
  };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.addFastRefreshPlugin = void 0;
16
- // @ts-ignore
17
- const lib_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin/lib"));
18
- const constants_1 = require("../constants");
19
- const types_1 = require("../types");
20
- function addFastRefreshPlugin(opts) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const { config, userConfig, name } = opts;
23
- const isDev = opts.env === types_1.Env.development;
24
- const useFastRefresh = isDev && userConfig.fastRefresh !== false && name !== constants_1.MFSU_NAME;
25
- // TODO: Should only run in react csr
26
- if (useFastRefresh) {
27
- config
28
- .plugin('fastRefresh')
29
- .after('hmr')
30
- .use(lib_1.default, [{ overlay: false }]);
31
- }
32
- });
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/config/fastRefreshPlugin.ts
30
+ var fastRefreshPlugin_exports = {};
31
+ __export(fastRefreshPlugin_exports, {
32
+ addFastRefreshPlugin: () => addFastRefreshPlugin
33
+ });
34
+ module.exports = __toCommonJS(fastRefreshPlugin_exports);
35
+ var import_lib = __toESM(require("@umijs/react-refresh-webpack-plugin/lib"));
36
+ var import_constants = require("../constants");
37
+ var import_types = require("../types");
38
+ async function addFastRefreshPlugin(opts) {
39
+ const { config, userConfig, name } = opts;
40
+ const isDev = opts.env === import_types.Env.development;
41
+ const useFastRefresh = isDev && userConfig.fastRefresh !== false && name !== import_constants.MFSU_NAME;
42
+ if (useFastRefresh) {
43
+ config.plugin("fastRefresh").after("hmr").use(import_lib.default, [{ overlay: false }]);
44
+ }
33
45
  }
34
- exports.addFastRefreshPlugin = addFastRefreshPlugin;
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ addFastRefreshPlugin
49
+ });
@@ -0,0 +1,11 @@
1
+ import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
2
+ import { Env, IConfig } from '../types';
3
+ interface IOpts {
4
+ name?: string;
5
+ config: Config;
6
+ userConfig: IConfig;
7
+ cwd: string;
8
+ env: Env;
9
+ }
10
+ export declare function addForkTSCheckerPlugin(opts: IOpts): Promise<void>;
11
+ export {};
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/config/forkTSCheckerPlugin.ts
30
+ var forkTSCheckerPlugin_exports = {};
31
+ __export(forkTSCheckerPlugin_exports, {
32
+ addForkTSCheckerPlugin: () => addForkTSCheckerPlugin
33
+ });
34
+ module.exports = __toCommonJS(forkTSCheckerPlugin_exports);
35
+ var import_fork_ts_checker_webpack_plugin = __toESM(require("fork-ts-checker-webpack-plugin"));
36
+ async function addForkTSCheckerPlugin(opts) {
37
+ var _a;
38
+ const { config, userConfig } = opts;
39
+ if (userConfig.forkTSChecker) {
40
+ if ((_a = userConfig.forkTSChecker.typescript) == null ? void 0 : _a.enable) {
41
+ userConfig.forkTSChecker.typescript.typescriptPath = require.resolve("typescript");
42
+ }
43
+ config.plugin("fork-ts-checker-plugin").use(import_fork_ts_checker_webpack_plugin.default, [userConfig.forkTSChecker]);
44
+ }
45
+ }
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ addForkTSCheckerPlugin
49
+ });
@@ -0,0 +1,6 @@
1
+ import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
2
+ interface IOpts {
3
+ config: Config;
4
+ }
5
+ export declare function addHarmonyLinkingErrorPlugin(opts: IOpts): Promise<void>;
6
+ export {};
@@ -0,0 +1,53 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/config/harmonyLinkingErrorPlugin.ts
20
+ var harmonyLinkingErrorPlugin_exports = {};
21
+ __export(harmonyLinkingErrorPlugin_exports, {
22
+ addHarmonyLinkingErrorPlugin: () => addHarmonyLinkingErrorPlugin
23
+ });
24
+ module.exports = __toCommonJS(harmonyLinkingErrorPlugin_exports);
25
+ var LINKING_ERROR_TAG = "was not found in";
26
+ var CSS_NO_EXPORTS = /\.(css|sass|scss|styl|less)' \(module has no exports\)/;
27
+ var HarmonyLinkingErrorPlugin = class {
28
+ apply(compiler) {
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);
42
+ }
43
+ );
44
+ }
45
+ };
46
+ async function addHarmonyLinkingErrorPlugin(opts) {
47
+ const { config } = opts;
48
+ config.plugin("harmony-linking-error-plugin").use(HarmonyLinkingErrorPlugin);
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ addHarmonyLinkingErrorPlugin
53
+ });
@@ -1,27 +1,40 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
10
8
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.addIgnorePlugin = void 0;
13
- const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
14
- function addIgnorePlugin(opts) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- const { config, userConfig } = opts;
17
- if (userConfig.ignoreMomentLocale) {
18
- config.plugin('ignore-moment-locale').use(webpack_1.IgnorePlugin, [
19
- {
20
- resourceRegExp: /^\.\/locale$/,
21
- contextRegExp: /moment$/,
22
- },
23
- ]);
24
- }
25
- });
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/config/ignorePlugin.ts
20
+ var ignorePlugin_exports = {};
21
+ __export(ignorePlugin_exports, {
22
+ addIgnorePlugin: () => addIgnorePlugin
23
+ });
24
+ module.exports = __toCommonJS(ignorePlugin_exports);
25
+ var import_webpack = require("@umijs/bundler-webpack/compiled/webpack");
26
+ async function addIgnorePlugin(opts) {
27
+ const { config, userConfig } = opts;
28
+ if (userConfig.ignoreMomentLocale) {
29
+ config.plugin("ignore-moment-locale").use(import_webpack.IgnorePlugin, [
30
+ {
31
+ resourceRegExp: /^\.\/locale$/,
32
+ contextRegExp: /moment$/
33
+ }
34
+ ]);
35
+ }
26
36
  }
27
- exports.addIgnorePlugin = addIgnorePlugin;
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ addIgnorePlugin
40
+ });
@@ -7,6 +7,8 @@ interface IOpts {
7
7
  env: Env;
8
8
  extraBabelPlugins: any[];
9
9
  extraBabelPresets: any[];
10
+ extraBabelIncludes: Array<string | RegExp>;
11
+ extraEsbuildLoaderHandler: any[];
10
12
  babelPreset: any;
11
13
  name?: string;
12
14
  }