weapp-vite 5.7.0 → 5.7.2
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.
- package/dist/auto-import-components/resolvers.cjs +5 -5
- package/dist/auto-import-components/resolvers.mjs +1 -1
- package/dist/auto-routes.cjs +8 -8
- package/dist/auto-routes.mjs +4 -4
- package/dist/{chunk-GU7U5762.mjs → chunk-3WGK7INY.mjs} +2 -2
- package/dist/{chunk-VRKZFXIZ.cjs → chunk-AUQJOLJS.cjs} +6 -6
- package/dist/{chunk-ZMX6CFVX.mjs → chunk-ED4S52HS.mjs} +1 -1
- package/dist/{chunk-AKJEW44F.mjs → chunk-FSDX3XLK.mjs} +454 -57
- package/dist/{chunk-FUJ4D6IR.cjs → chunk-HKSOVHNE.cjs} +799 -402
- package/dist/{chunk-MQBCRXCD.cjs → chunk-JKNSNXOE.cjs} +2 -2
- package/dist/chunk-O3YXI56P.cjs +6 -0
- package/dist/{chunk-A5DD7GKX.cjs → chunk-QKFYCWOC.cjs} +2 -2
- package/dist/{chunk-N463WDOG.mjs → chunk-RJVVY5EI.mjs} +1 -1
- package/dist/{chunk-G6EZVEVT.cjs → chunk-RMHCFT5Q.cjs} +2 -2
- package/dist/{chunk-2SUWUB42.mjs → chunk-SSYIWHY2.mjs} +1 -1
- package/dist/{chunk-SSQGJIB5.mjs → chunk-TZWATIK3.mjs} +2 -2
- package/dist/cli.cjs +298 -91
- package/dist/cli.mjs +228 -22
- package/dist/config.cjs +4 -4
- package/dist/config.mjs +3 -3
- package/dist/index.cjs +8 -8
- package/dist/index.mjs +6 -6
- package/dist/json.cjs +3 -3
- package/dist/json.mjs +2 -2
- package/dist/types.cjs +9 -9
- package/dist/types.mjs +2 -2
- package/dist/volar.cjs +2 -2
- package/dist/volar.mjs +1 -1
- package/modules/analyze-dashboard/assets/echarts.js +17 -0
- package/modules/analyze-dashboard/assets/index.css +2 -0
- package/modules/analyze-dashboard/assets/index.js +1 -0
- package/modules/analyze-dashboard/assets/rolldown-runtime.js +1 -0
- package/modules/analyze-dashboard/assets/vue.js +6 -0
- package/modules/analyze-dashboard/index.html +13 -0
- package/package.json +12 -5
- package/dist/chunk-FOWFAOSV.cjs +0 -6
package/dist/cli.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkAUQJOLJScjs = require('./chunk-AUQJOLJS.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -11,16 +11,17 @@ var _chunkVRKZFXIZcjs = require('./chunk-VRKZFXIZ.cjs');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkHKSOVHNEcjs = require('./chunk-HKSOVHNE.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
var _chunkQKFYCWOCcjs = require('./chunk-QKFYCWOC.cjs');
|
|
18
19
|
|
|
19
20
|
// src/cli.ts
|
|
20
|
-
|
|
21
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
21
22
|
|
|
22
23
|
// ../../node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
|
|
23
|
-
|
|
24
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
24
25
|
var _events = require('events');
|
|
25
26
|
function toArr(any) {
|
|
26
27
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
@@ -606,18 +607,18 @@ var CAC = class extends _events.EventEmitter {
|
|
|
606
607
|
var cac = (name = "") => new CAC(name);
|
|
607
608
|
|
|
608
609
|
// src/cli/commands/analyze.ts
|
|
609
|
-
|
|
610
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
610
611
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
611
612
|
var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
|
|
612
613
|
var _pathe = require('pathe'); var _pathe2 = _interopRequireDefault(_pathe);
|
|
613
614
|
|
|
614
615
|
// src/analyze/subpackages.ts
|
|
615
|
-
|
|
616
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
616
617
|
var _buffer = require('buffer');
|
|
617
618
|
|
|
618
619
|
var _vite = require('vite');
|
|
619
620
|
var VIRTUAL_MODULE_INDICATOR = "\0";
|
|
620
|
-
var VIRTUAL_PREFIX = `${
|
|
621
|
+
var VIRTUAL_PREFIX = `${_chunkHKSOVHNEcjs.SHARED_CHUNK_VIRTUAL_PREFIX}/`;
|
|
621
622
|
function isPathInside(parent, candidate) {
|
|
622
623
|
if (!parent) {
|
|
623
624
|
return false;
|
|
@@ -980,7 +981,7 @@ async function analyzeSubpackages(ctx) {
|
|
|
980
981
|
};
|
|
981
982
|
const analysisConfig = configService.merge(
|
|
982
983
|
void 0,
|
|
983
|
-
|
|
984
|
+
_chunkHKSOVHNEcjs.createSharedBuildConfig.call(void 0, configService, scanService),
|
|
984
985
|
{
|
|
985
986
|
build: {
|
|
986
987
|
write: false,
|
|
@@ -1007,8 +1008,171 @@ async function analyzeSubpackages(ctx) {
|
|
|
1007
1008
|
};
|
|
1008
1009
|
}
|
|
1009
1010
|
|
|
1011
|
+
// src/cli/analyze/dashboard.ts
|
|
1012
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
// src/packagePaths.ts
|
|
1018
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1019
|
+
var _path = require('path');
|
|
1020
|
+
var _url = require('url');
|
|
1021
|
+
|
|
1022
|
+
function findPackageRoot(from) {
|
|
1023
|
+
let current = from;
|
|
1024
|
+
while (true) {
|
|
1025
|
+
if (_fsextra2.default.existsSync(_path.join.call(void 0, current, "package.json"))) {
|
|
1026
|
+
return current;
|
|
1027
|
+
}
|
|
1028
|
+
const parent = _path.dirname.call(void 0, current);
|
|
1029
|
+
if (parent === current) {
|
|
1030
|
+
break;
|
|
1031
|
+
}
|
|
1032
|
+
current = parent;
|
|
1033
|
+
}
|
|
1034
|
+
throw new Error("\u65E0\u6CD5\u5B9A\u4F4D weapp-vite \u5305\u6839\u76EE\u5F55\uFF0C\u8BF7\u68C0\u67E5\u5B89\u88C5\u8DEF\u5F84\u3002");
|
|
1035
|
+
}
|
|
1036
|
+
var CURRENT_DIR = _path.dirname.call(void 0, _url.fileURLToPath.call(void 0, _chunkQKFYCWOCcjs.importMetaUrl));
|
|
1037
|
+
var PACKAGE_ROOT = findPackageRoot(CURRENT_DIR);
|
|
1038
|
+
var ANALYZE_DASHBOARD_ROOT = _path.join.call(void 0, PACKAGE_ROOT, "modules/analyze-dashboard");
|
|
1039
|
+
|
|
1040
|
+
// src/cli/analyze/dashboard.ts
|
|
1041
|
+
var ANALYZE_GLOBAL_KEY = "__WEAPP_VITE_ANALYZE_RESULT__";
|
|
1042
|
+
function resolveDashboardRoot() {
|
|
1043
|
+
if (_fsextra2.default.existsSync(ANALYZE_DASHBOARD_ROOT)) {
|
|
1044
|
+
return {
|
|
1045
|
+
root: ANALYZE_DASHBOARD_ROOT
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
throw new Error(
|
|
1049
|
+
"[weapp-vite analyze] \u672A\u627E\u5230\u4EEA\u8868\u76D8\u4EA7\u7269\uFF0C\u8BF7\u5148\u6267\u884C `pnpm --filter weapp-vite run build:dashboard` \u751F\u6210\u3002"
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
1052
|
+
function createAnalyzeHtmlPlugin(state, onServerInstance) {
|
|
1053
|
+
return {
|
|
1054
|
+
name: "weapp-vite-analyze-html",
|
|
1055
|
+
transformIndexHtml(html) {
|
|
1056
|
+
return {
|
|
1057
|
+
html,
|
|
1058
|
+
tags: [
|
|
1059
|
+
{
|
|
1060
|
+
tag: "script",
|
|
1061
|
+
children: `window.${ANALYZE_GLOBAL_KEY} = ${JSON.stringify(state.current)}`,
|
|
1062
|
+
injectTo: "head-prepend"
|
|
1063
|
+
}
|
|
1064
|
+
]
|
|
1065
|
+
};
|
|
1066
|
+
},
|
|
1067
|
+
configureServer(server) {
|
|
1068
|
+
onServerInstance(server);
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
async function waitForServerExit(server) {
|
|
1073
|
+
let resolved = false;
|
|
1074
|
+
const cleanup = async () => {
|
|
1075
|
+
if (resolved) {
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
resolved = true;
|
|
1079
|
+
try {
|
|
1080
|
+
await server.close();
|
|
1081
|
+
} catch (error) {
|
|
1082
|
+
_chunkHKSOVHNEcjs.logger_default.error(error);
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
const signals = ["SIGINT", "SIGTERM"];
|
|
1086
|
+
await new Promise((resolvePromise) => {
|
|
1087
|
+
const resolveOnce = async () => {
|
|
1088
|
+
await cleanup();
|
|
1089
|
+
signals.forEach((signal) => {
|
|
1090
|
+
_process2.default.removeListener(signal, resolveOnce);
|
|
1091
|
+
});
|
|
1092
|
+
resolvePromise();
|
|
1093
|
+
};
|
|
1094
|
+
signals.forEach((signal) => {
|
|
1095
|
+
_process2.default.once(signal, resolveOnce);
|
|
1096
|
+
});
|
|
1097
|
+
_optionalChain([server, 'access', _5 => _5.httpServer, 'optionalAccess', _6 => _6.once, 'call', _7 => _7("close", resolveOnce)]);
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
async function startAnalyzeDashboard(result, options) {
|
|
1101
|
+
const { root } = resolveDashboardRoot();
|
|
1102
|
+
const state = { current: result };
|
|
1103
|
+
let serverRef;
|
|
1104
|
+
const plugins = [
|
|
1105
|
+
createAnalyzeHtmlPlugin(state, (server2) => {
|
|
1106
|
+
serverRef = server2;
|
|
1107
|
+
})
|
|
1108
|
+
];
|
|
1109
|
+
const server = await _vite.createServer.call(void 0, {
|
|
1110
|
+
root,
|
|
1111
|
+
clearScreen: false,
|
|
1112
|
+
appType: "spa",
|
|
1113
|
+
publicDir: false,
|
|
1114
|
+
plugins,
|
|
1115
|
+
server: {
|
|
1116
|
+
host: "127.0.0.1",
|
|
1117
|
+
port: 0
|
|
1118
|
+
},
|
|
1119
|
+
logLevel: "error"
|
|
1120
|
+
});
|
|
1121
|
+
await server.listen();
|
|
1122
|
+
serverRef ??= server;
|
|
1123
|
+
server.printUrls();
|
|
1124
|
+
const urls = (() => {
|
|
1125
|
+
const resolved = server.resolvedUrls;
|
|
1126
|
+
if (!resolved) {
|
|
1127
|
+
return [];
|
|
1128
|
+
}
|
|
1129
|
+
return [
|
|
1130
|
+
..._nullishCoalesce(resolved.local, () => ( [])),
|
|
1131
|
+
..._nullishCoalesce(resolved.network, () => ( []))
|
|
1132
|
+
];
|
|
1133
|
+
})();
|
|
1134
|
+
const waitPromise = waitForServerExit(server);
|
|
1135
|
+
if (_optionalChain([serverRef, 'optionalAccess', _8 => _8.ws])) {
|
|
1136
|
+
serverRef.ws.send({
|
|
1137
|
+
type: "custom",
|
|
1138
|
+
event: "weapp-analyze:update",
|
|
1139
|
+
data: state.current
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
const handle = {
|
|
1143
|
+
async update(nextResult) {
|
|
1144
|
+
state.current = nextResult;
|
|
1145
|
+
if (serverRef) {
|
|
1146
|
+
serverRef.ws.send({
|
|
1147
|
+
type: "custom",
|
|
1148
|
+
event: "weapp-analyze:update",
|
|
1149
|
+
data: nextResult
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1153
|
+
waitForExit: () => waitPromise,
|
|
1154
|
+
close: async () => {
|
|
1155
|
+
await server.close();
|
|
1156
|
+
},
|
|
1157
|
+
urls
|
|
1158
|
+
};
|
|
1159
|
+
if (_optionalChain([options, 'optionalAccess', _9 => _9.watch])) {
|
|
1160
|
+
_chunkHKSOVHNEcjs.logger_default.info("\u5206\u6790\u4EEA\u8868\u76D8\u5DF2\u542F\u52A8\uFF08\u5B9E\u65F6\u6A21\u5F0F\uFF09\uFF0C\u6309 Ctrl+C \u9000\u51FA\u3002");
|
|
1161
|
+
for (const url of handle.urls) {
|
|
1162
|
+
_chunkHKSOVHNEcjs.logger_default.info(`\u5206\u5305\u5206\u6790\u4EEA\u8868\u76D8\uFF1A${url}`);
|
|
1163
|
+
}
|
|
1164
|
+
void waitPromise;
|
|
1165
|
+
return handle;
|
|
1166
|
+
}
|
|
1167
|
+
_chunkHKSOVHNEcjs.logger_default.info("\u5206\u6790\u4EEA\u8868\u76D8\u5DF2\u542F\u52A8\uFF08\u9759\u6001\u6A21\u5F0F\uFF09\uFF0C\u6309 Ctrl+C \u9000\u51FA\u3002");
|
|
1168
|
+
for (const url of handle.urls) {
|
|
1169
|
+
_chunkHKSOVHNEcjs.logger_default.info(`\u5206\u5305\u5206\u6790\u4EEA\u8868\u76D8\uFF1A${url}`);
|
|
1170
|
+
}
|
|
1171
|
+
await waitPromise;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1010
1174
|
// src/cli/options.ts
|
|
1011
|
-
|
|
1175
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1012
1176
|
function filterDuplicateOptions(options) {
|
|
1013
1177
|
for (const [key, value] of Object.entries(options)) {
|
|
1014
1178
|
if (Array.isArray(value)) {
|
|
@@ -1057,9 +1221,9 @@ function coerceBooleanOption(value) {
|
|
|
1057
1221
|
}
|
|
1058
1222
|
|
|
1059
1223
|
// src/cli/runtime.ts
|
|
1060
|
-
|
|
1224
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1061
1225
|
function logRuntimeTarget(targets) {
|
|
1062
|
-
|
|
1226
|
+
_chunkHKSOVHNEcjs.logger_default.info(`\u76EE\u6807\u5E73\u53F0\uFF1A${targets.label}`);
|
|
1063
1227
|
}
|
|
1064
1228
|
function resolveRuntimeTargets(options) {
|
|
1065
1229
|
const rawPlatform = typeof options.platform === "string" ? options.platform : typeof options.p === "string" ? options.p : void 0;
|
|
@@ -1067,17 +1231,17 @@ function resolveRuntimeTargets(options) {
|
|
|
1067
1231
|
return {
|
|
1068
1232
|
runMini: true,
|
|
1069
1233
|
runWeb: false,
|
|
1070
|
-
mpPlatform:
|
|
1071
|
-
label:
|
|
1234
|
+
mpPlatform: _chunkHKSOVHNEcjs.DEFAULT_MP_PLATFORM,
|
|
1235
|
+
label: _chunkHKSOVHNEcjs.DEFAULT_MP_PLATFORM
|
|
1072
1236
|
};
|
|
1073
1237
|
}
|
|
1074
|
-
const normalized =
|
|
1238
|
+
const normalized = _chunkHKSOVHNEcjs.normalizeMiniPlatform.call(void 0, rawPlatform);
|
|
1075
1239
|
if (!normalized) {
|
|
1076
1240
|
return {
|
|
1077
1241
|
runMini: true,
|
|
1078
1242
|
runWeb: false,
|
|
1079
|
-
mpPlatform:
|
|
1080
|
-
label:
|
|
1243
|
+
mpPlatform: _chunkHKSOVHNEcjs.DEFAULT_MP_PLATFORM,
|
|
1244
|
+
label: _chunkHKSOVHNEcjs.DEFAULT_MP_PLATFORM
|
|
1081
1245
|
};
|
|
1082
1246
|
}
|
|
1083
1247
|
if (normalized === "h5" || normalized === "web") {
|
|
@@ -1088,7 +1252,7 @@ function resolveRuntimeTargets(options) {
|
|
|
1088
1252
|
label: normalized === "h5" ? "h5" : "web"
|
|
1089
1253
|
};
|
|
1090
1254
|
}
|
|
1091
|
-
const mpPlatform =
|
|
1255
|
+
const mpPlatform = _chunkHKSOVHNEcjs.resolveMiniPlatform.call(void 0, normalized);
|
|
1092
1256
|
if (mpPlatform) {
|
|
1093
1257
|
return {
|
|
1094
1258
|
runMini: true,
|
|
@@ -1097,12 +1261,12 @@ function resolveRuntimeTargets(options) {
|
|
|
1097
1261
|
label: mpPlatform
|
|
1098
1262
|
};
|
|
1099
1263
|
}
|
|
1100
|
-
|
|
1264
|
+
_chunkHKSOVHNEcjs.logger_default.warn(`\u672A\u8BC6\u522B\u7684\u5E73\u53F0 "${rawPlatform}"\uFF0C\u5DF2\u56DE\u9000\u5230 ${_chunkHKSOVHNEcjs.DEFAULT_MP_PLATFORM}`);
|
|
1101
1265
|
return {
|
|
1102
1266
|
runMini: true,
|
|
1103
1267
|
runWeb: false,
|
|
1104
|
-
mpPlatform:
|
|
1105
|
-
label:
|
|
1268
|
+
mpPlatform: _chunkHKSOVHNEcjs.DEFAULT_MP_PLATFORM,
|
|
1269
|
+
label: _chunkHKSOVHNEcjs.DEFAULT_MP_PLATFORM
|
|
1106
1270
|
};
|
|
1107
1271
|
}
|
|
1108
1272
|
function createInlineConfig(mpPlatform) {
|
|
@@ -1130,15 +1294,15 @@ function printAnalysisSummary(result) {
|
|
|
1130
1294
|
packageModuleSet.set(pkgRef.packageId, set);
|
|
1131
1295
|
}
|
|
1132
1296
|
}
|
|
1133
|
-
|
|
1297
|
+
_chunkHKSOVHNEcjs.logger_default.success("\u5206\u5305\u5206\u6790\u5B8C\u6210");
|
|
1134
1298
|
for (const pkg of result.packages) {
|
|
1135
1299
|
const chunkCount = pkg.files.filter((file) => file.type === "chunk").length;
|
|
1136
1300
|
const assetCount = pkg.files.length - chunkCount;
|
|
1137
|
-
const moduleCount = _nullishCoalesce(_optionalChain([packageModuleSet, 'access',
|
|
1138
|
-
|
|
1301
|
+
const moduleCount = _nullishCoalesce(_optionalChain([packageModuleSet, 'access', _10 => _10.get, 'call', _11 => _11(pkg.id), 'optionalAccess', _12 => _12.size]), () => ( 0));
|
|
1302
|
+
_chunkHKSOVHNEcjs.logger_default.info(`- ${pkg.label}\uFF1A${chunkCount} \u4E2A\u6A21\u5757\u4EA7\u7269\uFF0C${assetCount} \u4E2A\u8D44\u6E90\uFF0C\u8986\u76D6 ${moduleCount} \u4E2A\u6E90\u7801\u6A21\u5757`);
|
|
1139
1303
|
}
|
|
1140
1304
|
if (result.subPackages.length > 0) {
|
|
1141
|
-
|
|
1305
|
+
_chunkHKSOVHNEcjs.logger_default.info("\u5206\u5305\u914D\u7F6E\uFF1A");
|
|
1142
1306
|
for (const descriptor of result.subPackages) {
|
|
1143
1307
|
const segments = [descriptor.root];
|
|
1144
1308
|
if (descriptor.name) {
|
|
@@ -1147,15 +1311,15 @@ function printAnalysisSummary(result) {
|
|
|
1147
1311
|
if (descriptor.independent) {
|
|
1148
1312
|
segments.push("\u72EC\u7ACB\u6784\u5EFA");
|
|
1149
1313
|
}
|
|
1150
|
-
|
|
1314
|
+
_chunkHKSOVHNEcjs.logger_default.info(`- ${segments.join("\uFF0C")}`);
|
|
1151
1315
|
}
|
|
1152
1316
|
}
|
|
1153
1317
|
const duplicates = result.modules.filter((module) => module.packages.length > 1);
|
|
1154
1318
|
if (duplicates.length === 0) {
|
|
1155
|
-
|
|
1319
|
+
_chunkHKSOVHNEcjs.logger_default.info("\u672A\u68C0\u6D4B\u5230\u8DE8\u5305\u590D\u7528\u7684\u6E90\u7801\u6A21\u5757\u3002");
|
|
1156
1320
|
return;
|
|
1157
1321
|
}
|
|
1158
|
-
|
|
1322
|
+
_chunkHKSOVHNEcjs.logger_default.info(`\u8DE8\u5305\u590D\u7528/\u590D\u5236\u6E90\u7801\u5171 ${duplicates.length} \u9879\uFF1A`);
|
|
1159
1323
|
const limit = 10;
|
|
1160
1324
|
const entries = duplicates.slice(0, limit);
|
|
1161
1325
|
for (const module of entries) {
|
|
@@ -1163,10 +1327,10 @@ function printAnalysisSummary(result) {
|
|
|
1163
1327
|
const label = _nullishCoalesce(packageLabelMap.get(pkgRef.packageId), () => ( pkgRef.packageId));
|
|
1164
1328
|
return `${label} \u2192 ${pkgRef.files.join(", ")}`;
|
|
1165
1329
|
}).join("\uFF1B");
|
|
1166
|
-
|
|
1330
|
+
_chunkHKSOVHNEcjs.logger_default.info(`- ${module.source} (${module.sourceType})\uFF1A${placements}`);
|
|
1167
1331
|
}
|
|
1168
1332
|
if (duplicates.length > limit) {
|
|
1169
|
-
|
|
1333
|
+
_chunkHKSOVHNEcjs.logger_default.info(`- \u2026\u5176\u4F59 ${duplicates.length - limit} \u9879\u8BF7\u4F7F\u7528 \`weapp-vite analyze --json\` \u67E5\u770B`);
|
|
1170
1334
|
}
|
|
1171
1335
|
}
|
|
1172
1336
|
function registerAnalyzeCommand(cli2) {
|
|
@@ -1176,15 +1340,15 @@ function registerAnalyzeCommand(cli2) {
|
|
|
1176
1340
|
const targets = resolveRuntimeTargets(options);
|
|
1177
1341
|
logRuntimeTarget(targets);
|
|
1178
1342
|
if (!targets.runMini) {
|
|
1179
|
-
|
|
1343
|
+
_chunkHKSOVHNEcjs.logger_default.warn("\u5F53\u524D\u547D\u4EE4\u4EC5\u652F\u6301\u5C0F\u7A0B\u5E8F\u5E73\u53F0\uFF0C\u8BF7\u901A\u8FC7 --platform weapp \u6307\u5B9A\u76EE\u6807\u3002");
|
|
1180
1344
|
return;
|
|
1181
1345
|
}
|
|
1182
1346
|
if (targets.runWeb) {
|
|
1183
|
-
|
|
1347
|
+
_chunkHKSOVHNEcjs.logger_default.warn("\u5206\u6790\u547D\u4EE4\u6682\u4E0D\u652F\u6301 Web \u5E73\u53F0\uFF0C\u5C06\u5FFD\u7565\u76F8\u5173\u914D\u7F6E\u3002");
|
|
1184
1348
|
}
|
|
1185
1349
|
const inlineConfig = createInlineConfig(targets.mpPlatform);
|
|
1186
1350
|
try {
|
|
1187
|
-
const ctx = await
|
|
1351
|
+
const ctx = await _chunkAUQJOLJScjs.createCompilerContext.call(void 0, {
|
|
1188
1352
|
cwd: root,
|
|
1189
1353
|
mode: _nullishCoalesce(options.mode, () => ( "production")),
|
|
1190
1354
|
configFile,
|
|
@@ -1196,13 +1360,13 @@ function registerAnalyzeCommand(cli2) {
|
|
|
1196
1360
|
let writtenPath;
|
|
1197
1361
|
if (outputOption) {
|
|
1198
1362
|
const configService = ctx.configService;
|
|
1199
|
-
const baseDir = _nullishCoalesce(_optionalChain([configService, 'optionalAccess',
|
|
1363
|
+
const baseDir = _nullishCoalesce(_optionalChain([configService, 'optionalAccess', _13 => _13.cwd]), () => ( _process2.default.cwd()));
|
|
1200
1364
|
const resolvedOutputPath = _pathe2.default.isAbsolute(outputOption) ? outputOption : _pathe2.default.resolve(baseDir, outputOption);
|
|
1201
1365
|
await _fsextra2.default.ensureDir(_pathe2.default.dirname(resolvedOutputPath));
|
|
1202
1366
|
await _fsextra2.default.writeFile(resolvedOutputPath, `${JSON.stringify(result, null, 2)}
|
|
1203
1367
|
`, "utf8");
|
|
1204
1368
|
const relativeOutput = configService ? configService.relativeCwd(resolvedOutputPath) : resolvedOutputPath;
|
|
1205
|
-
|
|
1369
|
+
_chunkHKSOVHNEcjs.logger_default.success(`\u5206\u6790\u7ED3\u679C\u5DF2\u5199\u5165 ${relativeOutput}`);
|
|
1206
1370
|
writtenPath = resolvedOutputPath;
|
|
1207
1371
|
}
|
|
1208
1372
|
if (outputJson) {
|
|
@@ -1212,22 +1376,23 @@ function registerAnalyzeCommand(cli2) {
|
|
|
1212
1376
|
}
|
|
1213
1377
|
} else {
|
|
1214
1378
|
printAnalysisSummary(result);
|
|
1379
|
+
await startAnalyzeDashboard(result);
|
|
1215
1380
|
}
|
|
1216
1381
|
} catch (error) {
|
|
1217
|
-
|
|
1382
|
+
_chunkHKSOVHNEcjs.logger_default.error(error);
|
|
1218
1383
|
_process2.default.exitCode = 1;
|
|
1219
1384
|
}
|
|
1220
1385
|
});
|
|
1221
1386
|
}
|
|
1222
1387
|
|
|
1223
1388
|
// src/cli/commands/build.ts
|
|
1224
|
-
|
|
1389
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1225
1390
|
|
|
1226
1391
|
// src/cli/logBuildAppFinish.ts
|
|
1227
|
-
|
|
1392
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1228
1393
|
|
|
1229
1394
|
// ../../node_modules/.pnpm/package-manager-detector@1.5.0/node_modules/package-manager-detector/dist/commands.mjs
|
|
1230
|
-
|
|
1395
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1231
1396
|
function dashDashArg(agent, agentCommand) {
|
|
1232
1397
|
return (args) => {
|
|
1233
1398
|
if (args.length > 1) {
|
|
@@ -1372,15 +1537,15 @@ function logBuildAppFinish(configService, webServer, options = {}) {
|
|
|
1372
1537
|
const urls = webServer.resolvedUrls;
|
|
1373
1538
|
const candidates = urls ? [..._nullishCoalesce(urls.local, () => ( [])), ..._nullishCoalesce(urls.network, () => ( []))] : [];
|
|
1374
1539
|
if (candidates.length > 0) {
|
|
1375
|
-
|
|
1540
|
+
_chunkHKSOVHNEcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8\uFF0C\u6D4F\u89C8\u5668\u8BBF\u95EE\uFF1A");
|
|
1376
1541
|
for (const url of candidates) {
|
|
1377
|
-
|
|
1542
|
+
_chunkHKSOVHNEcjs.logger_default.info(` \u279C ${url}`);
|
|
1378
1543
|
}
|
|
1379
1544
|
} else {
|
|
1380
|
-
|
|
1545
|
+
_chunkHKSOVHNEcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8");
|
|
1381
1546
|
}
|
|
1382
1547
|
} else {
|
|
1383
|
-
|
|
1548
|
+
_chunkHKSOVHNEcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8");
|
|
1384
1549
|
}
|
|
1385
1550
|
logBuildAppFinishOnlyShowOnce = true;
|
|
1386
1551
|
return;
|
|
@@ -1394,32 +1559,32 @@ function logBuildAppFinish(configService, webServer, options = {}) {
|
|
|
1394
1559
|
args: ["run", "open"]
|
|
1395
1560
|
}));
|
|
1396
1561
|
const devCommand = `${command} ${args.join(" ")}`;
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1562
|
+
_chunkHKSOVHNEcjs.logger_default.success("\u5E94\u7528\u6784\u5EFA\u5B8C\u6210\uFF01\u9884\u89C8\u65B9\u5F0F ( `2` \u79CD\u9009\u5176\u4E00\u5373\u53EF)\uFF1A");
|
|
1563
|
+
_chunkHKSOVHNEcjs.logger_default.info(`\u6267\u884C \`${devCommand}\` \u53EF\u4EE5\u76F4\u63A5\u5728 \`\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\` \u91CC\u6253\u5F00\u5F53\u524D\u5E94\u7528`);
|
|
1564
|
+
_chunkHKSOVHNEcjs.logger_default.info("\u6216\u624B\u52A8\u6253\u5F00\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\uFF0C\u5BFC\u5165\u6839\u76EE\u5F55(`project.config.json` \u6587\u4EF6\u6240\u5728\u7684\u76EE\u5F55)\uFF0C\u5373\u53EF\u9884\u89C8\u6548\u679C");
|
|
1400
1565
|
if (!skipWeb && webServer) {
|
|
1401
1566
|
const urls = webServer.resolvedUrls;
|
|
1402
1567
|
const candidates = urls ? [..._nullishCoalesce(urls.local, () => ( [])), ..._nullishCoalesce(urls.network, () => ( []))] : [];
|
|
1403
1568
|
if (candidates.length > 0) {
|
|
1404
|
-
|
|
1569
|
+
_chunkHKSOVHNEcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8\uFF0C\u6D4F\u89C8\u5668\u8BBF\u95EE\uFF1A");
|
|
1405
1570
|
for (const url of candidates) {
|
|
1406
|
-
|
|
1571
|
+
_chunkHKSOVHNEcjs.logger_default.info(` \u279C ${url}`);
|
|
1407
1572
|
}
|
|
1408
1573
|
} else {
|
|
1409
|
-
|
|
1574
|
+
_chunkHKSOVHNEcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8");
|
|
1410
1575
|
}
|
|
1411
1576
|
}
|
|
1412
1577
|
logBuildAppFinishOnlyShowOnce = true;
|
|
1413
1578
|
}
|
|
1414
1579
|
|
|
1415
1580
|
// src/cli/openIde.ts
|
|
1416
|
-
|
|
1581
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1417
1582
|
var _weappidecli = require('weapp-ide-cli');
|
|
1418
1583
|
async function openIde() {
|
|
1419
1584
|
try {
|
|
1420
1585
|
await _weappidecli.parse.call(void 0, ["open", "-p"]);
|
|
1421
1586
|
} catch (error) {
|
|
1422
|
-
|
|
1587
|
+
_chunkHKSOVHNEcjs.logger_default.error(error);
|
|
1423
1588
|
}
|
|
1424
1589
|
}
|
|
1425
1590
|
|
|
@@ -1434,28 +1599,35 @@ function registerBuildCommand(cli2) {
|
|
|
1434
1599
|
).option(
|
|
1435
1600
|
"--emptyOutDir",
|
|
1436
1601
|
`[boolean] force empty outDir when it's outside of root`
|
|
1437
|
-
).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).action(async (root, options) => {
|
|
1602
|
+
).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).option("--analyze", `[boolean] \u8F93\u51FA\u5206\u5305\u5206\u6790\u4EEA\u8868\u76D8`, { default: false }).action(async (root, options) => {
|
|
1438
1603
|
filterDuplicateOptions(options);
|
|
1439
1604
|
const configFile = resolveConfigFile(options);
|
|
1440
1605
|
const targets = resolveRuntimeTargets(options);
|
|
1441
1606
|
logRuntimeTarget(targets);
|
|
1442
1607
|
const inlineConfig = createInlineConfig(targets.mpPlatform);
|
|
1443
|
-
const
|
|
1608
|
+
const ctx = await _chunkAUQJOLJScjs.createCompilerContext.call(void 0, {
|
|
1444
1609
|
cwd: root,
|
|
1445
1610
|
mode: _nullishCoalesce(options.mode, () => ( "production")),
|
|
1446
1611
|
configFile,
|
|
1447
1612
|
inlineConfig
|
|
1448
1613
|
});
|
|
1614
|
+
const { buildService, configService, webService } = ctx;
|
|
1615
|
+
const enableAnalyze = Boolean(options.analyze && targets.runMini);
|
|
1616
|
+
let analyzeHandle;
|
|
1449
1617
|
if (targets.runMini) {
|
|
1450
1618
|
await buildService.build(options);
|
|
1619
|
+
if (enableAnalyze) {
|
|
1620
|
+
const analyzeResult = await analyzeSubpackages(ctx);
|
|
1621
|
+
analyzeHandle = await _asyncNullishCoalesce(await startAnalyzeDashboard(analyzeResult, { watch: true }), async () => ( void 0));
|
|
1622
|
+
}
|
|
1451
1623
|
}
|
|
1452
1624
|
const webConfig = configService.weappWebConfig;
|
|
1453
|
-
if (targets.runWeb && _optionalChain([webConfig, 'optionalAccess',
|
|
1625
|
+
if (targets.runWeb && _optionalChain([webConfig, 'optionalAccess', _14 => _14.enabled])) {
|
|
1454
1626
|
try {
|
|
1455
|
-
await _optionalChain([webService, 'optionalAccess',
|
|
1456
|
-
|
|
1627
|
+
await _optionalChain([webService, 'optionalAccess', _15 => _15.build, 'call', _16 => _16()]);
|
|
1628
|
+
_chunkHKSOVHNEcjs.logger_default.success(`Web \u6784\u5EFA\u5B8C\u6210\uFF0C\u8F93\u51FA\u76EE\u5F55\uFF1A${configService.relativeCwd(webConfig.outDir)}`);
|
|
1457
1629
|
} catch (error) {
|
|
1458
|
-
|
|
1630
|
+
_chunkHKSOVHNEcjs.logger_default.error(error);
|
|
1459
1631
|
throw error;
|
|
1460
1632
|
}
|
|
1461
1633
|
}
|
|
@@ -1465,11 +1637,14 @@ function registerBuildCommand(cli2) {
|
|
|
1465
1637
|
if (options.open && targets.runMini) {
|
|
1466
1638
|
await openIde();
|
|
1467
1639
|
}
|
|
1640
|
+
if (analyzeHandle) {
|
|
1641
|
+
await analyzeHandle.waitForExit();
|
|
1642
|
+
}
|
|
1468
1643
|
});
|
|
1469
1644
|
}
|
|
1470
1645
|
|
|
1471
1646
|
// src/cli/commands/create.ts
|
|
1472
|
-
|
|
1647
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1473
1648
|
var _init = require('@weapp-core/init');
|
|
1474
1649
|
function registerCreateCommand(cli2) {
|
|
1475
1650
|
cli2.command("create [outDir]", "create project").option("-t, --template <type>", "template type").action(async (outDir, options) => {
|
|
@@ -1478,11 +1653,11 @@ function registerCreateCommand(cli2) {
|
|
|
1478
1653
|
}
|
|
1479
1654
|
|
|
1480
1655
|
// src/cli/commands/generate.ts
|
|
1481
|
-
|
|
1656
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1482
1657
|
|
|
1483
1658
|
|
|
1484
1659
|
// src/schematics.ts
|
|
1485
|
-
|
|
1660
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1486
1661
|
|
|
1487
1662
|
var _schematics = require('@weapp-core/schematics');
|
|
1488
1663
|
var _shared = require('@weapp-core/shared');
|
|
@@ -1524,11 +1699,11 @@ async function loadTemplate(template, context) {
|
|
|
1524
1699
|
return void 0;
|
|
1525
1700
|
}
|
|
1526
1701
|
function resolveTemplate(templates, type, fileType) {
|
|
1527
|
-
const scoped = _optionalChain([templates, 'optionalAccess',
|
|
1702
|
+
const scoped = _optionalChain([templates, 'optionalAccess', _17 => _17[type], 'optionalAccess', _18 => _18[fileType]]);
|
|
1528
1703
|
if (scoped !== void 0) {
|
|
1529
1704
|
return scoped;
|
|
1530
1705
|
}
|
|
1531
|
-
return _optionalChain([templates, 'optionalAccess',
|
|
1706
|
+
return _optionalChain([templates, 'optionalAccess', _19 => _19.shared, 'optionalAccess', _20 => _20[fileType]]);
|
|
1532
1707
|
}
|
|
1533
1708
|
async function generate(options) {
|
|
1534
1709
|
let { fileName, outDir, extensions, type, cwd, templates } = _shared.defu.call(void 0, options, {
|
|
@@ -1583,13 +1758,13 @@ async function generate(options) {
|
|
|
1583
1758
|
for (const { code, fileName: fileName2 } of files) {
|
|
1584
1759
|
if (code !== void 0) {
|
|
1585
1760
|
await _fsextra2.default.outputFile(_pathe2.default.resolve(basepath, fileName2), code, "utf8");
|
|
1586
|
-
|
|
1761
|
+
_chunkHKSOVHNEcjs.logger_default.success(`${composePath(outDir, fileName2)} \u521B\u5EFA\u6210\u529F\uFF01`);
|
|
1587
1762
|
}
|
|
1588
1763
|
}
|
|
1589
1764
|
}
|
|
1590
1765
|
|
|
1591
1766
|
// src/cli/loadConfig.ts
|
|
1592
|
-
|
|
1767
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1593
1768
|
|
|
1594
1769
|
|
|
1595
1770
|
|
|
@@ -1605,14 +1780,14 @@ async function loadConfig(configFile) {
|
|
|
1605
1780
|
mode: "development"
|
|
1606
1781
|
};
|
|
1607
1782
|
const loaded = await _vite.loadConfigFromFile.call(void 0, configEnv, resolvedConfigFile, cwd);
|
|
1608
|
-
const weappConfigFilePath = await
|
|
1783
|
+
const weappConfigFilePath = await _chunkHKSOVHNEcjs.resolveWeappConfigFile.call(void 0, {
|
|
1609
1784
|
root: cwd,
|
|
1610
1785
|
specified: resolvedConfigFile
|
|
1611
1786
|
});
|
|
1612
1787
|
let weappLoaded;
|
|
1613
1788
|
if (weappConfigFilePath) {
|
|
1614
1789
|
const normalizedWeappPath = _pathe2.default.resolve(weappConfigFilePath);
|
|
1615
|
-
const normalizedLoadedPath = _optionalChain([loaded, 'optionalAccess',
|
|
1790
|
+
const normalizedLoadedPath = _optionalChain([loaded, 'optionalAccess', _21 => _21.path]) ? _pathe2.default.resolve(loaded.path) : void 0;
|
|
1616
1791
|
if (normalizedLoadedPath && normalizedLoadedPath === normalizedWeappPath) {
|
|
1617
1792
|
weappLoaded = loaded;
|
|
1618
1793
|
} else {
|
|
@@ -1622,23 +1797,23 @@ async function loadConfig(configFile) {
|
|
|
1622
1797
|
if (!loaded && !weappLoaded) {
|
|
1623
1798
|
return void 0;
|
|
1624
1799
|
}
|
|
1625
|
-
const config = _nullishCoalesce(_optionalChain([loaded, 'optionalAccess',
|
|
1626
|
-
if (_optionalChain([weappLoaded, 'optionalAccess',
|
|
1800
|
+
const config = _nullishCoalesce(_optionalChain([loaded, 'optionalAccess', _22 => _22.config]), () => ( (_nullishCoalesce(_optionalChain([weappLoaded, 'optionalAccess', _23 => _23.config]), () => ( {})))));
|
|
1801
|
+
if (_optionalChain([weappLoaded, 'optionalAccess', _24 => _24.config, 'optionalAccess', _25 => _25.weapp])) {
|
|
1627
1802
|
config.weapp = _shared.defu.call(void 0,
|
|
1628
1803
|
weappLoaded.config.weapp,
|
|
1629
1804
|
_nullishCoalesce(config.weapp, () => ( {}))
|
|
1630
1805
|
);
|
|
1631
1806
|
}
|
|
1632
1807
|
const dependencySet = /* @__PURE__ */ new Set();
|
|
1633
|
-
for (const dependency of _nullishCoalesce(_optionalChain([loaded, 'optionalAccess',
|
|
1808
|
+
for (const dependency of _nullishCoalesce(_optionalChain([loaded, 'optionalAccess', _26 => _26.dependencies]), () => ( []))) {
|
|
1634
1809
|
dependencySet.add(dependency);
|
|
1635
1810
|
}
|
|
1636
|
-
for (const dependency of _nullishCoalesce(_optionalChain([weappLoaded, 'optionalAccess',
|
|
1811
|
+
for (const dependency of _nullishCoalesce(_optionalChain([weappLoaded, 'optionalAccess', _27 => _27.dependencies]), () => ( []))) {
|
|
1637
1812
|
dependencySet.add(dependency);
|
|
1638
1813
|
}
|
|
1639
1814
|
return {
|
|
1640
1815
|
config,
|
|
1641
|
-
path: _nullishCoalesce(_nullishCoalesce(_optionalChain([weappLoaded, 'optionalAccess',
|
|
1816
|
+
path: _nullishCoalesce(_nullishCoalesce(_optionalChain([weappLoaded, 'optionalAccess', _28 => _28.path]), () => ( _optionalChain([loaded, 'optionalAccess', _29 => _29.path]))), () => ( resolvedConfigFile)),
|
|
1642
1817
|
dependencies: Array.from(dependencySet)
|
|
1643
1818
|
};
|
|
1644
1819
|
}
|
|
@@ -1658,26 +1833,26 @@ function registerGenerateCommand(cli2) {
|
|
|
1658
1833
|
fileName = "app";
|
|
1659
1834
|
}
|
|
1660
1835
|
if (filepath === void 0) {
|
|
1661
|
-
|
|
1836
|
+
_chunkHKSOVHNEcjs.logger_default.error("weapp-vite generate <outDir> \u547D\u4EE4\u5FC5\u987B\u4F20\u5165\u8DEF\u5F84\u53C2\u6570 outDir");
|
|
1662
1837
|
return;
|
|
1663
1838
|
}
|
|
1664
1839
|
if (options.page) {
|
|
1665
1840
|
type = "page";
|
|
1666
1841
|
}
|
|
1667
|
-
const generateOptions = _optionalChain([config, 'optionalAccess',
|
|
1668
|
-
fileName = _nullishCoalesce(_optionalChain([generateOptions, 'optionalAccess',
|
|
1842
|
+
const generateOptions = _optionalChain([config, 'optionalAccess', _30 => _30.config, 'access', _31 => _31.weapp, 'optionalAccess', _32 => _32.generate]);
|
|
1843
|
+
fileName = _nullishCoalesce(_optionalChain([generateOptions, 'optionalAccess', _33 => _33.filenames, 'optionalAccess', _34 => _34[type]]), () => ( fileName));
|
|
1669
1844
|
await generate({
|
|
1670
|
-
outDir: _pathe2.default.join(_nullishCoalesce(_optionalChain([generateOptions, 'optionalAccess',
|
|
1845
|
+
outDir: _pathe2.default.join(_nullishCoalesce(_optionalChain([generateOptions, 'optionalAccess', _35 => _35.dirs, 'optionalAccess', _36 => _36[type]]), () => ( "")), filepath),
|
|
1671
1846
|
type,
|
|
1672
1847
|
fileName,
|
|
1673
|
-
extensions: _optionalChain([generateOptions, 'optionalAccess',
|
|
1674
|
-
templates: _optionalChain([generateOptions, 'optionalAccess',
|
|
1848
|
+
extensions: _optionalChain([generateOptions, 'optionalAccess', _37 => _37.extensions]),
|
|
1849
|
+
templates: _optionalChain([generateOptions, 'optionalAccess', _38 => _38.templates])
|
|
1675
1850
|
});
|
|
1676
1851
|
});
|
|
1677
1852
|
}
|
|
1678
1853
|
|
|
1679
1854
|
// src/cli/commands/init.ts
|
|
1680
|
-
|
|
1855
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1681
1856
|
|
|
1682
1857
|
function registerInitCommand(cli2) {
|
|
1683
1858
|
cli2.command("init").action(async () => {
|
|
@@ -1686,26 +1861,26 @@ function registerInitCommand(cli2) {
|
|
|
1686
1861
|
command: "weapp-vite"
|
|
1687
1862
|
});
|
|
1688
1863
|
} catch (error) {
|
|
1689
|
-
|
|
1864
|
+
_chunkHKSOVHNEcjs.logger_default.error(error);
|
|
1690
1865
|
}
|
|
1691
1866
|
});
|
|
1692
1867
|
}
|
|
1693
1868
|
|
|
1694
1869
|
// src/cli/commands/npm.ts
|
|
1695
|
-
|
|
1870
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1696
1871
|
|
|
1697
1872
|
function registerNpmCommand(cli2) {
|
|
1698
1873
|
cli2.command("npm").alias("build:npm").alias("build-npm").action(async () => {
|
|
1699
1874
|
try {
|
|
1700
1875
|
await _weappidecli.parse.call(void 0, ["build-npm", "-p"]);
|
|
1701
1876
|
} catch (error) {
|
|
1702
|
-
|
|
1877
|
+
_chunkHKSOVHNEcjs.logger_default.error(error);
|
|
1703
1878
|
}
|
|
1704
1879
|
});
|
|
1705
1880
|
}
|
|
1706
1881
|
|
|
1707
1882
|
// src/cli/commands/open.ts
|
|
1708
|
-
|
|
1883
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1709
1884
|
function registerOpenCommand(cli2) {
|
|
1710
1885
|
cli2.command("open").action(async () => {
|
|
1711
1886
|
await openIde();
|
|
@@ -1713,30 +1888,59 @@ function registerOpenCommand(cli2) {
|
|
|
1713
1888
|
}
|
|
1714
1889
|
|
|
1715
1890
|
// src/cli/commands/serve.ts
|
|
1716
|
-
|
|
1891
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
1717
1892
|
function registerServeCommand(cli2) {
|
|
1718
|
-
cli2.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).option("-p, --platform <platform>", `[string] target platform (weapp | h5)`).action(async (root, options) => {
|
|
1893
|
+
cli2.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).option("-p, --platform <platform>", `[string] target platform (weapp | h5)`).option("--analyze", `[boolean] \u542F\u52A8\u5206\u5305\u5206\u6790\u4EEA\u8868\u76D8 (\u5B9E\u9A8C\u7279\u6027)`, { default: false }).action(async (root, options) => {
|
|
1719
1894
|
filterDuplicateOptions(options);
|
|
1720
1895
|
const configFile = resolveConfigFile(options);
|
|
1721
1896
|
const targets = resolveRuntimeTargets(options);
|
|
1722
1897
|
logRuntimeTarget(targets);
|
|
1723
1898
|
const inlineConfig = createInlineConfig(targets.mpPlatform);
|
|
1724
|
-
const
|
|
1899
|
+
const ctx = await _chunkAUQJOLJScjs.createCompilerContext.call(void 0, {
|
|
1725
1900
|
cwd: root,
|
|
1726
1901
|
mode: _nullishCoalesce(options.mode, () => ( "development")),
|
|
1727
1902
|
isDev: true,
|
|
1728
1903
|
configFile,
|
|
1729
1904
|
inlineConfig
|
|
1730
1905
|
});
|
|
1906
|
+
const { buildService, configService, webService } = ctx;
|
|
1907
|
+
const enableAnalyze = Boolean(options.analyze && targets.runMini);
|
|
1908
|
+
let analyzeHandle;
|
|
1909
|
+
const triggerAnalyzeUpdate = async () => {
|
|
1910
|
+
if (!analyzeHandle) {
|
|
1911
|
+
return;
|
|
1912
|
+
}
|
|
1913
|
+
const next = await analyzeSubpackages(ctx);
|
|
1914
|
+
await analyzeHandle.update(next);
|
|
1915
|
+
};
|
|
1731
1916
|
if (targets.runMini) {
|
|
1732
|
-
await buildService.build(options);
|
|
1917
|
+
const buildResult = await buildService.build(options);
|
|
1918
|
+
if (enableAnalyze) {
|
|
1919
|
+
const initialResult = await analyzeSubpackages(ctx);
|
|
1920
|
+
analyzeHandle = await _asyncNullishCoalesce(await startAnalyzeDashboard(initialResult, { watch: true }), async () => ( void 0));
|
|
1921
|
+
if (analyzeHandle && buildResult && typeof buildResult.on === "function") {
|
|
1922
|
+
const watcher = buildResult;
|
|
1923
|
+
let updating = false;
|
|
1924
|
+
watcher.on("event", (event) => {
|
|
1925
|
+
if (event.code !== "END" || updating) {
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
updating = true;
|
|
1929
|
+
triggerAnalyzeUpdate().finally(() => {
|
|
1930
|
+
updating = false;
|
|
1931
|
+
});
|
|
1932
|
+
});
|
|
1933
|
+
} else if (analyzeHandle) {
|
|
1934
|
+
await triggerAnalyzeUpdate();
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1733
1937
|
}
|
|
1734
1938
|
let webServer;
|
|
1735
1939
|
if (targets.runWeb) {
|
|
1736
1940
|
try {
|
|
1737
|
-
webServer = await _optionalChain([webService, 'optionalAccess',
|
|
1941
|
+
webServer = await _optionalChain([webService, 'optionalAccess', _39 => _39.startDevServer, 'call', _40 => _40()]);
|
|
1738
1942
|
} catch (error) {
|
|
1739
|
-
|
|
1943
|
+
_chunkHKSOVHNEcjs.logger_default.error(error);
|
|
1740
1944
|
throw error;
|
|
1741
1945
|
}
|
|
1742
1946
|
}
|
|
@@ -1748,13 +1952,16 @@ function registerServeCommand(cli2) {
|
|
|
1748
1952
|
if (options.open && targets.runMini) {
|
|
1749
1953
|
await openIde();
|
|
1750
1954
|
}
|
|
1955
|
+
if (analyzeHandle) {
|
|
1956
|
+
await analyzeHandle.waitForExit();
|
|
1957
|
+
}
|
|
1751
1958
|
});
|
|
1752
1959
|
}
|
|
1753
1960
|
|
|
1754
1961
|
// src/cli.ts
|
|
1755
1962
|
var cli = cac("weapp-vite");
|
|
1756
1963
|
try {
|
|
1757
|
-
|
|
1964
|
+
_chunkHKSOVHNEcjs.checkRuntime.call(void 0, {
|
|
1758
1965
|
bun: "0.0.0",
|
|
1759
1966
|
deno: "0.0.0",
|
|
1760
1967
|
node: "20.19.0"
|
|
@@ -1773,5 +1980,5 @@ registerNpmCommand(cli);
|
|
|
1773
1980
|
registerGenerateCommand(cli);
|
|
1774
1981
|
registerCreateCommand(cli);
|
|
1775
1982
|
cli.help();
|
|
1776
|
-
cli.version(
|
|
1983
|
+
cli.version(_chunkHKSOVHNEcjs.VERSION);
|
|
1777
1984
|
cli.parse();
|