@umijs/bundler-webpack 4.0.5 → 4.0.8

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 (67) hide show
  1. package/{dist → client}/client/client.d.ts +0 -0
  2. package/client/client/client.js +172 -192
  3. package/client/constants.d.ts +15 -0
  4. package/client/constants.js +28 -19
  5. package/client/utils/formatWebpackMessages.d.ts +12 -0
  6. package/client/utils/formatWebpackMessages.js +68 -86
  7. package/dist/build.d.ts +1 -1
  8. package/dist/build.js +105 -61
  9. package/dist/cli.js +77 -69
  10. package/dist/config/_sampleFeature.js +33 -9
  11. package/dist/config/assetRules.js +45 -36
  12. package/dist/config/bundleAnalyzerPlugin.js +39 -17
  13. package/dist/config/compressPlugin.js +113 -95
  14. package/dist/config/config.d.ts +1 -0
  15. package/dist/config/config.js +204 -215
  16. package/dist/config/copyPlugin.js +58 -33
  17. package/dist/config/cssRules.js +136 -131
  18. package/dist/config/definePlugin.d.ts +1 -0
  19. package/dist/config/definePlugin.js +71 -31
  20. package/dist/config/detectDeadCode.js +120 -108
  21. package/dist/config/detectDeadCodePlugin.js +78 -63
  22. package/dist/config/fastRefreshPlugin.js +39 -20
  23. package/dist/config/forkTSCheckerPlugin.js +38 -19
  24. package/dist/config/harmonyLinkingErrorPlugin.js +48 -29
  25. package/dist/config/ignorePlugin.js +38 -14
  26. package/dist/config/javaScriptRules.js +146 -173
  27. package/dist/config/manifestPlugin.js +51 -15
  28. package/dist/config/miniCSSExtractPlugin.js +42 -22
  29. package/dist/config/nodePolyfill.js +65 -26
  30. package/dist/config/nodePrefixPlugin.js +36 -12
  31. package/dist/config/progressPlugin.js +37 -13
  32. package/dist/config/purgecssWebpackPlugin.js +41 -19
  33. package/dist/config/speedMeasureWebpackPlugin.js +41 -20
  34. package/dist/config/ssrPlugin.js +83 -63
  35. package/dist/config/svgRules.js +74 -46
  36. package/dist/constants.js +57 -22
  37. package/dist/dev.d.ts +1 -1
  38. package/dist/dev.js +170 -129
  39. package/dist/index.d.ts +0 -2
  40. package/dist/index.js +22 -35
  41. package/dist/loader/svgr.js +73 -54
  42. package/dist/loader/swc.js +110 -69
  43. package/dist/parcelCSS.d.ts +2 -0
  44. package/dist/parcelCSS.js +32 -0
  45. package/dist/plugins/ProgressPlugin.js +66 -43
  46. package/dist/plugins/RuntimePublicPathPlugin.js +42 -23
  47. package/dist/plugins/_SamplePlugin.js +39 -14
  48. package/dist/requireHook.js +37 -27
  49. package/dist/schema.js +119 -95
  50. package/dist/server/server.d.ts +0 -1
  51. package/dist/server/server.js +214 -184
  52. package/dist/server/ws.d.ts +0 -2
  53. package/dist/server/ws.js +63 -38
  54. package/dist/swcPlugins/autoCSSModules.js +50 -31
  55. package/dist/swcPlugins/changeImportFromString.js +31 -9
  56. package/dist/swcPlugins/lockCoreJS.js +44 -20
  57. package/dist/types.js +61 -30
  58. package/dist/utils/browsersList.js +31 -8
  59. package/dist/utils/depMatch.js +63 -39
  60. package/dist/utils/formatWebpackMessages.js +93 -91
  61. package/dist/utils/getEsBuildTarget.js +32 -10
  62. package/package.json +9 -11
  63. package/compiled/fork-ts-checker-webpack-plugin/LICENSE +0 -21
  64. package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
  65. package/compiled/fork-ts-checker-webpack-plugin/index.js +0 -42
  66. package/compiled/fork-ts-checker-webpack-plugin/package.json +0 -1
  67. package/dist/client/client.js +0 -245
@@ -1,120 +1,132 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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 });
4
10
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.disabledFolders = void 0;
7
- const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
8
- const utils_1 = require("@umijs/utils");
9
- const path_1 = __importDefault(require("path"));
10
- exports.disabledFolders = [
11
- 'node_modules',
12
- '.umi',
13
- '.umi-production',
14
- 'dist',
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // detectDeadCode.ts
23
+ var detectDeadCode_exports = {};
24
+ __export(detectDeadCode_exports, {
25
+ default: () => detectDeadCode_default,
26
+ disabledFolders: () => disabledFolders
27
+ });
28
+ module.exports = __toCommonJS(detectDeadCode_exports);
29
+ var import_webpack = require("@umijs/bundler-webpack/compiled/webpack");
30
+ var import_utils = require("@umijs/utils");
31
+ var import_path = __toESM(require("path"));
32
+ var disabledFolders = [
33
+ "node_modules",
34
+ ".umi",
35
+ ".umi-production",
36
+ "dist"
15
37
  ];
16
- const detectDeadCode = (compilation, options) => {
17
- const assets = getWebpackAssets(compilation);
18
- const compiledFilesDictionary = convertFilesToDict(assets);
19
- const includedFiles = getPattern(options)
20
- .map((pattern) => utils_1.glob.sync(pattern))
21
- .flat();
22
- const unusedFiles = options.detectUnusedFiles
23
- ? includedFiles.filter((file) => !compiledFilesDictionary[file])
24
- : [];
25
- const unusedExportMap = options.detectUnusedExport
26
- ? getUnusedExportMap(convertFilesToDict(includedFiles), compilation)
27
- : {};
28
- logUnusedFiles(unusedFiles);
29
- logUnusedExportMap(unusedExportMap);
30
- const hasUnusedThings = unusedFiles.length || Object.keys(unusedExportMap).length;
31
- if (hasUnusedThings && options.failOnHint) {
32
- process.exit(2);
33
- }
38
+ var detectDeadCode = (compilation, options) => {
39
+ const assets = getWebpackAssets(compilation);
40
+ const compiledFilesDictionary = convertFilesToDict(assets);
41
+ const includedFiles = getPattern(options).map((pattern) => import_utils.glob.sync(pattern)).flat();
42
+ const unusedFiles = options.detectUnusedFiles ? includedFiles.filter((file) => !compiledFilesDictionary[file]) : [];
43
+ const unusedExportMap = options.detectUnusedExport ? getUnusedExportMap(convertFilesToDict(includedFiles), compilation) : {};
44
+ logUnusedFiles(unusedFiles);
45
+ logUnusedExportMap(unusedExportMap);
46
+ const hasUnusedThings = unusedFiles.length || Object.keys(unusedExportMap).length;
47
+ if (hasUnusedThings && options.failOnHint) {
48
+ process.exit(2);
49
+ }
34
50
  };
35
- const getPattern = (options) => {
36
- return options.patterns
37
- .map((pattern) => path_1.default.resolve(options.context || '', pattern))
38
- .concat(options.exclude.map((pattern) => path_1.default.resolve(options.context || '', `!${pattern}`)))
39
- .map(convertToUnixPath);
51
+ var getPattern = (options) => {
52
+ return options.patterns.map((pattern) => import_path.default.resolve(options.context || "", pattern)).concat(options.exclude.map((pattern) => import_path.default.resolve(options.context || "", `!${pattern}`))).map(convertToUnixPath);
40
53
  };
41
- const getUnusedExportMap = (includedFileMap, compilation) => {
42
- const unusedExportMap = {};
43
- compilation.chunks.forEach((chunk) => {
44
- compilation.chunkGraph.getChunkModules(chunk).forEach((module) => {
45
- outputUnusedExportMap(compilation, chunk, module, includedFileMap, unusedExportMap);
46
- });
54
+ var getUnusedExportMap = (includedFileMap, compilation) => {
55
+ const unusedExportMap = {};
56
+ compilation.chunks.forEach((chunk) => {
57
+ compilation.chunkGraph.getChunkModules(chunk).forEach((module2) => {
58
+ outputUnusedExportMap(compilation, chunk, module2, includedFileMap, unusedExportMap);
47
59
  });
48
- return unusedExportMap;
60
+ });
61
+ return unusedExportMap;
49
62
  };
50
- const outputUnusedExportMap = (compilation, chunk, module, includedFileMap, unusedExportMap) => {
51
- if (!(module instanceof webpack_1.NormalModule) || !module.resource) {
52
- return;
53
- }
54
- const path = convertToUnixPath(module.resource);
55
- if (!/^((?!(node_modules)).)*$/.test(path))
56
- return;
57
- const providedExports = compilation.chunkGraph.moduleGraph.getProvidedExports(module);
58
- const usedExports = compilation.chunkGraph.moduleGraph.getUsedExports(module, chunk.runtime);
59
- if (usedExports !== true &&
60
- providedExports !== true &&
61
- includedFileMap[path]) {
62
- if (usedExports === false) {
63
- if (providedExports === null || providedExports === void 0 ? void 0 : providedExports.length) {
64
- unusedExportMap[path] = providedExports;
65
- }
66
- }
67
- else if (providedExports instanceof Array) {
68
- const unusedExports = providedExports.filter((item) => usedExports && !usedExports.has(item));
69
- if (unusedExports.length) {
70
- unusedExportMap[path] = unusedExports;
71
- }
72
- }
63
+ var outputUnusedExportMap = (compilation, chunk, module2, includedFileMap, unusedExportMap) => {
64
+ if (!(module2 instanceof import_webpack.NormalModule) || !module2.resource) {
65
+ return;
66
+ }
67
+ const path2 = convertToUnixPath(module2.resource);
68
+ if (!/^((?!(node_modules)).)*$/.test(path2))
69
+ return;
70
+ const providedExports = compilation.chunkGraph.moduleGraph.getProvidedExports(module2);
71
+ const usedExports = compilation.chunkGraph.moduleGraph.getUsedExports(module2, chunk.runtime);
72
+ if (usedExports !== true && providedExports !== true && includedFileMap[path2]) {
73
+ if (usedExports === false) {
74
+ if (providedExports == null ? void 0 : providedExports.length) {
75
+ unusedExportMap[path2] = providedExports;
76
+ }
77
+ } else if (providedExports instanceof Array) {
78
+ const unusedExports = providedExports.filter((item) => usedExports && !usedExports.has(item));
79
+ if (unusedExports.length) {
80
+ unusedExportMap[path2] = unusedExports;
81
+ }
73
82
  }
83
+ }
74
84
  };
75
- const logUnusedExportMap = (unusedExportMap) => {
76
- if (!Object.keys(unusedExportMap).length) {
77
- return;
78
- }
79
- let numberOfUnusedExport = 0;
80
- let logStr = '';
81
- Object.keys(unusedExportMap).forEach((filePath, fileIndex) => {
82
- const unusedExports = unusedExportMap[filePath];
83
- logStr += [
84
- `\n${fileIndex + 1}. `,
85
- utils_1.chalk.yellow(`${filePath}\n`),
86
- ' >>> ',
87
- utils_1.chalk.yellow(`${unusedExports.join(', ')}`),
88
- ].join('');
89
- numberOfUnusedExport += unusedExports.length;
90
- });
91
- console.log(utils_1.chalk.yellow.bold('\nWarning:'), utils_1.chalk.yellow(`There are ${numberOfUnusedExport} unused exports in ${Object.keys(unusedExportMap).length} files:`), logStr, utils_1.chalk.red.bold('\nPlease be careful if you want to remove them (¬º-°)¬.\n'));
85
+ var logUnusedExportMap = (unusedExportMap) => {
86
+ if (!Object.keys(unusedExportMap).length) {
87
+ return;
88
+ }
89
+ let numberOfUnusedExport = 0;
90
+ let logStr = "";
91
+ Object.keys(unusedExportMap).forEach((filePath, fileIndex) => {
92
+ const unusedExports = unusedExportMap[filePath];
93
+ logStr += [
94
+ `
95
+ ${fileIndex + 1}. `,
96
+ import_utils.chalk.yellow(`${filePath}
97
+ `),
98
+ " >>> ",
99
+ import_utils.chalk.yellow(`${unusedExports.join(", ")}`)
100
+ ].join("");
101
+ numberOfUnusedExport += unusedExports.length;
102
+ });
103
+ 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"));
92
104
  };
93
- const getWebpackAssets = (compilation) => {
94
- const outputPath = compilation.getPath(compilation.compiler.outputPath);
95
- const assets = [
96
- ...Array.from(compilation.fileDependencies),
97
- ...compilation
98
- .getAssets()
99
- .map((asset) => path_1.default.join(outputPath, asset.name)),
100
- ];
101
- return assets;
105
+ var getWebpackAssets = (compilation) => {
106
+ const outputPath = compilation.getPath(compilation.compiler.outputPath);
107
+ const assets = [
108
+ ...Array.from(compilation.fileDependencies),
109
+ ...compilation.getAssets().map((asset) => import_path.default.join(outputPath, asset.name))
110
+ ];
111
+ return assets;
102
112
  };
103
- const convertFilesToDict = (assets) => {
104
- return assets
105
- .filter((file) => Boolean(file) &&
106
- exports.disabledFolders.every((disabledPath) => !file.includes(disabledPath)))
107
- .reduce((fileDictionary, file) => {
108
- const unixFile = convertToUnixPath(file);
109
- fileDictionary[unixFile] = true;
110
- return fileDictionary;
111
- }, {});
113
+ var convertFilesToDict = (assets) => {
114
+ return assets.filter((file) => Boolean(file) && disabledFolders.every((disabledPath) => !file.includes(disabledPath))).reduce((fileDictionary, file) => {
115
+ const unixFile = convertToUnixPath(file);
116
+ fileDictionary[unixFile] = true;
117
+ return fileDictionary;
118
+ }, {});
112
119
  };
113
- const logUnusedFiles = (unusedFiles) => {
114
- if (!(unusedFiles === null || unusedFiles === void 0 ? void 0 : unusedFiles.length)) {
115
- return;
116
- }
117
- console.log(utils_1.chalk.yellow.bold('\nWarning:'), utils_1.chalk.yellow(`There are ${unusedFiles.length} unused files:`), ...unusedFiles.map((file, index) => `\n${index + 1}. ${utils_1.chalk.yellow(file)}`), utils_1.chalk.red.bold('\nPlease be careful if you want to remove them (¬º-°)¬.\n'));
120
+ var logUnusedFiles = (unusedFiles) => {
121
+ if (!(unusedFiles == null ? void 0 : unusedFiles.length)) {
122
+ return;
123
+ }
124
+ console.log(import_utils.chalk.yellow.bold("\nWarning:"), import_utils.chalk.yellow(`There are ${unusedFiles.length} unused files:`), ...unusedFiles.map((file, index) => `
125
+ ${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"));
118
126
  };
119
- const convertToUnixPath = (path) => path.replace(/\\+/g, '/');
120
- exports.default = detectDeadCode;
127
+ var convertToUnixPath = (path2) => path2.replace(/\\+/g, "/");
128
+ var detectDeadCode_default = detectDeadCode;
129
+ // Annotate the CommonJS export names for ESM import in node:
130
+ 0 && (module.exports = {
131
+ disabledFolders
132
+ });
@@ -1,70 +1,85 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
7
20
  }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
24
27
  };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.addDetectDeadCodePlugin = void 0;
27
- const types_1 = require("../types");
28
- const detectDeadCode_1 = __importStar(require("./detectDeadCode"));
29
- const defaultOptions = {
30
- patterns: [`!(${detectDeadCode_1.disabledFolders.join('|')})/**/*.*`],
31
- exclude: [],
32
- failOnHint: false,
33
- detectUnusedFiles: true,
34
- detectUnusedExport: true,
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
+ }
34
+ return to;
35
+ };
36
+ 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));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+
39
+ // detectDeadCodePlugin.ts
40
+ var detectDeadCodePlugin_exports = {};
41
+ __export(detectDeadCodePlugin_exports, {
42
+ addDetectDeadCodePlugin: () => addDetectDeadCodePlugin
43
+ });
44
+ module.exports = __toCommonJS(detectDeadCodePlugin_exports);
45
+ var import_types = require("../types");
46
+ var import_detectDeadCode = __toESM(require("./detectDeadCode"));
47
+ var defaultOptions = {
48
+ patterns: [`!(${import_detectDeadCode.disabledFolders.join("|")})/**/*.*`],
49
+ exclude: [],
50
+ failOnHint: false,
51
+ detectUnusedFiles: true,
52
+ detectUnusedExport: true
35
53
  };
36
- class DetectDeadCodePlugin {
37
- constructor(options) {
38
- this.options = defaultOptions;
39
- this.handleAfterEmit = (compilation, callback) => {
40
- (0, detectDeadCode_1.default)(compilation, this.options);
41
- callback();
42
- };
43
- if (!options) {
44
- return;
45
- }
46
- this.options = {
47
- ...this.options,
48
- ...options,
49
- };
54
+ var DetectDeadCodePlugin = class {
55
+ constructor(options) {
56
+ this.options = defaultOptions;
57
+ this.handleAfterEmit = (compilation, callback) => {
58
+ (0, import_detectDeadCode.default)(compilation, this.options);
59
+ callback();
60
+ };
61
+ if (!options) {
62
+ return;
50
63
  }
51
- apply(compiler) {
52
- if (!this.options.context) {
53
- this.options = {
54
- ...this.options,
55
- context: compiler.context,
56
- };
57
- }
58
- compiler.hooks.afterEmit.tapAsync('DetectDeadCodePlugin', this.handleAfterEmit);
64
+ this.options = __spreadValues(__spreadValues({}, this.options), options);
65
+ }
66
+ apply(compiler) {
67
+ if (!this.options.context) {
68
+ this.options = __spreadProps(__spreadValues({}, this.options), {
69
+ context: compiler.context
70
+ });
59
71
  }
60
- }
72
+ compiler.hooks.afterEmit.tapAsync("DetectDeadCodePlugin", this.handleAfterEmit);
73
+ }
74
+ };
61
75
  async function addDetectDeadCodePlugin(opts) {
62
- const { config, userConfig } = opts;
63
- const isDev = opts.env === types_1.Env.development;
64
- if (userConfig.deadCode && !isDev) {
65
- config
66
- .plugin('detect-dead-code-plugin')
67
- .use(DetectDeadCodePlugin, [userConfig.deadCode]);
68
- }
76
+ const { config, userConfig } = opts;
77
+ const isDev = opts.env === import_types.Env.development;
78
+ if (userConfig.deadCode && !isDev) {
79
+ config.plugin("detect-dead-code-plugin").use(DetectDeadCodePlugin, [userConfig.deadCode]);
80
+ }
69
81
  }
70
- exports.addDetectDeadCodePlugin = addDetectDeadCodePlugin;
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ addDetectDeadCodePlugin
85
+ });
@@ -1,23 +1,42 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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 });
4
10
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.addFastRefreshPlugin = void 0;
7
- // @ts-ignore
8
- const lib_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin/lib"));
9
- const constants_1 = require("../constants");
10
- const types_1 = require("../types");
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // fastRefreshPlugin.ts
23
+ var fastRefreshPlugin_exports = {};
24
+ __export(fastRefreshPlugin_exports, {
25
+ addFastRefreshPlugin: () => addFastRefreshPlugin
26
+ });
27
+ module.exports = __toCommonJS(fastRefreshPlugin_exports);
28
+ var import_lib = __toESM(require("@pmmmwh/react-refresh-webpack-plugin/lib"));
29
+ var import_constants = require("../constants");
30
+ var import_types = require("../types");
11
31
  async function addFastRefreshPlugin(opts) {
12
- const { config, userConfig, name } = opts;
13
- const isDev = opts.env === types_1.Env.development;
14
- const useFastRefresh = isDev && userConfig.fastRefresh !== false && name !== constants_1.MFSU_NAME;
15
- // TODO: Should only run in react csr
16
- if (useFastRefresh) {
17
- config
18
- .plugin('fastRefresh')
19
- .after('hmr')
20
- .use(lib_1.default, [{ overlay: false }]);
21
- }
32
+ const { config, userConfig, name } = opts;
33
+ const isDev = opts.env === import_types.Env.development;
34
+ const useFastRefresh = isDev && userConfig.fastRefresh !== false && name !== import_constants.MFSU_NAME;
35
+ if (useFastRefresh) {
36
+ config.plugin("fastRefresh").after("hmr").use(import_lib.default, [{ overlay: false }]);
37
+ }
22
38
  }
23
- exports.addFastRefreshPlugin = addFastRefreshPlugin;
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ addFastRefreshPlugin
42
+ });
@@ -1,23 +1,42 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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 });
4
10
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.addForkTSCheckerPlugin = void 0;
7
- // @ts-ignore
8
- const fork_ts_checker_webpack_plugin_1 = __importDefault(require("@umijs/bundler-webpack/compiled/fork-ts-checker-webpack-plugin"));
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // forkTSCheckerPlugin.ts
23
+ var forkTSCheckerPlugin_exports = {};
24
+ __export(forkTSCheckerPlugin_exports, {
25
+ addForkTSCheckerPlugin: () => addForkTSCheckerPlugin
26
+ });
27
+ module.exports = __toCommonJS(forkTSCheckerPlugin_exports);
28
+ var import_fork_ts_checker_webpack_plugin = __toESM(require("fork-ts-checker-webpack-plugin"));
9
29
  async function addForkTSCheckerPlugin(opts) {
10
- var _a;
11
- const { config, userConfig } = opts;
12
- if (userConfig.forkTSChecker) {
13
- // use user's typescript
14
- if ((_a = userConfig.forkTSChecker.typescript) === null || _a === void 0 ? void 0 : _a.enable) {
15
- userConfig.forkTSChecker.typescript.typescriptPath =
16
- require.resolve('typescript');
17
- }
18
- config
19
- .plugin('fork-ts-checker-plugin')
20
- .use(fork_ts_checker_webpack_plugin_1.default, [userConfig.forkTSChecker]);
30
+ var _a;
31
+ const { config, userConfig } = opts;
32
+ if (userConfig.forkTSChecker) {
33
+ if ((_a = userConfig.forkTSChecker.typescript) == null ? void 0 : _a.enable) {
34
+ userConfig.forkTSChecker.typescript.typescriptPath = require.resolve("typescript");
21
35
  }
36
+ config.plugin("fork-ts-checker-plugin").use(import_fork_ts_checker_webpack_plugin.default, [userConfig.forkTSChecker]);
37
+ }
22
38
  }
23
- exports.addForkTSCheckerPlugin = addForkTSCheckerPlugin;
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ addForkTSCheckerPlugin
42
+ });
@@ -1,31 +1,50 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addHarmonyLinkingErrorPlugin = void 0;
4
- // ref: https://github.com/webpack/webpack/blob/ccecc17c01af96edddb931a76e7a3b21ef2969d8/lib/dependencies/HarmonyImportDependency.js#L164
5
- const LINKING_ERROR_TAG = 'was not found in';
6
- // build 时会出现 css modules 的引用警告,但这应该是需要忽略的
7
- const CSS_NO_EXPORTS = /\.(css|sass|scss|styl|less)' \(module has no exports\)/;
8
- class HarmonyLinkingErrorPlugin {
9
- apply(compiler) {
10
- compiler.hooks.afterCompile.tap('HarmonyLinkingErrorPlugin', (compilation) => {
11
- if (!compilation.warnings.length) {
12
- return;
13
- }
14
- const harmonyLinkingErrors = compilation.warnings.filter((w) => {
15
- return (w.name === 'ModuleDependencyWarning' &&
16
- !w.module.resource.includes('node_modules') &&
17
- w.message.includes(LINKING_ERROR_TAG) &&
18
- !CSS_NO_EXPORTS.test(w.message));
19
- });
20
- if (!harmonyLinkingErrors.length) {
21
- return;
22
- }
23
- compilation.errors.push(...harmonyLinkingErrors);
24
- });
25
- }
26
- }
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
+ // 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("HarmonyLinkingErrorPlugin", (compilation) => {
30
+ if (!compilation.warnings.length) {
31
+ return;
32
+ }
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
+ });
41
+ }
42
+ };
27
43
  async function addHarmonyLinkingErrorPlugin(opts) {
28
- const { config } = opts;
29
- config.plugin('harmony-linking-error-plugin').use(HarmonyLinkingErrorPlugin);
44
+ const { config } = opts;
45
+ config.plugin("harmony-linking-error-plugin").use(HarmonyLinkingErrorPlugin);
30
46
  }
31
- exports.addHarmonyLinkingErrorPlugin = addHarmonyLinkingErrorPlugin;
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ addHarmonyLinkingErrorPlugin
50
+ });