@umijs/bundler-webpack 4.2.6-alpha.6 → 4.2.6-alpha.7

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 (101) hide show
  1. package/dist/build.d.ts +22 -0
  2. package/dist/build.js +151 -0
  3. package/dist/cli.d.ts +1 -0
  4. package/dist/cli.js +96 -0
  5. package/dist/config/_sampleFeature.d.ts +10 -0
  6. package/dist/config/_sampleFeature.js +35 -0
  7. package/dist/config/assetRules.d.ts +11 -0
  8. package/dist/config/assetRules.js +48 -0
  9. package/dist/config/bundleAnalyzerPlugin.d.ts +10 -0
  10. package/dist/config/bundleAnalyzerPlugin.js +43 -0
  11. package/dist/config/compressPlugin.d.ts +10 -0
  12. package/dist/config/compressPlugin.js +128 -0
  13. package/dist/config/config.d.ts +31 -0
  14. package/dist/config/config.js +243 -0
  15. package/dist/config/copyPlugin.d.ts +10 -0
  16. package/dist/config/copyPlugin.js +63 -0
  17. package/dist/config/cssRules.d.ts +11 -0
  18. package/dist/config/cssRules.js +165 -0
  19. package/dist/config/definePlugin.d.ts +16 -0
  20. package/dist/config/definePlugin.js +80 -0
  21. package/dist/config/detectCssModulesInDependence.d.ts +10 -0
  22. package/dist/config/detectCssModulesInDependence.js +151 -0
  23. package/dist/config/detectDeadCode.d.ts +12 -0
  24. package/dist/config/detectDeadCode.js +191 -0
  25. package/dist/config/detectDeadCodePlugin.d.ts +9 -0
  26. package/dist/config/detectDeadCodePlugin.js +82 -0
  27. package/dist/config/fastRefreshPlugin.d.ts +12 -0
  28. package/dist/config/fastRefreshPlugin.js +49 -0
  29. package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
  30. package/dist/config/forkTSCheckerPlugin.js +49 -0
  31. package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
  32. package/dist/config/harmonyLinkingErrorPlugin.js +53 -0
  33. package/dist/config/ignorePlugin.d.ts +10 -0
  34. package/dist/config/ignorePlugin.js +40 -0
  35. package/dist/config/javaScriptRules.d.ts +16 -0
  36. package/dist/config/javaScriptRules.js +191 -0
  37. package/dist/config/manifestPlugin.d.ts +11 -0
  38. package/dist/config/manifestPlugin.js +40 -0
  39. package/dist/config/miniCSSExtractPlugin.d.ts +11 -0
  40. package/dist/config/miniCSSExtractPlugin.js +55 -0
  41. package/dist/config/nodePolyfill.d.ts +10 -0
  42. package/dist/config/nodePolyfill.js +51 -0
  43. package/dist/config/nodePrefixPlugin.d.ts +11 -0
  44. package/dist/config/nodePrefixPlugin.js +38 -0
  45. package/dist/config/progressPlugin.d.ts +11 -0
  46. package/dist/config/progressPlugin.js +53 -0
  47. package/dist/config/purgecssWebpackPlugin.d.ts +10 -0
  48. package/dist/config/purgecssWebpackPlugin.js +43 -0
  49. package/dist/config/speedMeasureWebpackPlugin.d.ts +6 -0
  50. package/dist/config/speedMeasureWebpackPlugin.js +59 -0
  51. package/dist/config/ssrPlugin.d.ts +11 -0
  52. package/dist/config/ssrPlugin.js +98 -0
  53. package/dist/config/svgRules.d.ts +12 -0
  54. package/dist/config/svgRules.js +70 -0
  55. package/dist/constants.d.ts +15 -0
  56. package/dist/constants.js +59 -0
  57. package/dist/dev.d.ts +40 -0
  58. package/dist/dev.js +208 -0
  59. package/dist/index.d.ts +10 -0
  60. package/dist/index.js +32 -0
  61. package/dist/loader/svgr.d.ts +4 -0
  62. package/dist/loader/svgr.js +84 -0
  63. package/dist/loader/swc.d.ts +4 -0
  64. package/dist/loader/swc.js +149 -0
  65. package/dist/parcelCSS.d.ts +2 -0
  66. package/dist/parcelCSS.js +39 -0
  67. package/dist/plugins/EsbuildMinifyFix.d.ts +8 -0
  68. package/dist/plugins/EsbuildMinifyFix.js +136 -0
  69. package/dist/plugins/ProgressPlugin.d.ts +15 -0
  70. package/dist/plugins/ProgressPlugin.js +69 -0
  71. package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
  72. package/dist/plugins/RuntimePublicPathPlugin.js +45 -0
  73. package/dist/plugins/_SamplePlugin.d.ts +9 -0
  74. package/dist/plugins/_SamplePlugin.js +37 -0
  75. package/dist/requireHook.d.ts +1 -0
  76. package/dist/requireHook.js +49 -0
  77. package/dist/schema.d.ts +4 -0
  78. package/dist/schema.js +178 -0
  79. package/dist/server/server.d.ts +17 -0
  80. package/dist/server/server.js +223 -0
  81. package/dist/server/ws.d.ts +13 -0
  82. package/dist/server/ws.js +76 -0
  83. package/dist/swcPlugins/autoCSSModules.d.ts +17 -0
  84. package/dist/swcPlugins/autoCSSModules.js +63 -0
  85. package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
  86. package/dist/swcPlugins/changeImportFromString.js +32 -0
  87. package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
  88. package/dist/swcPlugins/lockCoreJS.js +56 -0
  89. package/dist/types.d.ts +144 -0
  90. package/dist/types.js +61 -0
  91. package/dist/utils/browsersList.d.ts +5 -0
  92. package/dist/utils/browsersList.js +33 -0
  93. package/dist/utils/depMatch.d.ts +6 -0
  94. package/dist/utils/depMatch.js +72 -0
  95. package/dist/utils/formatWebpackMessages.d.ts +12 -0
  96. package/dist/utils/formatWebpackMessages.js +128 -0
  97. package/dist/utils/getEsBuildTarget.d.ts +7 -0
  98. package/dist/utils/getEsBuildTarget.js +46 -0
  99. package/dist/utils/pkgUpContainsName.d.ts +1 -0
  100. package/dist/utils/pkgUpContainsName.js +50 -0
  101. package/package.json +5 -5
@@ -0,0 +1,151 @@
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/detectCssModulesInDependence.ts
20
+ var detectCssModulesInDependence_exports = {};
21
+ __export(detectCssModulesInDependence_exports, {
22
+ addDependenceCssModulesDetector: () => addDependenceCssModulesDetector
23
+ });
24
+ module.exports = __toCommonJS(detectCssModulesInDependence_exports);
25
+ var import_utils = require("@umijs/utils");
26
+ var import_path = require("path");
27
+ async function addDependenceCssModulesDetector(opts) {
28
+ const { config, cwd, userConfig } = opts;
29
+ if (!userConfig.checkDepCssModules)
30
+ return;
31
+ const matchers = opts.extraBabelIncludes.map(function(p) {
32
+ if (import_utils.lodash.isRegExp(p)) {
33
+ return p;
34
+ }
35
+ let absPath;
36
+ if ((0, import_path.isAbsolute)(p)) {
37
+ absPath = p;
38
+ }
39
+ try {
40
+ if (p.startsWith("./")) {
41
+ absPath = require.resolve(p, { paths: [cwd] });
42
+ }
43
+ absPath = (0, import_path.dirname)(
44
+ import_utils.resolve.sync(`${p}/package.json`, {
45
+ basedir: cwd,
46
+ // same behavior as webpack, to ensure `include` paths matched
47
+ // ref: https://webpack.js.org/configuration/resolve/#resolvesymlinks
48
+ preserveSymlinks: false
49
+ })
50
+ );
51
+ return toRegExp(absPath);
52
+ } catch (e) {
53
+ if (e.code === "MODULE_NOT_FOUND") {
54
+ throw new Error("Cannot resolve extraBabelIncludes: " + p, {
55
+ cause: e
56
+ });
57
+ }
58
+ throw e;
59
+ }
60
+ });
61
+ config.plugin("dep-css-modules-detector").use(DetectCSsModulePlugin, [matchers]);
62
+ }
63
+ var _DetectCSsModulePlugin = class {
64
+ constructor(skipMatcher = []) {
65
+ this.skipMatcher = skipMatcher;
66
+ }
67
+ isCallRequireStyle(statement) {
68
+ if (
69
+ // var x= require(...) ?
70
+ statement.type === "CallExpression" && statement.callee.type === "Identifier" && statement.callee.name === "require" && // var x = require('xxxxx')
71
+ statement.arguments.length === 1 && statement.arguments[0].type === "Literal"
72
+ ) {
73
+ const requireArg = statement.arguments[0].value;
74
+ if (requireArg.endsWith(".less") || requireArg.endsWith(".css")) {
75
+ return true;
76
+ }
77
+ }
78
+ return false;
79
+ }
80
+ apply(compiler) {
81
+ compiler.hooks.normalModuleFactory.tap(
82
+ _DetectCSsModulePlugin.PLUGIN_NAME,
83
+ (factory) => {
84
+ factory.hooks.parser.for("javascript/auto").tap("lessDetector", (parser) => {
85
+ parser.hooks.import.tap(
86
+ "lessDetector",
87
+ (statement, source) => {
88
+ var _a, _b;
89
+ const specifiers = statement.specifiers.length;
90
+ if (specifiers > 0 && (source.endsWith(".less") || source.endsWith(".css")) && this.isJSModule(parser)) {
91
+ this.throwError((_b = (_a = parser.state) == null ? void 0 : _a.module) == null ? void 0 : _b.resource, compiler);
92
+ }
93
+ }
94
+ );
95
+ parser.hooks.program.tap(
96
+ _DetectCSsModulePlugin.PLUGIN_NAME,
97
+ (program) => {
98
+ var _a, _b, _c, _d;
99
+ if (this.isJSModule(parser)) {
100
+ for (const statement of program.body) {
101
+ if (statement.type === "AssignmentExpression" && // x= require("x.less") or var x = require(".css") ?
102
+ this.isCallRequireStyle(statement.right)) {
103
+ this.throwError((_b = (_a = parser.state) == null ? void 0 : _a.module) == null ? void 0 : _b.resource, compiler);
104
+ }
105
+ if (statement.type === "VariableDeclarator" && // var x= require("x.less") or var x = require(".css") ?
106
+ this.isCallRequireStyle(statement.init)) {
107
+ this.throwError((_d = (_c = parser.state) == null ? void 0 : _c.module) == null ? void 0 : _d.resource, compiler);
108
+ }
109
+ }
110
+ }
111
+ }
112
+ );
113
+ });
114
+ }
115
+ );
116
+ }
117
+ isJSModule(parser) {
118
+ var _a, _b;
119
+ let res = (_b = (_a = parser.state) == null ? void 0 : _a.module) == null ? void 0 : _b.resource;
120
+ if (res) {
121
+ if (this.skipMatcher.some((r) => r.test(res))) {
122
+ return false;
123
+ }
124
+ return res.indexOf("node_modules") >= 0 && (res.endsWith(".js") || res.endsWith(".jsx"));
125
+ }
126
+ return false;
127
+ }
128
+ throwError(file, c) {
129
+ const logger = c.getInfrastructureLogger(_DetectCSsModulePlugin.PLUGIN_NAME) || console;
130
+ logger.error(import_utils.chalk.red(`Dependence file ${file} contains css module`));
131
+ logger.error(
132
+ import_utils.chalk.red(
133
+ `Please add the package's name in 'babelExtraIncludes' or use non-css module in dependence`
134
+ )
135
+ );
136
+ throw Error(_DetectCSsModulePlugin.ERROR_NAME);
137
+ }
138
+ };
139
+ var DetectCSsModulePlugin = _DetectCSsModulePlugin;
140
+ DetectCSsModulePlugin.PLUGIN_NAME = "depCssModulesDetector";
141
+ DetectCSsModulePlugin.ERROR_NAME = "USE CSS-MODULES IN NODE_MODULES";
142
+ var toRegExp = (test) => {
143
+ if (typeof test === "string") {
144
+ return new RegExp("^" + test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
145
+ }
146
+ return test;
147
+ };
148
+ // Annotate the CommonJS export names for ESM import in node:
149
+ 0 && (module.exports = {
150
+ addDependenceCssModulesDetector
151
+ });
@@ -0,0 +1,12 @@
1
+ import { Compilation } from '@umijs/bundler-webpack/compiled/webpack';
2
+ import { DeadCodeParams } from '../types';
3
+ export interface Options extends DeadCodeParams {
4
+ patterns: string[];
5
+ exclude: string[];
6
+ failOnHint: boolean;
7
+ detectUnusedFiles: boolean;
8
+ detectUnusedExport: boolean;
9
+ }
10
+ export declare const ignores: string[];
11
+ declare const detectDeadCode: (compilation: Compilation, options: Options) => void;
12
+ export default detectDeadCode;
@@ -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
+ });
@@ -0,0 +1,12 @@
1
+ import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
2
+ import { Env, IConfig } from '../types';
3
+ interface IOpts {
4
+ config: Config;
5
+ userConfig: IConfig;
6
+ cwd: string;
7
+ env: Env;
8
+ browsers: any;
9
+ name?: string;
10
+ }
11
+ export declare function addFastRefreshPlugin(opts: IOpts): Promise<void>;
12
+ 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/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
+ }
45
+ }
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
+ });
@@ -0,0 +1,10 @@
1
+ import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
2
+ import { Env, IConfig } from '../types';
3
+ interface IOpts {
4
+ config: Config;
5
+ userConfig: IConfig;
6
+ cwd: string;
7
+ env: Env;
8
+ }
9
+ export declare function addIgnorePlugin(opts: IOpts): Promise<void>;
10
+ export {};