@umijs/bundler-webpack 4.0.0-canary.20220718.2 → 4.0.0-canary.20220729.1

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 (154) hide show
  1. package/client/client/client.d.ts +1 -0
  2. package/client/client/client.js +295 -194
  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 -2
  8. package/dist/build.js +105 -68
  9. package/dist/cli.d.ts +0 -1
  10. package/dist/cli.js +77 -69
  11. package/dist/config/_sampleFeature.d.ts +0 -1
  12. package/dist/config/_sampleFeature.js +33 -9
  13. package/dist/config/assetRules.d.ts +0 -1
  14. package/dist/config/assetRules.js +45 -36
  15. package/dist/config/bundleAnalyzerPlugin.d.ts +0 -1
  16. package/dist/config/bundleAnalyzerPlugin.js +39 -17
  17. package/dist/config/compressPlugin.d.ts +0 -1
  18. package/dist/config/compressPlugin.js +113 -95
  19. package/dist/config/config.d.ts +1 -1
  20. package/dist/config/config.js +204 -218
  21. package/dist/config/copyPlugin.d.ts +0 -1
  22. package/dist/config/copyPlugin.js +59 -40
  23. package/dist/config/cssRules.d.ts +0 -1
  24. package/dist/config/cssRules.js +136 -131
  25. package/dist/config/definePlugin.d.ts +0 -1
  26. package/dist/config/definePlugin.js +71 -35
  27. package/dist/config/detectDeadCode.d.ts +0 -1
  28. package/dist/config/detectDeadCode.js +120 -108
  29. package/dist/config/detectDeadCodePlugin.d.ts +0 -1
  30. package/dist/config/detectDeadCodePlugin.js +78 -63
  31. package/dist/config/fastRefreshPlugin.d.ts +0 -1
  32. package/dist/config/fastRefreshPlugin.js +39 -20
  33. package/dist/config/forkTSCheckerPlugin.d.ts +0 -1
  34. package/dist/config/forkTSCheckerPlugin.js +38 -18
  35. package/dist/config/harmonyLinkingErrorPlugin.d.ts +0 -1
  36. package/dist/config/harmonyLinkingErrorPlugin.js +48 -29
  37. package/dist/config/ignorePlugin.d.ts +0 -1
  38. package/dist/config/ignorePlugin.js +38 -14
  39. package/dist/config/javaScriptRules.d.ts +0 -1
  40. package/dist/config/javaScriptRules.js +147 -175
  41. package/dist/config/manifestPlugin.d.ts +0 -1
  42. package/dist/config/manifestPlugin.js +51 -15
  43. package/dist/config/miniCSSExtractPlugin.d.ts +0 -1
  44. package/dist/config/miniCSSExtractPlugin.js +42 -22
  45. package/dist/config/nodePolyfill.d.ts +0 -1
  46. package/dist/config/nodePolyfill.js +65 -26
  47. package/dist/config/nodePrefixPlugin.d.ts +0 -1
  48. package/dist/config/nodePrefixPlugin.js +36 -12
  49. package/dist/config/progressPlugin.d.ts +0 -1
  50. package/dist/config/progressPlugin.js +37 -13
  51. package/dist/config/purgecssWebpackPlugin.d.ts +0 -1
  52. package/dist/config/purgecssWebpackPlugin.js +41 -19
  53. package/dist/config/speedMeasureWebpackPlugin.d.ts +0 -1
  54. package/dist/config/speedMeasureWebpackPlugin.js +41 -20
  55. package/dist/config/ssrPlugin.d.ts +0 -1
  56. package/dist/config/ssrPlugin.js +83 -63
  57. package/dist/config/svgRules.d.ts +0 -1
  58. package/dist/config/svgRules.js +74 -46
  59. package/dist/constants.d.ts +0 -1
  60. package/dist/constants.js +57 -22
  61. package/dist/dev.d.ts +1 -2
  62. package/dist/dev.js +174 -135
  63. package/dist/index.d.ts +0 -1
  64. package/dist/index.js +22 -20
  65. package/dist/loader/svgr.d.ts +0 -1
  66. package/dist/loader/svgr.js +73 -54
  67. package/dist/loader/swc.d.ts +0 -1
  68. package/dist/loader/swc.js +110 -69
  69. package/dist/parcelCSS.d.ts +0 -1
  70. package/dist/parcelCSS.js +31 -27
  71. package/dist/plugins/ProgressPlugin.d.ts +0 -1
  72. package/dist/plugins/ProgressPlugin.js +66 -43
  73. package/dist/plugins/RuntimePublicPathPlugin.d.ts +0 -1
  74. package/dist/plugins/RuntimePublicPathPlugin.js +42 -25
  75. package/dist/plugins/_SamplePlugin.d.ts +0 -1
  76. package/dist/plugins/_SamplePlugin.js +39 -14
  77. package/dist/requireHook.d.ts +0 -1
  78. package/dist/requireHook.js +37 -27
  79. package/dist/schema.d.ts +0 -1
  80. package/dist/schema.js +123 -97
  81. package/dist/server/server.d.ts +0 -2
  82. package/dist/server/server.js +214 -184
  83. package/dist/server/ws.d.ts +0 -3
  84. package/dist/server/ws.js +63 -38
  85. package/dist/swcPlugins/autoCSSModules.d.ts +0 -1
  86. package/dist/swcPlugins/autoCSSModules.js +50 -31
  87. package/dist/swcPlugins/changeImportFromString.d.ts +0 -1
  88. package/dist/swcPlugins/changeImportFromString.js +31 -9
  89. package/dist/swcPlugins/lockCoreJS.d.ts +0 -1
  90. package/dist/swcPlugins/lockCoreJS.js +44 -20
  91. package/dist/types.d.ts +2 -2
  92. package/dist/types.js +61 -30
  93. package/dist/utils/browsersList.d.ts +0 -1
  94. package/dist/utils/browsersList.js +31 -8
  95. package/dist/utils/depMatch.d.ts +0 -1
  96. package/dist/utils/depMatch.js +63 -39
  97. package/dist/utils/formatWebpackMessages.d.ts +0 -1
  98. package/dist/utils/formatWebpackMessages.js +93 -91
  99. package/dist/utils/getEsBuildTarget.d.ts +0 -1
  100. package/dist/utils/getEsBuildTarget.js +32 -10
  101. package/package.json +10 -15
  102. package/compiled/react-refresh/LICENSE +0 -21
  103. package/compiled/react-refresh/index.js +0 -21
  104. package/compiled/react-refresh/package.json +0 -1
  105. package/dist/build.d.ts.map +0 -1
  106. package/dist/cli.d.ts.map +0 -1
  107. package/dist/client/client.d.ts +0 -2
  108. package/dist/client/client.d.ts.map +0 -1
  109. package/dist/client/client.js +0 -245
  110. package/dist/config/_sampleFeature.d.ts.map +0 -1
  111. package/dist/config/assetRules.d.ts.map +0 -1
  112. package/dist/config/bundleAnalyzerPlugin.d.ts.map +0 -1
  113. package/dist/config/compressPlugin.d.ts.map +0 -1
  114. package/dist/config/config.d.ts.map +0 -1
  115. package/dist/config/copyPlugin.d.ts.map +0 -1
  116. package/dist/config/cssRules.d.ts.map +0 -1
  117. package/dist/config/definePlugin.d.ts.map +0 -1
  118. package/dist/config/detectDeadCode.d.ts.map +0 -1
  119. package/dist/config/detectDeadCodePlugin.d.ts.map +0 -1
  120. package/dist/config/fastRefreshPlugin.d.ts.map +0 -1
  121. package/dist/config/forkTSCheckerPlugin.d.ts.map +0 -1
  122. package/dist/config/harmonyLinkingErrorPlugin.d.ts.map +0 -1
  123. package/dist/config/ignorePlugin.d.ts.map +0 -1
  124. package/dist/config/javaScriptRules.d.ts.map +0 -1
  125. package/dist/config/manifestPlugin.d.ts.map +0 -1
  126. package/dist/config/miniCSSExtractPlugin.d.ts.map +0 -1
  127. package/dist/config/nodePolyfill.d.ts.map +0 -1
  128. package/dist/config/nodePrefixPlugin.d.ts.map +0 -1
  129. package/dist/config/progressPlugin.d.ts.map +0 -1
  130. package/dist/config/purgecssWebpackPlugin.d.ts.map +0 -1
  131. package/dist/config/speedMeasureWebpackPlugin.d.ts.map +0 -1
  132. package/dist/config/ssrPlugin.d.ts.map +0 -1
  133. package/dist/config/svgRules.d.ts.map +0 -1
  134. package/dist/constants.d.ts.map +0 -1
  135. package/dist/dev.d.ts.map +0 -1
  136. package/dist/index.d.ts.map +0 -1
  137. package/dist/loader/svgr.d.ts.map +0 -1
  138. package/dist/loader/swc.d.ts.map +0 -1
  139. package/dist/parcelCSS.d.ts.map +0 -1
  140. package/dist/plugins/ProgressPlugin.d.ts.map +0 -1
  141. package/dist/plugins/RuntimePublicPathPlugin.d.ts.map +0 -1
  142. package/dist/plugins/_SamplePlugin.d.ts.map +0 -1
  143. package/dist/requireHook.d.ts.map +0 -1
  144. package/dist/schema.d.ts.map +0 -1
  145. package/dist/server/server.d.ts.map +0 -1
  146. package/dist/server/ws.d.ts.map +0 -1
  147. package/dist/swcPlugins/autoCSSModules.d.ts.map +0 -1
  148. package/dist/swcPlugins/changeImportFromString.d.ts.map +0 -1
  149. package/dist/swcPlugins/lockCoreJS.d.ts.map +0 -1
  150. package/dist/types.d.ts.map +0 -1
  151. package/dist/utils/browsersList.d.ts.map +0 -1
  152. package/dist/utils/depMatch.d.ts.map +0 -1
  153. package/dist/utils/formatWebpackMessages.d.ts.map +0 -1
  154. package/dist/utils/getEsBuildTarget.d.ts.map +0 -1
@@ -1,10 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.changeImportFromString = void 0;
4
- const changeImportFromString = (e, v) => {
5
- e.source.value = v;
6
- // sync change to `raw`
7
- // https://github.com/swc-project/swc/issues/4128
8
- e.source.raw = `'${v}'`;
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 });
9
8
  };
10
- exports.changeImportFromString = changeImportFromString;
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/swcPlugins/changeImportFromString.ts
20
+ var changeImportFromString_exports = {};
21
+ __export(changeImportFromString_exports, {
22
+ changeImportFromString: () => changeImportFromString
23
+ });
24
+ module.exports = __toCommonJS(changeImportFromString_exports);
25
+ var changeImportFromString = (e, v) => {
26
+ e.source.value = v;
27
+ e.source.raw = `'${v}'`;
28
+ };
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ changeImportFromString
32
+ });
@@ -4,4 +4,3 @@ declare class LockCoreJS extends Visitor {
4
4
  visitImportDeclaration(expression: ImportDeclaration): ImportDeclaration;
5
5
  }
6
6
  export default LockCoreJS;
7
- //# sourceMappingURL=lockCoreJS.d.ts.map
@@ -1,24 +1,48 @@
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
- const Visitor_1 = __importDefault(require("@swc/core/Visitor"));
7
- const utils_1 = require("@umijs/utils");
8
- const path_1 = require("path");
9
- const changeImportFromString_1 = require("./changeImportFromString");
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
+ // src/swcPlugins/lockCoreJS.ts
23
+ var lockCoreJS_exports = {};
24
+ __export(lockCoreJS_exports, {
25
+ default: () => lockCoreJS_default
26
+ });
27
+ module.exports = __toCommonJS(lockCoreJS_exports);
28
+ var import_Visitor = __toESM(require("@swc/core/Visitor"));
29
+ var import_utils = require("@umijs/utils");
30
+ var import_path = require("path");
31
+ var import_changeImportFromString = require("./changeImportFromString");
10
32
  function addLastSlash(path) {
11
- return path.endsWith('/') ? path : `${path}/`;
33
+ return path.endsWith("/") ? path : `${path}/`;
12
34
  }
13
- class LockCoreJS extends Visitor_1.default {
14
- visitImportDeclaration(expression) {
15
- const { source } = expression;
16
- let { value, type } = source;
17
- if (type === 'StringLiteral' && value.startsWith('core-js/')) {
18
- const newValue = value.replace(/^core-js\//, addLastSlash((0, utils_1.winPath)((0, path_1.dirname)(require.resolve('core-js/package.json')))));
19
- (0, changeImportFromString_1.changeImportFromString)(expression, newValue);
20
- }
21
- return expression;
35
+ var LockCoreJS = class extends import_Visitor.default {
36
+ visitImportDeclaration(expression) {
37
+ const { source } = expression;
38
+ let { value, type } = source;
39
+ if (type === "StringLiteral" && value.startsWith("core-js/")) {
40
+ const newValue = value.replace(/^core-js\//, addLastSlash((0, import_utils.winPath)((0, import_path.dirname)(require.resolve("core-js/package.json")))));
41
+ (0, import_changeImportFromString.changeImportFromString)(expression, newValue);
22
42
  }
23
- }
24
- exports.default = LockCoreJS;
43
+ return expression;
44
+ }
45
+ };
46
+ var lockCoreJS_default = LockCoreJS;
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {});
package/dist/types.d.ts CHANGED
@@ -75,7 +75,7 @@ export interface IConfig {
75
75
  extraPostCSSPlugins?: any[];
76
76
  hash?: boolean;
77
77
  ignoreMomentLocale?: boolean;
78
- jsMinifier?: JSMinifier;
78
+ jsMinifier?: `${JSMinifier}`;
79
79
  jsMinifierOptions?: {
80
80
  [key: string]: any;
81
81
  };
@@ -110,6 +110,7 @@ export interface IConfig {
110
110
  [key: string]: any;
111
111
  };
112
112
  writeToDisk?: boolean;
113
+ babelLoaderCustomize?: string;
113
114
  [key: string]: any;
114
115
  }
115
116
  export interface SwcOptions extends SwcConfig {
@@ -117,4 +118,3 @@ export interface SwcOptions extends SwcConfig {
117
118
  parseMap?: boolean;
118
119
  }
119
120
  export {};
120
- //# sourceMappingURL=types.d.ts.map
package/dist/types.js CHANGED
@@ -1,30 +1,61 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CSSMinifier = exports.JSMinifier = exports.Transpiler = exports.Env = void 0;
4
- var Env;
5
- (function (Env) {
6
- Env["development"] = "development";
7
- Env["production"] = "production";
8
- })(Env = exports.Env || (exports.Env = {}));
9
- var Transpiler;
10
- (function (Transpiler) {
11
- Transpiler["babel"] = "babel";
12
- Transpiler["swc"] = "swc";
13
- Transpiler["esbuild"] = "esbuild";
14
- Transpiler["none"] = "none";
15
- })(Transpiler = exports.Transpiler || (exports.Transpiler = {}));
16
- var JSMinifier;
17
- (function (JSMinifier) {
18
- JSMinifier["terser"] = "terser";
19
- JSMinifier["swc"] = "swc";
20
- JSMinifier["esbuild"] = "esbuild";
21
- JSMinifier["uglifyJs"] = "uglifyJs";
22
- JSMinifier["none"] = "none";
23
- })(JSMinifier = exports.JSMinifier || (exports.JSMinifier = {}));
24
- var CSSMinifier;
25
- (function (CSSMinifier) {
26
- CSSMinifier["esbuild"] = "esbuild";
27
- CSSMinifier["cssnano"] = "cssnano";
28
- CSSMinifier["parcelCSS"] = "parcelCSS";
29
- CSSMinifier["none"] = "none";
30
- })(CSSMinifier = exports.CSSMinifier || (exports.CSSMinifier = {}));
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/types.ts
20
+ var types_exports = {};
21
+ __export(types_exports, {
22
+ CSSMinifier: () => CSSMinifier,
23
+ Env: () => Env,
24
+ JSMinifier: () => JSMinifier,
25
+ Transpiler: () => Transpiler
26
+ });
27
+ module.exports = __toCommonJS(types_exports);
28
+ var Env = /* @__PURE__ */ ((Env2) => {
29
+ Env2["development"] = "development";
30
+ Env2["production"] = "production";
31
+ return Env2;
32
+ })(Env || {});
33
+ var Transpiler = /* @__PURE__ */ ((Transpiler2) => {
34
+ Transpiler2["babel"] = "babel";
35
+ Transpiler2["swc"] = "swc";
36
+ Transpiler2["esbuild"] = "esbuild";
37
+ Transpiler2["none"] = "none";
38
+ return Transpiler2;
39
+ })(Transpiler || {});
40
+ var JSMinifier = /* @__PURE__ */ ((JSMinifier2) => {
41
+ JSMinifier2["terser"] = "terser";
42
+ JSMinifier2["swc"] = "swc";
43
+ JSMinifier2["esbuild"] = "esbuild";
44
+ JSMinifier2["uglifyJs"] = "uglifyJs";
45
+ JSMinifier2["none"] = "none";
46
+ return JSMinifier2;
47
+ })(JSMinifier || {});
48
+ var CSSMinifier = /* @__PURE__ */ ((CSSMinifier2) => {
49
+ CSSMinifier2["esbuild"] = "esbuild";
50
+ CSSMinifier2["cssnano"] = "cssnano";
51
+ CSSMinifier2["parcelCSS"] = "parcelCSS";
52
+ CSSMinifier2["none"] = "none";
53
+ return CSSMinifier2;
54
+ })(CSSMinifier || {});
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ CSSMinifier,
58
+ Env,
59
+ JSMinifier,
60
+ Transpiler
61
+ });
@@ -3,4 +3,3 @@ interface IOpts {
3
3
  }
4
4
  export declare function getBrowsersList({ targets }: IOpts): any;
5
5
  export {};
6
- //# sourceMappingURL=browsersList.d.ts.map
@@ -1,10 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBrowsersList = void 0;
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/utils/browsersList.ts
20
+ var browsersList_exports = {};
21
+ __export(browsersList_exports, {
22
+ getBrowsersList: () => getBrowsersList
23
+ });
24
+ module.exports = __toCommonJS(browsersList_exports);
4
25
  function getBrowsersList({ targets }) {
5
- return (targets.browsers ||
6
- Object.keys(targets).map((key) => {
7
- return `${key} >= ${targets[key] === true ? '0' : targets[key]}`;
8
- }));
26
+ return targets.browsers || Object.keys(targets).map((key) => {
27
+ return `${key} >= ${targets[key] === true ? "0" : targets[key]}`;
28
+ });
9
29
  }
10
- exports.getBrowsersList = getBrowsersList;
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ getBrowsersList
33
+ });
@@ -4,4 +4,3 @@ export declare function isMatch(opts: {
4
4
  pkgs: Record</*name*/ string, /*version*/ string[]>;
5
5
  }): boolean;
6
6
  export declare function es5ImcompatibleVersionsToPkg(): Record<string, string[]>;
7
- //# sourceMappingURL=depMatch.d.ts.map
@@ -1,46 +1,70 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.es5ImcompatibleVersionsToPkg = exports.isMatch = exports.cleanCache = void 0;
4
- const utils_1 = require("@umijs/utils");
5
- const path_1 = require("path");
6
- const cache = new Map();
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/utils/depMatch.ts
20
+ var depMatch_exports = {};
21
+ __export(depMatch_exports, {
22
+ cleanCache: () => cleanCache,
23
+ es5ImcompatibleVersionsToPkg: () => es5ImcompatibleVersionsToPkg,
24
+ isMatch: () => isMatch
25
+ });
26
+ module.exports = __toCommonJS(depMatch_exports);
27
+ var import_utils = require("@umijs/utils");
28
+ var import_path = require("path");
29
+ var cache = /* @__PURE__ */ new Map();
7
30
  function cleanCache() {
8
- cache.clear();
31
+ cache.clear();
9
32
  }
10
- exports.cleanCache = cleanCache;
11
33
  function isMatch(opts) {
12
- // cache by dir, 命中率会更高
13
- const dir = (0, utils_1.winPath)((0, path_1.dirname)(opts.path));
14
- if (cache.has(dir)) {
15
- return !!cache.get(dir);
16
- }
17
- else {
18
- const pkgPath = utils_1.pkgUp.pkgUpSync({ cwd: opts.path });
19
- let ret;
20
- if (!pkgPath) {
21
- ret = false;
22
- }
23
- else {
24
- const { name, version } = require(pkgPath);
25
- if (opts.pkgs[name]) {
26
- ret = opts.pkgs[name].some((v) => {
27
- return utils_1.semver.satisfies(version, v);
28
- });
29
- }
30
- else {
31
- ret = false;
32
- }
33
- }
34
- cache.set(dir, ret);
35
- return ret;
34
+ const dir = (0, import_utils.winPath)((0, import_path.dirname)(opts.path));
35
+ if (cache.has(dir)) {
36
+ return !!cache.get(dir);
37
+ } else {
38
+ const pkgPath = import_utils.pkgUp.pkgUpSync({ cwd: opts.path });
39
+ let ret;
40
+ if (!pkgPath) {
41
+ ret = false;
42
+ } else {
43
+ const { name, version } = require(pkgPath);
44
+ if (opts.pkgs[name]) {
45
+ ret = opts.pkgs[name].some((v) => {
46
+ return import_utils.semver.satisfies(version, v);
47
+ });
48
+ } else {
49
+ ret = false;
50
+ }
36
51
  }
52
+ cache.set(dir, ret);
53
+ return ret;
54
+ }
37
55
  }
38
- exports.isMatch = isMatch;
39
56
  function es5ImcompatibleVersionsToPkg() {
40
- const { config: { 'es5-imcompatible-versions': config }, } = require('es5-imcompatible-versions/package.json');
41
- return Object.keys(config).reduce((memo, key) => {
42
- memo[key] = /* versions */ Object.keys(config[key]);
43
- return memo;
44
- }, {});
57
+ const {
58
+ config: { "es5-imcompatible-versions": config }
59
+ } = require("es5-imcompatible-versions/package.json");
60
+ return Object.keys(config).reduce((memo, key) => {
61
+ memo[key] = Object.keys(config[key]);
62
+ return memo;
63
+ }, {});
45
64
  }
46
- exports.es5ImcompatibleVersionsToPkg = es5ImcompatibleVersionsToPkg;
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ cleanCache,
68
+ es5ImcompatibleVersionsToPkg,
69
+ isMatch
70
+ });
@@ -10,4 +10,3 @@ export declare function formatWebpackMessages(json: {
10
10
  errors: string[];
11
11
  warnings: string[];
12
12
  };
13
- //# sourceMappingURL=formatWebpackMessages.d.ts.map
@@ -1,100 +1,102 @@
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.formatWebpackMessages = exports.formatMessage = void 0;
7
- const strip_ansi_1 = __importDefault(require("@umijs/utils/compiled/strip-ansi"));
8
- const friendlySyntaxErrorLabel = 'Syntax error:';
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
+ // src/utils/formatWebpackMessages.ts
23
+ var formatWebpackMessages_exports = {};
24
+ __export(formatWebpackMessages_exports, {
25
+ formatMessage: () => formatMessage,
26
+ formatWebpackMessages: () => formatWebpackMessages
27
+ });
28
+ module.exports = __toCommonJS(formatWebpackMessages_exports);
29
+ var import_strip_ansi = __toESM(require("@umijs/utils/compiled/strip-ansi"));
30
+ var friendlySyntaxErrorLabel = "Syntax error:";
9
31
  function isLikelyASyntaxError(message) {
10
- return (0, strip_ansi_1.default)(message).indexOf(friendlySyntaxErrorLabel) !== -1;
32
+ return (0, import_strip_ansi.default)(message).indexOf(friendlySyntaxErrorLabel) !== -1;
11
33
  }
12
34
  function formatMessage(message) {
13
- let lines = [];
14
- if (typeof message === 'string') {
15
- lines = message.split('\n');
16
- }
17
- else if ('message' in message) {
18
- lines = message['message'].split('\n');
19
- }
20
- else if (Array.isArray(message)) {
21
- message.forEach((message) => {
22
- if ('message' in message) {
23
- lines = message['message'].split('\n');
24
- }
25
- });
26
- }
27
- // Strip webpack-added headers off errors/warnings
28
- // https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
29
- lines = lines.filter((line) => !/Module [A-z ]+\(from/.test(line));
30
- // Transform parsing error into syntax error
31
- // TODO: move this to our ESLint formatter?
32
- lines = lines.map((line) => {
33
- const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
34
- if (!parsingError) {
35
- return line;
36
- }
37
- const [, errorLine, errorColumn, errorMessage] = parsingError;
38
- return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
35
+ let lines = [];
36
+ if (typeof message === "string") {
37
+ lines = message.split("\n");
38
+ } else if ("message" in message) {
39
+ lines = message["message"].split("\n");
40
+ } else if (Array.isArray(message)) {
41
+ message.forEach((message2) => {
42
+ if ("message" in message2) {
43
+ lines = message2["message"].split("\n");
44
+ }
39
45
  });
40
- message = lines.join('\n');
41
- // Smoosh syntax errors (commonly found in CSS)
42
- message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, `${friendlySyntaxErrorLabel} $3 ($1:$2)\n`);
43
- // Clean up export errors
44
- message = message.replace(/^.*export '(.+?)' was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$2'.`);
45
- message = message.replace(/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$2' does not contain a default export (imported as '$1').`);
46
- message = message.replace(/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$3' (imported as '$2').`);
47
- lines = message.split('\n');
48
- // Remove leading newline
49
- if (lines.length > 2 && lines[1].trim() === '') {
50
- lines.splice(1, 1);
51
- }
52
- // Clean up file name
53
- lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1');
54
- // Cleans up verbose "module not found" messages for files and packages.
55
- if (lines[1] && lines[1].indexOf('Module not found: ') === 0) {
56
- lines = [
57
- lines[0],
58
- lines[1]
59
- .replace('Error: ', '')
60
- .replace('Module not found: Cannot find file:', 'Cannot find file:'),
61
- ];
46
+ }
47
+ lines = lines.filter((line) => !/Module [A-z ]+\(from/.test(line));
48
+ lines = lines.map((line) => {
49
+ const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
50
+ if (!parsingError) {
51
+ return line;
62
52
  }
63
- // Add helpful message for users trying to use Sass for the first time
64
- if (lines[1] && lines[1].match(/Cannot find module.+sass/)) {
65
- lines[1] = 'To import Sass files, you first need to install sass.\n';
66
- lines[1] +=
67
- 'Run `npm install sass` or `yarn add sass` inside your workspace.';
68
- }
69
- message = lines.join('\n');
70
- // Internal stacks are generally useless so we strip them... with the
71
- // exception of stacks containing `webpack:` because they're normally
72
- // from user code generated by webpack. For more information see
73
- // https://github.com/facebook/create-react-app/pull/1050
74
- message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, ''); // at ... ...:x:y
75
- message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, ''); // at <anonymous>
76
- lines = message.split('\n');
77
- // Remove duplicated newlines
78
- lines = lines.filter((line, index, arr) => index === 0 ||
79
- line.trim() !== '' ||
80
- line.trim() !== arr[index - 1].trim());
81
- // Reassemble the message
82
- message = lines.join('\n');
83
- return message.trim();
53
+ const [, errorLine, errorColumn, errorMessage] = parsingError;
54
+ return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
55
+ });
56
+ message = lines.join("\n");
57
+ message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, `${friendlySyntaxErrorLabel} $3 ($1:$2)
58
+ `);
59
+ message = message.replace(/^.*export '(.+?)' was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$2'.`);
60
+ message = message.replace(/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$2' does not contain a default export (imported as '$1').`);
61
+ message = message.replace(/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$3' (imported as '$2').`);
62
+ lines = message.split("\n");
63
+ if (lines.length > 2 && lines[1].trim() === "") {
64
+ lines.splice(1, 1);
65
+ }
66
+ lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
67
+ if (lines[1] && lines[1].indexOf("Module not found: ") === 0) {
68
+ lines = [
69
+ lines[0],
70
+ lines[1].replace("Error: ", "").replace("Module not found: Cannot find file:", "Cannot find file:")
71
+ ];
72
+ }
73
+ if (lines[1] && lines[1].match(/Cannot find module.+sass/)) {
74
+ lines[1] = "To import Sass files, you first need to install sass.\n";
75
+ lines[1] += "Run `npm install sass` or `yarn add sass` inside your workspace.";
76
+ }
77
+ message = lines.join("\n");
78
+ message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, "");
79
+ message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "");
80
+ lines = message.split("\n");
81
+ lines = lines.filter((line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim());
82
+ message = lines.join("\n");
83
+ return message.trim();
84
84
  }
85
- exports.formatMessage = formatMessage;
86
85
  function formatWebpackMessages(json) {
87
- const formattedErrors = json.errors.map(function (message) {
88
- return formatMessage(message);
89
- });
90
- const formattedWarnings = json.warnings.map(function (message) {
91
- return formatMessage(message);
92
- });
93
- const result = { errors: formattedErrors, warnings: formattedWarnings };
94
- if (result.errors.some(isLikelyASyntaxError)) {
95
- // If there are any syntax errors, show just them.
96
- result.errors = result.errors.filter(isLikelyASyntaxError);
97
- }
98
- return result;
86
+ const formattedErrors = json.errors.map(function(message) {
87
+ return formatMessage(message);
88
+ });
89
+ const formattedWarnings = json.warnings.map(function(message) {
90
+ return formatMessage(message);
91
+ });
92
+ const result = { errors: formattedErrors, warnings: formattedWarnings };
93
+ if (result.errors.some(isLikelyASyntaxError)) {
94
+ result.errors = result.errors.filter(isLikelyASyntaxError);
95
+ }
96
+ return result;
99
97
  }
100
- exports.formatWebpackMessages = formatWebpackMessages;
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ formatMessage,
101
+ formatWebpackMessages
102
+ });
@@ -3,4 +3,3 @@ interface IOpts {
3
3
  }
4
4
  export declare function getEsBuildTarget({ targets }: IOpts): string[];
5
5
  export {};
6
- //# sourceMappingURL=getEsBuildTarget.d.ts.map