@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.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/FileSizeReporter.js +69 -92
- package/dist/cjs/alias.js +34 -58
- package/dist/cjs/analyzeProject.js +58 -41
- package/dist/cjs/applyOptionsChain.js +15 -42
- package/dist/cjs/babel.js +28 -39
- package/dist/cjs/chainId.js +7 -25
- package/dist/cjs/clearConsole.js +7 -25
- package/dist/cjs/commands.js +14 -29
- package/dist/cjs/compatRequire.js +22 -38
- package/dist/cjs/compiled.js +120 -139
- package/dist/cjs/constants.js +143 -98
- package/dist/cjs/debug.js +8 -26
- package/dist/cjs/emptyDir.js +10 -28
- package/dist/cjs/ensureAbsolutePath.js +13 -36
- package/dist/cjs/ensureArray.js +10 -26
- package/dist/cjs/findExists.js +14 -37
- package/dist/cjs/generateMetaTags.js +12 -31
- package/dist/cjs/getBrowserslist.js +20 -27
- package/dist/cjs/getCoreJsVersion.js +49 -37
- package/dist/cjs/getEntryOptions.js +14 -29
- package/dist/cjs/getPackageManager.js +23 -46
- package/dist/cjs/getPort.js +26 -61
- package/dist/cjs/getServerConfig.js +51 -43
- package/dist/cjs/getTargetDir.js +50 -38
- package/dist/cjs/import.js +16 -27
- package/dist/cjs/index.js +61 -60
- package/dist/cjs/is/index.js +53 -68
- package/dist/cjs/is/nodeEnv.js +13 -29
- package/dist/cjs/is/platform.js +13 -26
- package/dist/cjs/is/type.js +14 -33
- package/dist/cjs/logger.js +54 -50
- package/dist/cjs/monorepo.js +47 -78
- package/dist/cjs/nodeEnv.js +29 -31
- package/dist/cjs/path.js +42 -63
- package/dist/cjs/pathSerializer.js +43 -51
- package/dist/cjs/plugin.js +11 -29
- package/dist/cjs/prettyInstructions.js +35 -68
- package/dist/cjs/printBuildError.js +15 -37
- package/dist/cjs/react.js +18 -41
- package/dist/cjs/readTsConfig.js +21 -39
- package/dist/cjs/removeSlash.js +13 -27
- package/dist/cjs/resolve.js +25 -31
- package/dist/cjs/routes.js +22 -42
- package/dist/cjs/runtime/index.js +18 -17
- package/dist/cjs/runtime/parsed.js +8 -26
- package/dist/cjs/runtimeExports.js +31 -56
- package/dist/cjs/ssr.js +13 -26
- package/dist/cjs/storage.js +51 -41
- package/dist/cjs/testUtils.js +8 -29
- package/dist/cjs/types.js +4 -15
- package/dist/cjs/universal/constants.js +13 -26
- package/dist/cjs/universal/formatWebpack.js +16 -44
- package/dist/cjs/universal/nestedRoutes.js +94 -46
- package/dist/cjs/universal/pluginDagSort.js +58 -0
- package/dist/cjs/universal/remixRouter.js +18 -17
- package/dist/cjs/universal/serialize.js +16 -37
- package/dist/cjs/version.js +25 -41
- package/dist/cjs/wait.js +7 -25
- package/dist/cjs/watch.js +69 -43
- package/dist/esm/FileSizeReporter.js +40 -52
- package/dist/esm/alias.js +9 -19
- package/dist/esm/analyzeProject.js +3 -7
- package/dist/esm/applyOptionsChain.js +5 -17
- package/dist/esm/babel.js +6 -8
- package/dist/esm/chainId.js +1 -4
- package/dist/esm/clearConsole.js +1 -4
- package/dist/esm/commands.js +6 -12
- package/dist/esm/compatRequire.js +10 -17
- package/dist/esm/compiled.js +32 -76
- package/dist/esm/constants.js +143 -89
- package/dist/esm/debug.js +1 -4
- package/dist/esm/emptyDir.js +1 -4
- package/dist/esm/ensureAbsolutePath.js +1 -4
- package/dist/esm/ensureArray.js +4 -5
- package/dist/esm/findExists.js +1 -4
- package/dist/esm/generateMetaTags.js +6 -10
- package/dist/esm/getBrowserslist.js +8 -6
- package/dist/esm/getCoreJsVersion.js +1 -4
- package/dist/esm/getEntryOptions.js +5 -5
- package/dist/esm/getPackageManager.js +1 -4
- package/dist/esm/getPort.js +10 -25
- package/dist/esm/getServerConfig.js +2 -9
- package/dist/esm/getTargetDir.js +1 -4
- package/dist/esm/import.js +3 -4
- package/dist/esm/is/index.js +18 -30
- package/dist/esm/is/nodeEnv.js +5 -12
- package/dist/esm/is/platform.js +2 -6
- package/dist/esm/is/type.js +8 -18
- package/dist/esm/logger.js +37 -17
- package/dist/esm/monorepo.js +21 -38
- package/dist/esm/nodeEnv.js +18 -11
- package/dist/esm/path.js +16 -23
- package/dist/esm/pathSerializer.js +21 -21
- package/dist/esm/plugin.js +1 -4
- package/dist/esm/prettyInstructions.js +13 -32
- package/dist/esm/printBuildError.js +4 -11
- package/dist/esm/react.js +1 -4
- package/dist/esm/readTsConfig.js +2 -6
- package/dist/esm/removeSlash.js +3 -8
- package/dist/esm/resolve.js +14 -11
- package/dist/esm/routes.js +3 -9
- package/dist/esm/runtime/parsed.js +2 -5
- package/dist/esm/runtimeExports.js +17 -22
- package/dist/esm/ssr.js +1 -4
- package/dist/esm/storage.js +2 -6
- package/dist/esm/testUtils.js +2 -8
- package/dist/esm/types.js +1 -0
- package/dist/esm/universal/constants.js +2 -6
- package/dist/esm/universal/formatWebpack.js +10 -22
- package/dist/esm/universal/nestedRoutes.js +41 -27
- package/dist/esm/universal/pluginDagSort.js +50 -0
- package/dist/esm/universal/serialize.js +4 -5
- package/dist/esm/version.js +5 -7
- package/dist/esm/wait.js +1 -3
- package/dist/esm/watch.js +14 -9
- package/dist/types/universal/pluginDagSort.d.ts +1 -0
- 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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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 || [
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
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,
|
82
|
-
var sizeLength = (0,
|
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 =
|
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 &&
|
72
|
+
if (isLarge && _path.default.extname(asset.name) === ".js") {
|
96
73
|
suggestBundleSplitting = true;
|
97
74
|
}
|
98
|
-
|
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
|
-
|
104
|
-
|
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 = [
|
109
|
-
|
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
|
-
|
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,
|
107
|
+
var fileSize = !Number.isNaN(difference) ? (0, _compiled.filesize)(difference) : 0;
|
129
108
|
if (difference >= FIFTY_KILOBYTES) {
|
130
|
-
return
|
109
|
+
return _compiled.chalk.red("+" + fileSize);
|
131
110
|
} else if (difference < FIFTY_KILOBYTES && difference > 0) {
|
132
|
-
return
|
111
|
+
return _compiled.chalk.yellow("+" + fileSize);
|
133
112
|
} else if (difference < 0) {
|
134
|
-
return
|
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,
|
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 =
|
124
|
+
var contents = _fs.default.readFileSync(fileName);
|
146
125
|
var key = removeFileNameHash(buildFolder, fileName);
|
147
|
-
memo[key] = [
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
15
|
+
getAliasConfig: () => getAliasConfig,
|
16
|
+
getUserAlias: () => getUserAlias
|
34
17
|
});
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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 =
|
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
|
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,
|
43
|
+
const mergeAlias = (alias) => (0, _applyOptionsChain.applyOptionsChain)({}, alias);
|
61
44
|
const getAliasConfig = (aliasOption, option) => {
|
62
|
-
var
|
63
|
-
const isTsProject =
|
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,
|
74
|
-
const 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 ?
|
59
|
+
absoluteBaseUrl: baseUrl ? _path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
|
77
60
|
paths: {
|
78
61
|
...alias,
|
79
|
-
...
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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 =
|
39
|
-
const existSrc = await
|
40
|
-
const options = (0,
|
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,
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
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,
|
14
|
+
if ((0, _index.isPlainObject)(options)) {
|
29
15
|
return mergeFn(defaults, options);
|
30
|
-
} else if ((0,
|
16
|
+
} else if ((0, _index.isFunction)(options)) {
|
31
17
|
const ret = options(defaults, utils);
|
32
18
|
if (ret) {
|
33
|
-
if (!(0,
|
34
|
-
|
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
|
-
|
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
|
-
});
|