@modern-js/utils 2.15.1-alpha.0 → 2.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/FileSizeReporter.js +69 -92
  3. package/dist/cjs/alias.js +34 -58
  4. package/dist/cjs/analyzeProject.js +58 -41
  5. package/dist/cjs/applyOptionsChain.js +15 -42
  6. package/dist/cjs/babel.js +28 -39
  7. package/dist/cjs/chainId.js +7 -25
  8. package/dist/cjs/clearConsole.js +7 -25
  9. package/dist/cjs/commands.js +14 -29
  10. package/dist/cjs/compatRequire.js +22 -38
  11. package/dist/cjs/compiled.js +120 -139
  12. package/dist/cjs/constants.js +143 -98
  13. package/dist/cjs/debug.js +8 -26
  14. package/dist/cjs/emptyDir.js +10 -28
  15. package/dist/cjs/ensureAbsolutePath.js +13 -36
  16. package/dist/cjs/ensureArray.js +10 -26
  17. package/dist/cjs/findExists.js +14 -37
  18. package/dist/cjs/generateMetaTags.js +12 -31
  19. package/dist/cjs/getBrowserslist.js +20 -27
  20. package/dist/cjs/getCoreJsVersion.js +49 -37
  21. package/dist/cjs/getEntryOptions.js +14 -29
  22. package/dist/cjs/getPackageManager.js +23 -46
  23. package/dist/cjs/getPort.js +26 -61
  24. package/dist/cjs/getServerConfig.js +51 -43
  25. package/dist/cjs/getTargetDir.js +50 -38
  26. package/dist/cjs/import.js +16 -27
  27. package/dist/cjs/index.js +61 -60
  28. package/dist/cjs/is/index.js +53 -68
  29. package/dist/cjs/is/nodeEnv.js +13 -29
  30. package/dist/cjs/is/platform.js +13 -26
  31. package/dist/cjs/is/type.js +14 -33
  32. package/dist/cjs/logger.js +54 -50
  33. package/dist/cjs/monorepo.js +47 -78
  34. package/dist/cjs/nodeEnv.js +29 -31
  35. package/dist/cjs/path.js +42 -63
  36. package/dist/cjs/pathSerializer.js +43 -51
  37. package/dist/cjs/plugin.js +11 -29
  38. package/dist/cjs/prettyInstructions.js +35 -68
  39. package/dist/cjs/printBuildError.js +15 -37
  40. package/dist/cjs/react.js +18 -41
  41. package/dist/cjs/readTsConfig.js +21 -39
  42. package/dist/cjs/removeSlash.js +13 -27
  43. package/dist/cjs/resolve.js +25 -31
  44. package/dist/cjs/routes.js +22 -42
  45. package/dist/cjs/runtime/index.js +18 -17
  46. package/dist/cjs/runtime/parsed.js +8 -26
  47. package/dist/cjs/runtimeExports.js +31 -56
  48. package/dist/cjs/ssr.js +13 -26
  49. package/dist/cjs/storage.js +51 -41
  50. package/dist/cjs/testUtils.js +8 -29
  51. package/dist/cjs/types.js +4 -15
  52. package/dist/cjs/universal/constants.js +13 -26
  53. package/dist/cjs/universal/formatWebpack.js +16 -44
  54. package/dist/cjs/universal/nestedRoutes.js +94 -46
  55. package/dist/cjs/universal/pluginDagSort.js +58 -0
  56. package/dist/cjs/universal/remixRouter.js +18 -17
  57. package/dist/cjs/universal/serialize.js +16 -37
  58. package/dist/cjs/version.js +25 -41
  59. package/dist/cjs/wait.js +7 -25
  60. package/dist/cjs/watch.js +69 -43
  61. package/dist/esm/FileSizeReporter.js +40 -52
  62. package/dist/esm/alias.js +9 -19
  63. package/dist/esm/analyzeProject.js +3 -7
  64. package/dist/esm/applyOptionsChain.js +5 -17
  65. package/dist/esm/babel.js +6 -8
  66. package/dist/esm/chainId.js +1 -4
  67. package/dist/esm/clearConsole.js +1 -4
  68. package/dist/esm/commands.js +6 -12
  69. package/dist/esm/compatRequire.js +10 -17
  70. package/dist/esm/compiled.js +32 -76
  71. package/dist/esm/constants.js +143 -89
  72. package/dist/esm/debug.js +1 -4
  73. package/dist/esm/emptyDir.js +1 -4
  74. package/dist/esm/ensureAbsolutePath.js +1 -4
  75. package/dist/esm/ensureArray.js +4 -5
  76. package/dist/esm/findExists.js +1 -4
  77. package/dist/esm/generateMetaTags.js +6 -10
  78. package/dist/esm/getBrowserslist.js +8 -6
  79. package/dist/esm/getCoreJsVersion.js +1 -4
  80. package/dist/esm/getEntryOptions.js +5 -5
  81. package/dist/esm/getPackageManager.js +1 -4
  82. package/dist/esm/getPort.js +10 -25
  83. package/dist/esm/getServerConfig.js +2 -9
  84. package/dist/esm/getTargetDir.js +1 -4
  85. package/dist/esm/import.js +3 -4
  86. package/dist/esm/is/index.js +18 -30
  87. package/dist/esm/is/nodeEnv.js +5 -12
  88. package/dist/esm/is/platform.js +2 -6
  89. package/dist/esm/is/type.js +8 -18
  90. package/dist/esm/logger.js +37 -17
  91. package/dist/esm/monorepo.js +21 -38
  92. package/dist/esm/nodeEnv.js +18 -11
  93. package/dist/esm/path.js +16 -23
  94. package/dist/esm/pathSerializer.js +21 -21
  95. package/dist/esm/plugin.js +1 -4
  96. package/dist/esm/prettyInstructions.js +13 -32
  97. package/dist/esm/printBuildError.js +4 -11
  98. package/dist/esm/react.js +1 -4
  99. package/dist/esm/readTsConfig.js +2 -6
  100. package/dist/esm/removeSlash.js +3 -8
  101. package/dist/esm/resolve.js +14 -11
  102. package/dist/esm/routes.js +3 -9
  103. package/dist/esm/runtime/parsed.js +2 -5
  104. package/dist/esm/runtimeExports.js +17 -22
  105. package/dist/esm/ssr.js +1 -4
  106. package/dist/esm/storage.js +2 -6
  107. package/dist/esm/testUtils.js +2 -8
  108. package/dist/esm/types.js +1 -0
  109. package/dist/esm/universal/constants.js +2 -6
  110. package/dist/esm/universal/formatWebpack.js +10 -22
  111. package/dist/esm/universal/nestedRoutes.js +41 -27
  112. package/dist/esm/universal/pluginDagSort.js +50 -0
  113. package/dist/esm/universal/serialize.js +4 -5
  114. package/dist/esm/version.js +5 -7
  115. package/dist/esm/wait.js +1 -3
  116. package/dist/esm/watch.js +14 -9
  117. package/dist/types/universal/pluginDagSort.d.ts +1 -0
  118. package/package.json +17 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @modern-js/utils
2
2
 
3
+ ## 2.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7596520: feat(builder): builder plugin supports specifying relative order via the `pre` / `post` configuration items
8
+
9
+ feat(builder): builder 插件支持通过 `pre` / `post` 配置项指定相对顺序
10
+
11
+ ### Patch Changes
12
+
13
+ - 5954330: fix: route id should not include [ or ]
14
+ fix: 路由 id 不应该包含 [ 或 ]
15
+ - 4e876ab: chore: package.json include the monorepo-relative directory
16
+
17
+ chore: 在 package.json 中声明 monorepo 的子路径
18
+
3
19
  ## 2.15.0
4
20
 
5
21
  ## 2.14.0
@@ -1,90 +1,67 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
9
6
  for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var FileSizeReporter_exports = {};
30
- __export(FileSizeReporter_exports, {
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
31
13
  measureFileSizesBeforeBuild: () => measureFileSizesBeforeBuild,
32
14
  printFileSizesAfterBuild: () => printFileSizesAfterBuild
33
15
  });
34
- module.exports = __toCommonJS(FileSizeReporter_exports);
35
- var import_fs = __toESM(require("fs"));
36
- var import_path = __toESM(require("path"));
37
- var import_compiled = require("./compiled");
38
- var import_logger = require("./logger");
16
+ const _fs = /* @__PURE__ */ _interop_require_default(require("fs"));
17
+ const _path = /* @__PURE__ */ _interop_require_default(require("path"));
18
+ const _compiled = require("./compiled");
19
+ const _logger = require("./logger");
20
+ function _interop_require_default(obj) {
21
+ return obj && obj.__esModule ? obj : {
22
+ default: obj
23
+ };
24
+ }
39
25
  function canReadAsset(asset) {
40
26
  return /\.(js|css)$/.test(asset) && !/service-worker\.js/.test(asset) && !/precache-manifest\.[0-9a-f]+\.js/.test(asset);
41
27
  }
42
28
  function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, maxBundleGzipSize, maxChunkGzipSize) {
43
29
  var root = previousSizeMap.root;
44
30
  var sizes = previousSizeMap.sizes;
45
- var assets = (webpackStats.stats || [webpackStats]).map(
46
- (stats) => stats.toJson({ all: false, assets: true }).assets.filter((asset) => canReadAsset(asset.name)).map((asset) => {
47
- var fileContents = import_fs.default.readFileSync(import_path.default.join(root, asset.name));
48
- var size = fileContents.length;
49
- var gzippedSize = import_compiled.gzipSize.sync(fileContents);
50
- var [previousSize, previousGzipSize] = sizes[removeFileNameHash(root, asset.name)] || [];
51
- var sizeDifference = getDifferenceLabel(size, previousSize);
52
- var gzipSizeDifference = getDifferenceLabel(
53
- gzippedSize,
54
- previousGzipSize
55
- );
56
- return {
57
- folder: import_path.default.join(
58
- import_path.default.basename(buildFolder),
59
- import_path.default.dirname(asset.name)
60
- ),
61
- name: import_path.default.basename(asset.name),
62
- gzippedSize,
63
- sizeLabel: (0, import_compiled.filesize)(size) + (sizeDifference ? " (" + sizeDifference + ")" : ""),
64
- gzipSizeLabel: (0, import_compiled.filesize)(gzippedSize) + (gzipSizeDifference ? " (" + gzipSizeDifference + ")" : "")
65
- };
66
- })
67
- ).reduce((single, all) => all.concat(single), []);
31
+ var assets = (webpackStats.stats || [
32
+ webpackStats
33
+ ]).map((stats) => stats.toJson({
34
+ all: false,
35
+ assets: true
36
+ }).assets.filter((asset) => canReadAsset(asset.name)).map((asset) => {
37
+ var fileContents = _fs.default.readFileSync(_path.default.join(root, asset.name));
38
+ var size = fileContents.length;
39
+ var gzippedSize = _compiled.gzipSize.sync(fileContents);
40
+ var [previousSize, previousGzipSize] = sizes[removeFileNameHash(root, asset.name)] || [];
41
+ var sizeDifference = getDifferenceLabel(size, previousSize);
42
+ var gzipSizeDifference = getDifferenceLabel(gzippedSize, previousGzipSize);
43
+ return {
44
+ folder: _path.default.join(_path.default.basename(buildFolder), _path.default.dirname(asset.name)),
45
+ name: _path.default.basename(asset.name),
46
+ gzippedSize,
47
+ sizeLabel: (0, _compiled.filesize)(size) + (sizeDifference ? " (" + sizeDifference + ")" : ""),
48
+ gzipSizeLabel: (0, _compiled.filesize)(gzippedSize) + (gzipSizeDifference ? " (" + gzipSizeDifference + ")" : "")
49
+ };
50
+ })).reduce((single, all) => all.concat(single), []);
68
51
  assets.sort((a, b) => b.size - a.size);
69
- var longestSizeLabelLength = Math.max.apply(
70
- null,
71
- assets.map((a) => (0, import_compiled.stripAnsi)(a.sizeLabel).length)
72
- );
73
- var longestFileNameLength = Math.max.apply(
74
- null,
75
- assets.map((a) => (0, import_compiled.stripAnsi)(a.folder + import_path.default.sep + a.name).length)
76
- );
52
+ var longestSizeLabelLength = Math.max.apply(null, assets.map((a) => (0, _compiled.stripAnsi)(a.sizeLabel).length));
53
+ var longestFileNameLength = Math.max.apply(null, assets.map((a) => (0, _compiled.stripAnsi)(a.folder + _path.default.sep + a.name).length));
77
54
  printFileSizesHeader(longestFileNameLength, longestSizeLabelLength);
78
55
  var suggestBundleSplitting = false;
79
56
  assets.forEach((asset) => {
80
57
  var { folder, name, sizeLabel, gzipSizeLabel, gzippedSize } = asset;
81
- var fileNameLength = (0, import_compiled.stripAnsi)(folder + import_path.default.sep + name).length;
82
- var sizeLength = (0, import_compiled.stripAnsi)(sizeLabel).length;
58
+ var fileNameLength = (0, _compiled.stripAnsi)(folder + _path.default.sep + name).length;
59
+ var sizeLength = (0, _compiled.stripAnsi)(sizeLabel).length;
83
60
  if (sizeLength < longestSizeLabelLength) {
84
61
  var rightPadding = " ".repeat(longestSizeLabelLength - sizeLength);
85
62
  sizeLabel += rightPadding;
86
63
  }
87
- var fileNameLabel = import_compiled.chalk.dim(asset.folder + import_path.default.sep) + import_compiled.chalk.cyan(asset.name);
64
+ var fileNameLabel = _compiled.chalk.dim(asset.folder + _path.default.sep) + _compiled.chalk.cyan(asset.name);
88
65
  if (fileNameLength < longestFileNameLength) {
89
66
  var rightPadding = " ".repeat(longestFileNameLength - fileNameLength);
90
67
  fileNameLabel += rightPadding;
@@ -92,21 +69,26 @@ function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, ma
92
69
  var isMainBundle = asset.name.indexOf("main.") === 0;
93
70
  var maxRecommendedSize = isMainBundle ? maxBundleGzipSize : maxChunkGzipSize;
94
71
  var isLarge = maxRecommendedSize && gzippedSize > maxRecommendedSize;
95
- if (isLarge && import_path.default.extname(asset.name) === ".js") {
72
+ if (isLarge && _path.default.extname(asset.name) === ".js") {
96
73
  suggestBundleSplitting = true;
97
74
  }
98
- import_logger.logger.log(
99
- " " + fileNameLabel + " " + sizeLabel + " " + (isLarge ? import_compiled.chalk.yellow(gzipSizeLabel) : gzipSizeLabel)
100
- );
75
+ _logger.logger.log(" " + fileNameLabel + " " + sizeLabel + " " + (isLarge ? _compiled.chalk.yellow(gzipSizeLabel) : gzipSizeLabel));
101
76
  });
102
77
  if (suggestBundleSplitting) {
103
- import_logger.logger.log();
104
- import_logger.logger.warn("The bundle size is significantly larger than recommended.");
78
+ _logger.logger.log();
79
+ _logger.logger.warn("The bundle size is significantly larger than recommended.");
105
80
  }
106
81
  }
107
82
  function printFileSizesHeader(longestFileNameLength, longestSizeLabelLength) {
108
- const longestLengths = [longestFileNameLength, longestSizeLabelLength];
109
- const headerRow = ["File", "Size", "Gzipped"].reduce((prev, cur, index) => {
83
+ const longestLengths = [
84
+ longestFileNameLength,
85
+ longestSizeLabelLength
86
+ ];
87
+ const headerRow = [
88
+ "File",
89
+ "Size",
90
+ "Gzipped"
91
+ ].reduce((prev, cur, index) => {
110
92
  const length = longestLengths[index];
111
93
  let curLabel = cur;
112
94
  if (length) {
@@ -114,37 +96,37 @@ function printFileSizesHeader(longestFileNameLength, longestSizeLabelLength) {
114
96
  }
115
97
  return prev + curLabel + " ";
116
98
  }, " ");
117
- import_logger.logger.log(import_compiled.chalk.bold(import_compiled.chalk.blue(headerRow)));
99
+ _logger.logger.log(_compiled.chalk.bold(_compiled.chalk.blue(headerRow)));
118
100
  }
119
101
  function removeFileNameHash(buildFolder, fileName) {
120
- return fileName.replace(buildFolder, "").replace(/\\/g, "/").replace(
121
- /\/?(.*)(\.[0-9a-f]+)(\.chunk)?(\.js|\.css)/,
122
- (match, p1, p2, p3, p4) => p1 + p4
123
- );
102
+ return fileName.replace(buildFolder, "").replace(/\\/g, "/").replace(/\/?(.*)(\.[0-9a-f]+)(\.chunk)?(\.js|\.css)/, (match, p1, p2, p3, p4) => p1 + p4);
124
103
  }
125
104
  function getDifferenceLabel(currentSize, previousSize) {
126
105
  var FIFTY_KILOBYTES = 1024 * 50;
127
106
  var difference = currentSize - previousSize;
128
- var fileSize = !Number.isNaN(difference) ? (0, import_compiled.filesize)(difference) : 0;
107
+ var fileSize = !Number.isNaN(difference) ? (0, _compiled.filesize)(difference) : 0;
129
108
  if (difference >= FIFTY_KILOBYTES) {
130
- return import_compiled.chalk.red("+" + fileSize);
109
+ return _compiled.chalk.red("+" + fileSize);
131
110
  } else if (difference < FIFTY_KILOBYTES && difference > 0) {
132
- return import_compiled.chalk.yellow("+" + fileSize);
111
+ return _compiled.chalk.yellow("+" + fileSize);
133
112
  } else if (difference < 0) {
134
- return import_compiled.chalk.green(fileSize);
113
+ return _compiled.chalk.green(fileSize);
135
114
  } else {
136
115
  return "";
137
116
  }
138
117
  }
139
118
  function measureFileSizesBeforeBuild(buildFolder) {
140
119
  return new Promise((resolve) => {
141
- (0, import_compiled.recursiveReaddir)(buildFolder, (err, fileNames) => {
120
+ (0, _compiled.recursiveReaddir)(buildFolder, (err, fileNames) => {
142
121
  var sizes;
143
122
  if (!err && fileNames) {
144
123
  sizes = fileNames.filter(canReadAsset).reduce((memo, fileName) => {
145
- var contents = import_fs.default.readFileSync(fileName);
124
+ var contents = _fs.default.readFileSync(fileName);
146
125
  var key = removeFileNameHash(buildFolder, fileName);
147
- memo[key] = [contents.length, import_compiled.gzipSize.sync(contents)];
126
+ memo[key] = [
127
+ contents.length,
128
+ _compiled.gzipSize.sync(contents)
129
+ ];
148
130
  return memo;
149
131
  }, {});
150
132
  }
@@ -155,8 +137,3 @@ function measureFileSizesBeforeBuild(buildFolder) {
155
137
  });
156
138
  });
157
139
  }
158
- // Annotate the CommonJS export names for ESM import in node:
159
- 0 && (module.exports = {
160
- measureFileSizesBeforeBuild,
161
- printFileSizesAfterBuild
162
- });
package/dist/cjs/alias.js CHANGED
@@ -1,66 +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) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
8
6
  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
- var alias_exports = {};
29
- __export(alias_exports, {
30
- getAliasConfig: () => getAliasConfig,
31
- getUserAlias: () => getUserAlias,
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ validAlias: () => validAlias,
32
14
  mergeAlias: () => mergeAlias,
33
- validAlias: () => validAlias
15
+ getAliasConfig: () => getAliasConfig,
16
+ getUserAlias: () => getUserAlias
34
17
  });
35
- module.exports = __toCommonJS(alias_exports);
36
- var import_fs = __toESM(require("fs"));
37
- var import_path = __toESM(require("path"));
38
- var import_compiled = require("./compiled");
39
- var import_readTsConfig = require("./readTsConfig");
40
- var import_applyOptionsChain = require("./applyOptionsChain");
18
+ const _fs = /* @__PURE__ */ _interop_require_default(require("fs"));
19
+ const _path = /* @__PURE__ */ _interop_require_default(require("path"));
20
+ const _compiled = require("./compiled");
21
+ const _readTsConfig = require("./readTsConfig");
22
+ const _applyOptionsChain = require("./applyOptionsChain");
23
+ function _interop_require_default(obj) {
24
+ return obj && obj.__esModule ? obj : {
25
+ default: obj
26
+ };
27
+ }
41
28
  const validAlias = (modernConfig, { tsconfigPath }) => {
42
- const {
43
- source: { alias }
44
- } = modernConfig;
29
+ const { source: { alias } } = modernConfig;
45
30
  if (!alias) {
46
31
  return null;
47
32
  }
48
- const isTsProject = import_fs.default.existsSync(tsconfigPath);
33
+ const isTsProject = _fs.default.existsSync(tsconfigPath);
49
34
  if (!isTsProject) {
50
35
  return null;
51
36
  }
52
37
  const userAlias = getUserAlias(alias);
53
38
  if (Object.keys(userAlias).length > 0) {
54
- return import_compiled.chalk.red(
55
- 'Note: Please use `compilerOptions.paths` in "tsconfig.json" file replace `source.alias` config in "modern.config.js/ts" when project is typescript'
56
- );
39
+ return _compiled.chalk.red('Note: Please use `compilerOptions.paths` in "tsconfig.json" file replace `source.alias` config in "modern.config.js/ts" when project is typescript');
57
40
  }
58
41
  return null;
59
42
  };
60
- const mergeAlias = (alias) => (0, import_applyOptionsChain.applyOptionsChain)({}, alias);
43
+ const mergeAlias = (alias) => (0, _applyOptionsChain.applyOptionsChain)({}, alias);
61
44
  const getAliasConfig = (aliasOption, option) => {
62
- var _a, _b;
63
- const isTsProject = import_fs.default.existsSync(option.tsconfigPath);
45
+ var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
46
+ const isTsProject = _fs.default.existsSync(option.tsconfigPath);
64
47
  const alias = mergeAlias(aliasOption);
65
48
  if (!isTsProject) {
66
49
  return {
@@ -70,13 +53,13 @@ const getAliasConfig = (aliasOption, option) => {
70
53
  isTsProject
71
54
  };
72
55
  }
73
- const tsconfig = (0, import_readTsConfig.readTsConfigByFile)(option.tsconfigPath);
74
- const baseUrl = (_a = tsconfig == null ? void 0 : tsconfig.compilerOptions) == null ? void 0 : _a.baseUrl;
56
+ const tsconfig = (0, _readTsConfig.readTsConfigByFile)(option.tsconfigPath);
57
+ const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
75
58
  return {
76
- absoluteBaseUrl: baseUrl ? import_path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
59
+ absoluteBaseUrl: baseUrl ? _path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
77
60
  paths: {
78
61
  ...alias,
79
- ...(_b = tsconfig == null ? void 0 : tsconfig.compilerOptions) == null ? void 0 : _b.paths
62
+ ...tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions1 = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths
80
63
  },
81
64
  isTsPath: true,
82
65
  isTsProject
@@ -88,10 +71,3 @@ const getUserAlias = (alias = {}) => Object.keys(alias).reduce((o, k) => {
88
71
  }
89
72
  return o;
90
73
  }, {});
91
- // Annotate the CommonJS export names for ESM import in node:
92
- 0 && (module.exports = {
93
- getAliasConfig,
94
- getUserAlias,
95
- mergeAlias,
96
- validAlias
97
- });
@@ -1,51 +1,68 @@
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) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
8
6
  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
- var analyzeProject_exports = {};
29
- __export(analyzeProject_exports, {
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
30
13
  isApiOnly: () => isApiOnly,
31
14
  isWebOnly: () => isWebOnly
32
15
  });
33
- module.exports = __toCommonJS(analyzeProject_exports);
34
- var path = __toESM(require("path"));
35
- var import_commands = require("./commands");
36
- var import_compiled = require("./compiled");
16
+ const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
17
+ const _commands = require("./commands");
18
+ const _compiled = require("./compiled");
19
+ function _getRequireWildcardCache(nodeInterop) {
20
+ if (typeof WeakMap !== "function")
21
+ return null;
22
+ var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
23
+ var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
24
+ return (_getRequireWildcardCache = function(nodeInterop2) {
25
+ return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
26
+ })(nodeInterop);
27
+ }
28
+ function _interop_require_wildcard(obj, nodeInterop) {
29
+ if (!nodeInterop && obj && obj.__esModule) {
30
+ return obj;
31
+ }
32
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
33
+ return {
34
+ default: obj
35
+ };
36
+ }
37
+ var cache = _getRequireWildcardCache(nodeInterop);
38
+ if (cache && cache.has(obj)) {
39
+ return cache.get(obj);
40
+ }
41
+ var newObj = {};
42
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
43
+ for (var key in obj) {
44
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
45
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
46
+ if (desc && (desc.get || desc.set)) {
47
+ Object.defineProperty(newObj, key, desc);
48
+ } else {
49
+ newObj[key] = obj[key];
50
+ }
51
+ }
52
+ }
53
+ newObj.default = obj;
54
+ if (cache) {
55
+ cache.set(obj, newObj);
56
+ }
57
+ return newObj;
58
+ }
37
59
  const isApiOnly = async (appDirectory, entryDir) => {
38
- const srcDir = path.join(appDirectory, entryDir != null ? entryDir : "src");
39
- const existSrc = await import_compiled.fs.pathExists(srcDir);
40
- const options = (0, import_compiled.minimist)((0, import_commands.getArgv)());
60
+ const srcDir = _path.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src");
61
+ const existSrc = await _compiled.fs.pathExists(srcDir);
62
+ const options = (0, _compiled.minimist)((0, _commands.getArgv)());
41
63
  return !existSrc || Boolean(options["api-only"]);
42
64
  };
43
65
  const isWebOnly = async () => {
44
- const options = (0, import_compiled.minimist)((0, import_commands.getArgv)());
66
+ const options = (0, _compiled.minimist)((0, _commands.getArgv)());
45
67
  return Boolean(options["web-only"]);
46
68
  };
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
49
- isApiOnly,
50
- isWebOnly
51
- });
@@ -1,58 +1,31 @@
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
- var applyOptionsChain_exports = {};
19
- __export(applyOptionsChain_exports, {
20
- applyOptionsChain: () => applyOptionsChain
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "applyOptionsChain", {
6
+ enumerable: true,
7
+ get: () => applyOptionsChain
21
8
  });
22
- module.exports = __toCommonJS(applyOptionsChain_exports);
23
- var import_index = require("./index");
9
+ const _index = require("./index");
24
10
  function applyOptionsChain(defaults, options, utils, mergeFn = Object.assign) {
25
11
  if (!options) {
26
12
  return defaults;
27
13
  }
28
- if ((0, import_index.isPlainObject)(options)) {
14
+ if ((0, _index.isPlainObject)(options)) {
29
15
  return mergeFn(defaults, options);
30
- } else if ((0, import_index.isFunction)(options)) {
16
+ } else if ((0, _index.isFunction)(options)) {
31
17
  const ret = options(defaults, utils);
32
18
  if (ret) {
33
- if (!(0, import_index.isPlainObject)(ret)) {
34
- import_index.logger.warn(
35
- `${options.name}: Function should mutate the config and return nothing, Or return a cloned or merged version of config object.`
36
- );
19
+ if (!(0, _index.isPlainObject)(ret)) {
20
+ _index.logger.warn(`${options.name}: Function should mutate the config and return nothing, Or return a cloned or merged version of config object.`);
37
21
  }
38
22
  return ret;
39
23
  }
40
24
  } else if (Array.isArray(options)) {
41
- return options.reduce(
42
- (memo, cur) => applyOptionsChain(memo, cur, utils, mergeFn),
43
- defaults
44
- );
25
+ return options.reduce((memo, cur) => applyOptionsChain(memo, cur, utils, mergeFn), defaults);
45
26
  } else {
46
- throw new Error(
47
- `applyOptionsChain error:
48
- default options is: ${JSON.stringify(
49
- defaults
50
- )}`
51
- );
27
+ throw new Error(`applyOptionsChain error:
28
+ default options is: ${JSON.stringify(defaults)}`);
52
29
  }
53
30
  return defaults;
54
31
  }
55
- // Annotate the CommonJS export names for ESM import in node:
56
- 0 && (module.exports = {
57
- applyOptionsChain
58
- });