weapp-vite 6.16.2 → 6.16.4
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-routes.mjs +1 -1
- package/dist/cli.mjs +65 -69
- package/dist/{config-BiVvWW9d.d.mts → config-CXABkCb8.d.mts} +46 -7
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/{createContext-D69xinBq.mjs → createContext-CoTaL8he.mjs} +200 -90
- package/dist/docs/volar.md +19 -1
- package/dist/{file-Dnwa6tm_.mjs → file-D57m5ljp.mjs} +1 -1
- package/dist/file-Dxf7qCi6.mjs +2 -0
- package/dist/getInstance-BWhJaTcd.mjs +2 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/json.d.mts +1 -1
- package/dist/{mcp-BzcrPiku.mjs → mcp-DV3K2AVD.mjs} +6 -4
- package/dist/mcp.d.mts +4 -3
- package/dist/mcp.mjs +2 -2
- package/dist/{pluginHost-SJdl15d3.mjs → pluginHost-BEnGeaSo.mjs} +7 -4
- package/dist/types.d.mts +1 -1
- package/package.json +11 -11
- package/dist/file-C0XHk9ks.mjs +0 -2
- package/dist/getInstance-GyYMx1dz.mjs +0 -2
package/dist/auto-routes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as getRouteRuntimeGlobalKeys, i as getCompilerContext } from "./createContext-CoTaL8he.mjs";
|
|
2
2
|
//#region src/auto-routes.ts
|
|
3
3
|
const ROUTE_RUNTIME_OVERRIDE_KEY = Symbol.for("weapp-vite.route-runtime");
|
|
4
4
|
function createGetter(resolver) {
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as getDefaultIdeProjectRoot, S as createCjsConfigLoadError, T as isPathInside, _ as resolveWeappConfigFile, b as loadViteConfigFile, f as resolveWeappViteTarget, h as resolveHmrProfileJsonPath, m as SHARED_CHUNK_VIRTUAL_PREFIX, n as syncProjectSupportFiles, p as createSharedBuildConfig, r as syncManagedTsconfigBootstrapFiles, s as formatBytes, t as createCompilerContext, v as checkRuntime, w as shouldPassPlatformArgToIdeOpen, x as parseCommentJson, y as getProjectConfigFileName } from "./createContext-CoTaL8he.mjs";
|
|
2
2
|
import { r as logger_default, t as colors } from "./logger-CgxdNjvb.mjs";
|
|
3
|
-
import { h as VERSION } from "./file-
|
|
4
|
-
import {
|
|
3
|
+
import { h as VERSION } from "./file-D57m5ljp.mjs";
|
|
4
|
+
import { o as resolveWeappMcpConfig, s as startWeappViteMcpServer } from "./mcp-DV3K2AVD.mjs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import path, { posix } from "pathe";
|
|
7
7
|
import { defu } from "@weapp-core/shared";
|
|
@@ -1127,7 +1127,8 @@ function createDashboardRuntimeEvent(input) {
|
|
|
1127
1127
|
timestamp: formatEventTimestamp(),
|
|
1128
1128
|
source: input.source ?? "weapp-vite",
|
|
1129
1129
|
durationMs: input.durationMs,
|
|
1130
|
-
tags: input.tags
|
|
1130
|
+
tags: input.tags,
|
|
1131
|
+
profile: input.profile
|
|
1131
1132
|
};
|
|
1132
1133
|
}
|
|
1133
1134
|
function readDashboardManifest(packageJsonPath) {
|
|
@@ -1553,7 +1554,7 @@ function isUiEnabled(options) {
|
|
|
1553
1554
|
function logRuntimeTarget(targets, options = {}) {
|
|
1554
1555
|
if (options.silent) return;
|
|
1555
1556
|
if (targets.label === "config") {
|
|
1556
|
-
const resolvedPlatform = targets.
|
|
1557
|
+
const resolvedPlatform = targets.platform ?? options.resolvedConfigPlatform;
|
|
1557
1558
|
if (resolvedPlatform) {
|
|
1558
1559
|
logger_default.info(`目标平台:${colors.green(resolvedPlatform)}`);
|
|
1559
1560
|
return;
|
|
@@ -1565,56 +1566,18 @@ function logRuntimeTarget(targets, options = {}) {
|
|
|
1565
1566
|
}
|
|
1566
1567
|
function resolveRuntimeTargets(options) {
|
|
1567
1568
|
const rawPlatform = typeof options.platform === "string" ? options.platform : typeof options.p === "string" ? options.p : void 0;
|
|
1568
|
-
|
|
1569
|
-
runMini: true,
|
|
1570
|
-
runWeb: false,
|
|
1571
|
-
mpPlatform: void 0,
|
|
1572
|
-
label: "config",
|
|
1573
|
-
rawPlatform
|
|
1574
|
-
};
|
|
1575
|
-
const normalized = normalizeMiniPlatform(rawPlatform);
|
|
1576
|
-
const lowerRawPlatform = rawPlatform.toLowerCase();
|
|
1577
|
-
if (lowerRawPlatform === "all" || lowerRawPlatform === "both") return {
|
|
1578
|
-
runMini: true,
|
|
1579
|
-
runWeb: true,
|
|
1580
|
-
mpPlatform: void 0,
|
|
1581
|
-
label: "weapp + web",
|
|
1582
|
-
rawPlatform
|
|
1583
|
-
};
|
|
1584
|
-
if (!normalized) return {
|
|
1585
|
-
runMini: true,
|
|
1586
|
-
runWeb: false,
|
|
1587
|
-
mpPlatform: DEFAULT_MP_PLATFORM,
|
|
1588
|
-
label: DEFAULT_MP_PLATFORM,
|
|
1589
|
-
rawPlatform
|
|
1590
|
-
};
|
|
1591
|
-
if (normalized === "h5" || normalized === "web") return {
|
|
1592
|
-
runMini: false,
|
|
1593
|
-
runWeb: true,
|
|
1594
|
-
mpPlatform: void 0,
|
|
1595
|
-
label: normalized === "h5" ? "h5" : "web",
|
|
1596
|
-
rawPlatform
|
|
1597
|
-
};
|
|
1598
|
-
const mpPlatform = resolveMiniPlatform(normalized);
|
|
1599
|
-
if (mpPlatform) return {
|
|
1600
|
-
runMini: true,
|
|
1601
|
-
runWeb: false,
|
|
1602
|
-
mpPlatform,
|
|
1603
|
-
label: mpPlatform,
|
|
1604
|
-
rawPlatform
|
|
1605
|
-
};
|
|
1606
|
-
logger_default.warn(`未识别的平台 "${colors.yellow(rawPlatform)}",已回退到 ${colors.green(DEFAULT_MP_PLATFORM)}`);
|
|
1569
|
+
const target = resolveWeappViteTarget(rawPlatform, { warn: (message) => logger_default.warn(message) });
|
|
1607
1570
|
return {
|
|
1608
|
-
runMini:
|
|
1609
|
-
runWeb:
|
|
1610
|
-
|
|
1611
|
-
label:
|
|
1571
|
+
runMini: target.runMini,
|
|
1572
|
+
runWeb: target.runWeb,
|
|
1573
|
+
platform: target.kind === "miniprogram" ? target.platform : void 0,
|
|
1574
|
+
label: target.label,
|
|
1612
1575
|
rawPlatform
|
|
1613
1576
|
};
|
|
1614
1577
|
}
|
|
1615
|
-
function createInlineConfig(
|
|
1616
|
-
if (!
|
|
1617
|
-
return { weapp: { platform
|
|
1578
|
+
function createInlineConfig(platform) {
|
|
1579
|
+
if (!platform) return;
|
|
1580
|
+
return { weapp: { platform } };
|
|
1618
1581
|
}
|
|
1619
1582
|
//#endregion
|
|
1620
1583
|
//#region src/cli/commands/analyze.ts
|
|
@@ -1777,7 +1740,7 @@ function printHmrProfileAnalysisSummary(result, configService) {
|
|
|
1777
1740
|
}
|
|
1778
1741
|
}
|
|
1779
1742
|
function registerAnalyzeCommand(cli) {
|
|
1780
|
-
cli.command("analyze [root]", "analyze 两端包体与源码映射").option("--hmr-profile [file]", `[string | boolean] 分析 HMR JSONL profile,省略值时优先读取配置,否则回退到默认路径`).option("--json", `[boolean] 输出 JSON 结果`).option("--markdown", `[boolean] 输出 Markdown 报告`).option("--report <type>", `[string] 输出指定报告类型(pr)`).option("--budget-check", `[boolean] 检查 analyze 预算,超过预算时返回非 0 退出码`).option("--output <file>", `[string] 将分析结果写入指定文件(JSON 或 Markdown)`).option("-p, --platform <platform>", `[string] target platform (weapp |
|
|
1743
|
+
cli.command("analyze [root]", "analyze 两端包体与源码映射").option("--hmr-profile [file]", `[string | boolean] 分析 HMR JSONL profile,省略值时优先读取配置,否则回退到默认路径`).option("--json", `[boolean] 输出 JSON 结果`).option("--markdown", `[boolean] 输出 Markdown 报告`).option("--report <type>", `[string] 输出指定报告类型(pr)`).option("--budget-check", `[boolean] 检查 analyze 预算,超过预算时返回非 0 退出码`).option("--output <file>", `[string] 将分析结果写入指定文件(JSON 或 Markdown)`).option("-p, --platform <platform>", `[string] target platform (weapp | web)`).option("--project-config <path>", `[string] project config path (miniprogram only)`).action(async (root, options) => {
|
|
1781
1744
|
filterDuplicateOptions(options);
|
|
1782
1745
|
const configFile = resolveConfigFile(options);
|
|
1783
1746
|
const outputJson = coerceBooleanOption(options.json);
|
|
@@ -1787,7 +1750,7 @@ function registerAnalyzeCommand(cli) {
|
|
|
1787
1750
|
if (reportType && !outputPrReport) throw new Error(`不支持的 analyze report 类型:${reportType}`);
|
|
1788
1751
|
const budgetCheck = coerceBooleanOption(options.budgetCheck);
|
|
1789
1752
|
const targets = resolveRuntimeTargets(options);
|
|
1790
|
-
const inlineConfig = createInlineConfig(targets.
|
|
1753
|
+
const inlineConfig = createInlineConfig(targets.platform);
|
|
1791
1754
|
try {
|
|
1792
1755
|
const ctx = await createCompilerContext({
|
|
1793
1756
|
cwd: root,
|
|
@@ -1818,7 +1781,7 @@ function registerAnalyzeCommand(cli) {
|
|
|
1818
1781
|
return;
|
|
1819
1782
|
}
|
|
1820
1783
|
if (targets.runWeb) {
|
|
1821
|
-
const webResult = createWebAnalyzeResult(ctx.configService, { platform:
|
|
1784
|
+
const webResult = createWebAnalyzeResult(ctx.configService, { platform: "web" });
|
|
1822
1785
|
const writtenPath = await writeAnalyzeResult(webResult, outputOption, ctx.configService);
|
|
1823
1786
|
if (outputJson) {
|
|
1824
1787
|
if (!writtenPath) process.stdout.write(`${JSON.stringify(webResult, null, 2)}\n`);
|
|
@@ -1826,7 +1789,7 @@ function registerAnalyzeCommand(cli) {
|
|
|
1826
1789
|
return;
|
|
1827
1790
|
}
|
|
1828
1791
|
if (!targets.runMini) {
|
|
1829
|
-
logger_default.warn("当前命令不支持该平台,请通过 --platform weapp 或 --platform
|
|
1792
|
+
logger_default.warn("当前命令不支持该平台,请通过 --platform weapp 或 --platform web 指定目标。");
|
|
1830
1793
|
return;
|
|
1831
1794
|
}
|
|
1832
1795
|
const previousResult = await readLatestAnalyzeHistorySnapshot(ctx.configService);
|
|
@@ -2359,11 +2322,11 @@ function emitDashboardEvents$1(handle, events) {
|
|
|
2359
2322
|
handle?.emitRuntimeEvents(events);
|
|
2360
2323
|
}
|
|
2361
2324
|
function registerBuildCommand(cli) {
|
|
2362
|
-
cli.command("build [root]", "build for production").option("--target <target>", `[string] transpile target (default: 'modules')`).option("--outDir <dir>", `[string] output directory (default: dist)`).option("-p, --platform <platform>", `[string] target platform (weapp |
|
|
2325
|
+
cli.command("build [root]", "build for production").option("--target <target>", `[string] transpile target (default: 'modules')`).option("--outDir <dir>", `[string] output directory (default: dist)`).option("-p, --platform <platform>", `[string] target platform (weapp | web | all)`).option("--project-config <path>", `[string] project config path (miniprogram only)`).option("--sourcemap [output]", `[boolean | "inline" | "hidden"] output source maps for build (default: false)`).option("--minify [minifier]", "[boolean | \"terser\" | \"esbuild\"] enable/disable minification, or specify minifier to use (default: esbuild)").option("--emptyOutDir", `[boolean] force empty outDir when it's outside of root`).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("--trust-project", "[boolean] auto trust Wechat DevTools project on open", { default: true }).option("--ui", `[boolean] 启动调试 UI(当前提供分析视图)`, { default: false }).option("--analyze", `[boolean] 输出分包分析仪表盘`, { default: false }).action(async (root, options) => {
|
|
2363
2326
|
filterDuplicateOptions(options);
|
|
2364
2327
|
const configFile = resolveConfigFile(options);
|
|
2365
2328
|
const targets = resolveRuntimeTargets(options);
|
|
2366
|
-
const inlineConfig = createInlineConfig(targets.
|
|
2329
|
+
const inlineConfig = createInlineConfig(targets.platform);
|
|
2367
2330
|
const ctx = await createCompilerContext({
|
|
2368
2331
|
cwd: root,
|
|
2369
2332
|
mode: options.mode ?? "production",
|
|
@@ -2887,7 +2850,7 @@ async function runIdeCommand(action, root, options) {
|
|
|
2887
2850
|
const resolved = await resolveIdeCommandContext({
|
|
2888
2851
|
configFile,
|
|
2889
2852
|
mode: options.mode ?? "development",
|
|
2890
|
-
platform: targets.
|
|
2853
|
+
platform: targets.platform,
|
|
2891
2854
|
projectPath: root,
|
|
2892
2855
|
cliPlatform: targets.rawPlatform
|
|
2893
2856
|
});
|
|
@@ -2960,7 +2923,7 @@ async function runIdeCommand(action, root, options) {
|
|
|
2960
2923
|
* @description 注册 IDE 相关子命令。
|
|
2961
2924
|
*/
|
|
2962
2925
|
function registerIdeCommand(cli) {
|
|
2963
|
-
cli.command("ide [action] [root]", "run Wechat DevTools utility actions and log bridge commands").option("-o, --open", "[boolean] open ide before attaching log bridge").option("-p, --platform <platform>", "[string] target platform (weapp |
|
|
2926
|
+
cli.command("ide [action] [root]", "run Wechat DevTools utility actions and log bridge commands").option("-o, --open", "[boolean] open ide before attaching log bridge").option("-p, --platform <platform>", "[string] target platform (weapp | web)").option("--project-config <path>", "[string] project config path (miniprogram only)").option("--ticket <value>", "[string] ticket used by `ide ticket:set`").option("--trust-project", "[boolean] auto trust Wechat DevTools project on open", { default: true }).action(async (action, root, options) => {
|
|
2964
2927
|
await runIdeCommand(action, root, options);
|
|
2965
2928
|
});
|
|
2966
2929
|
}
|
|
@@ -3341,6 +3304,7 @@ async function handleServer(options) {
|
|
|
3341
3304
|
endpoint: options.endpoint,
|
|
3342
3305
|
host: options.host,
|
|
3343
3306
|
port: resolvePort(options.port),
|
|
3307
|
+
restEndpoint: options.rest === false ? false : options.restEndpoint,
|
|
3344
3308
|
transport: resolvedTransport,
|
|
3345
3309
|
unref: options.unref,
|
|
3346
3310
|
workspaceRoot: options.workspaceRoot
|
|
@@ -3351,7 +3315,7 @@ async function handleServer(options) {
|
|
|
3351
3315
|
})) logger_default.info(line);
|
|
3352
3316
|
}
|
|
3353
3317
|
function registerMcpCommand(cli) {
|
|
3354
|
-
cli.command("mcp [...args]", "start weapp-vite MCP server or manage MCP client onboarding").option("--transport <type>", "[string] stdio | streamable-http | command | http", { default: "stdio" }).option("--host <host>", "[string] streamable-http host").option("--port <port>", "[number] streamable-http port").option("--endpoint <path>", "[string] streamable-http endpoint path").option("--unref", "[boolean] unref HTTP server to not block process exit").option("--url <url>", "[string] explicit HTTP MCP url").option("--workspace-root <path>", "[string] workspace root path, defaults to cwd").option("-y, --yes", "[boolean] write config without prompt").action(async (args, options) => {
|
|
3318
|
+
cli.command("mcp [...args]", "start weapp-vite MCP server or manage MCP client onboarding").option("--transport <type>", "[string] stdio | streamable-http | command | http", { default: "stdio" }).option("--host <host>", "[string] streamable-http host").option("--port <port>", "[number] streamable-http port").option("--endpoint <path>", "[string] streamable-http endpoint path").option("--rest-endpoint <path>", "[string] streamable-http REST runtime endpoint path").option("--no-rest", "[boolean] disable streamable-http REST runtime endpoints").option("--unref", "[boolean] unref HTTP server to not block process exit").option("--url <url>", "[string] explicit HTTP MCP url").option("--workspace-root <path>", "[string] workspace root path, defaults to cwd").option("-y, --yes", "[boolean] write config without prompt").action(async (args, options) => {
|
|
3355
3319
|
const [subcommand, client] = args;
|
|
3356
3320
|
if (subcommand === "init") {
|
|
3357
3321
|
if (!client) throw new Error("缺少客户端名称,请使用:wv mcp init <codex|claude-code|cursor>");
|
|
@@ -3386,14 +3350,14 @@ function registerNpmCommand(cli) {
|
|
|
3386
3350
|
//#endregion
|
|
3387
3351
|
//#region src/cli/commands/open.ts
|
|
3388
3352
|
function registerOpenCommand(cli) {
|
|
3389
|
-
cli.command("open [root]").option("-p, --platform <platform>", `[string] target platform (weapp |
|
|
3353
|
+
cli.command("open [root]").option("-p, --platform <platform>", `[string] target platform (weapp | web)`).option("--trust-project", "[boolean] auto trust Wechat DevTools project on open", { default: true }).action(async (root, options) => {
|
|
3390
3354
|
filterDuplicateOptions(options);
|
|
3391
3355
|
const configFile = resolveConfigFile(options);
|
|
3392
3356
|
const targets = resolveRuntimeTargets(options);
|
|
3393
3357
|
const { cwd, platform, projectPath, mpDistRoot, weappViteConfig } = await resolveIdeCommandContext({
|
|
3394
3358
|
configFile,
|
|
3395
3359
|
mode: options.mode ?? "development",
|
|
3396
|
-
platform: targets.
|
|
3360
|
+
platform: targets.platform,
|
|
3397
3361
|
projectPath: root,
|
|
3398
3362
|
cliPlatform: targets.rawPlatform
|
|
3399
3363
|
});
|
|
@@ -3416,18 +3380,24 @@ function resolvePrepareRoot(input) {
|
|
|
3416
3380
|
function formatPrepareSkipMessage$1(error) {
|
|
3417
3381
|
return `跳过 .weapp-vite 支持文件预生成:${error instanceof Error ? error.message : String(error)}`;
|
|
3418
3382
|
}
|
|
3383
|
+
function resolvePreparePlatform(options) {
|
|
3384
|
+
return typeof options.platform === "string" ? options.platform : typeof options.p === "string" ? options.p : void 0;
|
|
3385
|
+
}
|
|
3419
3386
|
function registerPrepareCommand(cli) {
|
|
3420
|
-
cli.command("prepare [...input]", "generate .weapp-vite support files").action(async (input, options) => {
|
|
3387
|
+
cli.command("prepare [...input]", "generate .weapp-vite support files").option("-p, --platform <platform>", `[string] target platform (weapp | web)`).action(async (input, options) => {
|
|
3421
3388
|
try {
|
|
3422
3389
|
filterDuplicateOptions(options);
|
|
3390
|
+
const cwd = path.resolve(resolvePrepareRoot(input));
|
|
3391
|
+
const cliPlatform = resolvePreparePlatform(options);
|
|
3423
3392
|
await syncProjectSupportFiles(await createCompilerContext({
|
|
3424
|
-
cwd
|
|
3393
|
+
cwd,
|
|
3425
3394
|
isDev: false,
|
|
3426
3395
|
mode: typeof options.mode === "string" ? options.mode : "development",
|
|
3427
3396
|
configFile: resolveConfigFile(options),
|
|
3428
3397
|
configLoader: "native",
|
|
3429
3398
|
syncSupportFiles: false,
|
|
3430
|
-
preloadAppEntry: false
|
|
3399
|
+
preloadAppEntry: false,
|
|
3400
|
+
...cliPlatform ? { cliPlatform } : {}
|
|
3431
3401
|
}));
|
|
3432
3402
|
logger_default.info("已生成 .weapp-vite 支持文件。");
|
|
3433
3403
|
} catch (error) {
|
|
@@ -3646,7 +3616,7 @@ function resolveRunnableHotkeyDefinition(input) {
|
|
|
3646
3616
|
}
|
|
3647
3617
|
//#endregion
|
|
3648
3618
|
//#region package.json
|
|
3649
|
-
var version = "6.16.
|
|
3619
|
+
var version = "6.16.4";
|
|
3650
3620
|
//#endregion
|
|
3651
3621
|
//#region src/cli/devHotkeys/format.ts
|
|
3652
3622
|
const FULLWIDTH_ASCII_START = 65281;
|
|
@@ -3751,6 +3721,7 @@ function createToggleMcpAction(options) {
|
|
|
3751
3721
|
endpoint: resolvedMcp.endpoint,
|
|
3752
3722
|
host: resolvedMcp.host,
|
|
3753
3723
|
port: resolvedMcp.port,
|
|
3724
|
+
restEndpoint: resolvedMcp.restEndpoint,
|
|
3754
3725
|
transport: "streamable-http",
|
|
3755
3726
|
unref: false,
|
|
3756
3727
|
workspaceRoot: cwd
|
|
@@ -3945,6 +3916,27 @@ const REG_DIST_POSIX_SEP = /\\/g;
|
|
|
3945
3916
|
function emitDashboardEvents(handle, events) {
|
|
3946
3917
|
handle?.emitRuntimeEvents(events);
|
|
3947
3918
|
}
|
|
3919
|
+
function formatHmrProfileFile(profile) {
|
|
3920
|
+
return profile.sourceRootFile ?? profile.relativeFile ?? profile.file ?? "未知文件";
|
|
3921
|
+
}
|
|
3922
|
+
function createHmrProfileEvent(profile) {
|
|
3923
|
+
if (!profile || typeof profile.totalMs !== "number") return;
|
|
3924
|
+
const file = formatHmrProfileFile(profile);
|
|
3925
|
+
const counts = [
|
|
3926
|
+
typeof profile.dirtyCount === "number" ? `dirty ${profile.dirtyCount}` : void 0,
|
|
3927
|
+
typeof profile.pendingCount === "number" ? `pending ${profile.pendingCount}` : void 0,
|
|
3928
|
+
typeof profile.emittedCount === "number" ? `emitted ${profile.emittedCount}` : void 0
|
|
3929
|
+
].filter(Boolean).join(" / ");
|
|
3930
|
+
return {
|
|
3931
|
+
kind: "hmr",
|
|
3932
|
+
level: profile.totalMs >= 1e3 ? "warning" : "success",
|
|
3933
|
+
title: "mini hmr rebuild completed",
|
|
3934
|
+
detail: counts ? `${file} 已完成热更新重建(${counts})。` : `${file} 已完成热更新重建。`,
|
|
3935
|
+
durationMs: profile.totalMs,
|
|
3936
|
+
tags: ["hmr", "rebuild"],
|
|
3937
|
+
profile
|
|
3938
|
+
};
|
|
3939
|
+
}
|
|
3948
3940
|
function hasAnalyzeData(result) {
|
|
3949
3941
|
return result.packages.length > 0 || result.modules.length > 0;
|
|
3950
3942
|
}
|
|
@@ -4045,7 +4037,7 @@ function createAnalyzeController(options) {
|
|
|
4045
4037
|
mode: configService.mode,
|
|
4046
4038
|
isDev: false,
|
|
4047
4039
|
configFile,
|
|
4048
|
-
inlineConfig: createInlineConfig(targets.
|
|
4040
|
+
inlineConfig: createInlineConfig(targets.platform),
|
|
4049
4041
|
cliPlatform: targets.rawPlatform,
|
|
4050
4042
|
projectConfigPath: cliOptions.projectConfig,
|
|
4051
4043
|
syncSupportFiles: false
|
|
@@ -4114,6 +4106,8 @@ function createAnalyzeController(options) {
|
|
|
4114
4106
|
let updating = false;
|
|
4115
4107
|
if (analyzeHandle && buildResult && typeof buildResult.on === "function") buildResult.on("event", (event) => {
|
|
4116
4108
|
if (event.code !== "END" || updating) return;
|
|
4109
|
+
const hmrEvent = createHmrProfileEvent(ctx.runtimeState.build.hmr.recentProfiles.at(-1));
|
|
4110
|
+
if (hmrEvent) emitDashboardEvents(analyzeHandle, [hmrEvent]);
|
|
4117
4111
|
updating = true;
|
|
4118
4112
|
triggerAnalyzeUpdate("watch").finally(() => {
|
|
4119
4113
|
updating = false;
|
|
@@ -4221,11 +4215,11 @@ function waitForServeShutdownSignal() {
|
|
|
4221
4215
|
//#endregion
|
|
4222
4216
|
//#region src/cli/commands/serve/index.ts
|
|
4223
4217
|
function registerServeCommand(cli) {
|
|
4224
|
-
cli.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 |
|
|
4218
|
+
cli.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 | web | all)`).option("--project-config <path>", `[string] project config path (miniprogram only)`).option("--trust-project", "[boolean] auto trust Wechat DevTools project on open", { default: true }).option("--host [host]", `[string] web dev server host`).option("--ui", `[boolean] 启动调试 UI(当前提供分析视图)`, { default: false }).option("--analyze", `[boolean] 启动分包分析仪表盘 (实验特性)`, { default: false }).action(async (root, options) => {
|
|
4225
4219
|
filterDuplicateOptions(options);
|
|
4226
4220
|
const configFile = resolveConfigFile(options);
|
|
4227
4221
|
const targets = resolveRuntimeTargets(options);
|
|
4228
|
-
let inlineConfig = createInlineConfig(targets.
|
|
4222
|
+
let inlineConfig = createInlineConfig(targets.platform);
|
|
4229
4223
|
if (targets.runWeb) {
|
|
4230
4224
|
const host = resolveWebHost(options.host);
|
|
4231
4225
|
if (host !== void 0) inlineConfig = {
|
|
@@ -4492,6 +4486,7 @@ async function maybeAutoStartMcpServer(argv, cliOptions) {
|
|
|
4492
4486
|
endpoint: resolvedMcp.endpoint,
|
|
4493
4487
|
host: resolvedMcp.host,
|
|
4494
4488
|
port: resolvedMcp.port,
|
|
4489
|
+
restEndpoint: resolvedMcp.restEndpoint,
|
|
4495
4490
|
quiet: true,
|
|
4496
4491
|
transport: "streamable-http",
|
|
4497
4492
|
unref: true,
|
|
@@ -4501,6 +4496,7 @@ async function maybeAutoStartMcpServer(argv, cliOptions) {
|
|
|
4501
4496
|
const mcpUrl = `http://${resolvedMcp.host}:${resolvedMcp.port}${resolvedMcp.endpoint}`;
|
|
4502
4497
|
logger_default.success("MCP 服务已自动启动:");
|
|
4503
4498
|
logger_default.info(` ➜ ${colors.cyan(mcpUrl)}`);
|
|
4499
|
+
if (resolvedMcp.restEndpoint !== false) logger_default.info(` REST ➜ ${colors.cyan(`http://${resolvedMcp.host}:${resolvedMcp.port}${resolvedMcp.restEndpoint}`)}`);
|
|
4504
4500
|
for (const line of formatMcpQuickStart({
|
|
4505
4501
|
httpUrl: mcpUrl,
|
|
4506
4502
|
transport: "http"
|
|
@@ -19,15 +19,45 @@ import { WeappWebPluginOptions } from "@weapp-vite/web/plugin";
|
|
|
19
19
|
import { CompilerOptions } from "typescript";
|
|
20
20
|
import { DetectResult } from "package-manager-detector";
|
|
21
21
|
|
|
22
|
+
//#region src/runtimeTarget.d.ts
|
|
23
|
+
type WebPlatform = 'web';
|
|
24
|
+
type WeappViteRuntime = 'miniprogram' | 'web';
|
|
25
|
+
type WeappVitePlatform = MpPlatform$1 | WebPlatform;
|
|
26
|
+
type WeappViteTargetInput = WeappVitePlatform | 'h5' | 'all' | 'both' | (string & {});
|
|
27
|
+
type WeappViteTargetKind = WeappViteRuntime | 'all';
|
|
28
|
+
interface ResolvedWeappViteTarget {
|
|
29
|
+
kind: WeappViteTargetKind;
|
|
30
|
+
runMini: boolean;
|
|
31
|
+
runWeb: boolean;
|
|
32
|
+
platform?: WeappVitePlatform;
|
|
33
|
+
label: string;
|
|
34
|
+
raw?: string;
|
|
35
|
+
}
|
|
36
|
+
interface ResolveWeappViteTargetOptions {
|
|
37
|
+
fallbackMiniPlatform?: MpPlatform$1;
|
|
38
|
+
warn?: (message: string) => void;
|
|
39
|
+
}
|
|
40
|
+
interface WeappViteTargetDescriptor {
|
|
41
|
+
platform: WeappVitePlatform;
|
|
42
|
+
runtime: WeappViteRuntime;
|
|
43
|
+
aliases: readonly string[];
|
|
44
|
+
label: string;
|
|
45
|
+
}
|
|
46
|
+
declare const WEB_PLATFORM_ALIASES: readonly string[];
|
|
47
|
+
declare function isWebPlatform(input?: string | null): boolean;
|
|
48
|
+
declare function getSupportedWeappViteTargetDescriptors(): readonly WeappViteTargetDescriptor[];
|
|
49
|
+
declare function getSupportedWeappVitePlatforms(): readonly WeappVitePlatform[];
|
|
50
|
+
declare function resolveWeappViteTarget(input?: WeappViteTargetInput | null, options?: ResolveWeappViteTargetOptions): ResolvedWeappViteTarget;
|
|
51
|
+
//#endregion
|
|
22
52
|
//#region src/pluginHost.d.ts
|
|
23
53
|
declare const WEAPP_VITE_HOST_NAME = "weapp-vite";
|
|
24
|
-
type WeappViteRuntime = 'miniprogram' | 'web';
|
|
25
54
|
interface WeappViteHostMeta {
|
|
26
55
|
name: typeof WEAPP_VITE_HOST_NAME;
|
|
27
56
|
runtime: WeappViteRuntime;
|
|
57
|
+
platform?: WeappVitePlatform;
|
|
28
58
|
}
|
|
29
|
-
declare function createWeappViteHostMeta(runtime: WeappViteRuntime): WeappViteHostMeta;
|
|
30
|
-
declare function applyWeappViteHostMeta(config: InlineConfig, runtime: WeappViteRuntime): InlineConfig;
|
|
59
|
+
declare function createWeappViteHostMeta(runtime: WeappViteRuntime, platform?: WeappVitePlatform): WeappViteHostMeta;
|
|
60
|
+
declare function applyWeappViteHostMeta(config: InlineConfig, runtime: WeappViteRuntime, platform?: WeappVitePlatform): InlineConfig;
|
|
31
61
|
declare function resolveWeappViteHostMeta(config: Pick<InlineConfig, 'weappVite'> | undefined): WeappViteHostMeta | undefined;
|
|
32
62
|
declare function isWeappViteHost(config: Pick<InlineConfig, 'weappVite'> | undefined): boolean;
|
|
33
63
|
declare module 'vite' {
|
|
@@ -204,9 +234,6 @@ interface WeappWebConfig {
|
|
|
204
234
|
}
|
|
205
235
|
interface WeappManagedSharedTsconfigConfig {
|
|
206
236
|
compilerOptions?: CompilerOptions;
|
|
207
|
-
include?: string[];
|
|
208
|
-
exclude?: string[];
|
|
209
|
-
files?: string[];
|
|
210
237
|
}
|
|
211
238
|
interface WeappManagedAppTsconfigConfig {
|
|
212
239
|
compilerOptions?: CompilerOptions;
|
|
@@ -397,6 +424,10 @@ interface WeappMcpConfig {
|
|
|
397
424
|
host?: string;
|
|
398
425
|
port?: number;
|
|
399
426
|
endpoint?: string;
|
|
427
|
+
/**
|
|
428
|
+
* @description streamable-http 模式下的 DevTools runtime REST 入口;设为 false 可关闭。
|
|
429
|
+
*/
|
|
430
|
+
restEndpoint?: string | false;
|
|
400
431
|
}
|
|
401
432
|
/**
|
|
402
433
|
* @description 自动路由配置
|
|
@@ -1451,7 +1482,13 @@ interface RuntimeState {
|
|
|
1451
1482
|
didEmitAllEntries: boolean;
|
|
1452
1483
|
lastEmittedEntryIds: Set<string>;
|
|
1453
1484
|
recentProfiles: Array<{
|
|
1485
|
+
timestamp?: string;
|
|
1454
1486
|
totalMs: number;
|
|
1487
|
+
eventId?: string;
|
|
1488
|
+
event?: string;
|
|
1489
|
+
file?: string;
|
|
1490
|
+
relativeFile?: string;
|
|
1491
|
+
sourceRootFile?: string;
|
|
1455
1492
|
buildCoreMs?: number;
|
|
1456
1493
|
transformMs?: number;
|
|
1457
1494
|
writeMs?: number;
|
|
@@ -1461,6 +1498,8 @@ interface RuntimeState {
|
|
|
1461
1498
|
dirtyCount?: number;
|
|
1462
1499
|
pendingCount?: number;
|
|
1463
1500
|
emittedCount?: number;
|
|
1501
|
+
dirtyReasonSummary?: string[];
|
|
1502
|
+
pendingReasonSummary?: string[];
|
|
1464
1503
|
}>;
|
|
1465
1504
|
profile: {
|
|
1466
1505
|
eventId?: string;
|
|
@@ -1711,4 +1750,4 @@ declare module 'vite' {
|
|
|
1711
1750
|
*/
|
|
1712
1751
|
declare function defineConfig<T extends UserConfigExport>(config: T): T;
|
|
1713
1752
|
//#endregion
|
|
1714
|
-
export { WeappAnalyzeBudgetConfig as $, GenerateTemplateScope as $t, Ref as A, WeappLibVueTscOptions as An, WeappVueConfig as At, BindingErrorLike as B,
|
|
1753
|
+
export { WeappAnalyzeBudgetConfig as $, getSupportedWeappViteTargetDescriptors as $n, GenerateTemplateScope as $t, Ref as A, WeappLibVueTscOptions as An, WeappVueConfig as At, BindingErrorLike as B, createWeappViteHostMeta as Bn, CopyGlobs as Bt, LoadConfigOptions as C, SubPackageStyleScope as Cn, WeappInjectWebRuntimeGlobalsTarget as Ct, MethodDefinitions$1 as D, WeappLibEntryContext as Dn, WeappRouteRule as Dt, InlineConfig$1 as E, WeappLibDtsOptions as En, WeappRequestRuntimeConfig as Et, RolldownPlugin as F, WeappManagedTypeScriptConfig as Fn, Alias as Ft, EntryJsonFragment as G, WEB_PLATFORM_ALIASES as Gn, GenerateFilenamesOptions as Gt, BaseEntry as H, resolveWeappViteHostMeta as Hn, GenerateDirsOptions as Ht, RolldownPluginOption as I, WeappWebConfig as In, AliasOptions as It, ScanComponentItem as J, WeappViteTargetDescriptor as Jn, GenerateTemplateContext as Jt, PageEntry as K, WeappVitePlatform as Kn, GenerateOptions as Kt, RolldownWatchOptions as L, WEAPP_VITE_HOST_NAME as Ln, AlipayNpmMode as Lt, RolldownBuild as M, WeappManagedNodeTsconfigConfig as Mn, WeappWebRuntimeConfig as Mt, RolldownOptions as N, WeappManagedServerTsconfigConfig as Nn, WeappWevuConfig as Nt, Plugin$1 as O, WeappLibFileName as On, WeappRouteRules as Ot, RolldownOutput$1 as P, WeappManagedSharedTsconfigConfig as Pn, WeappWorkerConfig as Pt, UserConfig$2 as Q, getSupportedWeappVitePlatforms as Qn, GenerateTemplateInlineSource as Qt, RolldownWatcher$1 as R, WeappViteHostMeta as Rn, BuildNpmPackageMeta as Rt, CompilerContext as S, SubPackageStyleEntry as Sn, WeappInjectWebRuntimeGlobalsConfig as St, ConfigEnv$1 as T, WeappLibConfig as Tn, WeappNpmConfig as Tt, ComponentEntry as U, ResolveWeappViteTargetOptions as Un, GenerateExtensionsOptions as Ut, AppEntry as V, isWeappViteHost as Vn, CopyOptions as Vt, Entry as W, ResolvedWeappViteTarget as Wn, GenerateFileType as Wt, ProjectConfig as X, WeappViteTargetKind as Xn, GenerateTemplateFactory as Xt, WxmlDep as Y, WeappViteTargetInput as Yn, GenerateTemplateEntry as Yt, SubPackageMetaValue as Z, WebPlatform as Zn, GenerateTemplateFileSource as Zt, definePageJson as _, SharedChunkOverride as _n, WeappAutoRoutesIncludePattern as _t, UserConfigFnNoEnvPlain as a, JsonMergeStage as an, WeappViteConfig as at, ChangeEvent as b, SubPackageStyleConfigEntry as bn, WeappInjectRequestGlobalsTarget as bt, UserConfigFnPromise as c, NpmBuildOptions as cn, EnhanceOptions as ct, Component$1 as d, NpmPluginPackageConfig as dn, MultiPlatformConfig as dt, GenerateTemplatesConfig as en, isWebPlatform as er, WeappAnalyzeConfig as et, Page$1 as f, NpmStrategy as fn, ScanWxmlOptions as ft, defineComponentJson as g, SharedChunkMode as gn, WeappAutoRoutesInclude as gt, defineAppJson as h, SharedChunkDynamicImports as hn, WeappAutoRoutesConfig as ht, UserConfigFnNoEnv as i, JsonMergeFunction as in, WeappForwardConsoleLogLevel as it, ResolvedConfig as j, WeappManagedAppTsconfigConfig as jn, WeappVueTemplateConfig as jt, PluginOption as k, WeappLibInternalDtsOptions as kn, WeappSubPackageConfig as kt, defineConfig as l, NpmDependencyPattern as ln, EnhanceWxmlOptions as lt, Theme$1 as m, ResolvedAlias as mn, WeappAppPreludeMode as mt, UserConfigExport as n, JsonConfig as nn, WeappDebugConfig as nt, UserConfigFnObject as o, JsonMergeStrategy as on, AutoImportComponents as ot, Sitemap$1 as p, NpmSubPackageConfig as pn, WeappAppPreludeConfig as pt, ComponentsMap as q, WeappViteRuntime as qn, GenerateTemplate as qt, UserConfigFn as r, JsonMergeContext as rn, WeappForwardConsoleConfig as rt, UserConfigFnObjectPlain as s, MpPlatform$1 as sn, AutoImportComponentsOption as st, UserConfig$1 as t, JsFormat as tn, resolveWeappViteTarget as tr, WeappAnalyzeHistoryConfig as tt, App$1 as u, NpmMainPackageConfig as un, HandleWxmlOptions as ut, defineSitemapJson as v, SharedChunkStrategy as vn, WeappHmrConfig as vt, ComputedDefinitions$1 as w, WeappLibComponentJson as wn, WeappMcpConfig as wt, WeappVitePluginApi as x, SubPackageStyleConfigObject as xn, WeappInjectWeapiConfig as xt, defineThemeJson as y, SubPackage as yn, WeappInjectRequestGlobalsConfig as yt, ViteDevServer$1 as z, applyWeappViteHostMeta as zn, ChunksConfig as zt };
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Bn as
|
|
1
|
+
import { Bn as createWeappViteHostMeta, Hn as resolveWeappViteHostMeta, Ln as WEAPP_VITE_HOST_NAME, Rn as WeappViteHostMeta, Vn as isWeappViteHost, _ as definePageJson, a as UserConfigFnNoEnvPlain, at as WeappViteConfig, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, l as defineConfig, m as Theme, n as UserConfigExport, o as UserConfigFnObject, p as Sitemap, qn as WeappViteRuntime, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson, zn as applyWeappViteHostMeta } from "./config-CXABkCb8.mjs";
|
|
2
2
|
export { App, Component, Page, Sitemap, Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, WEAPP_VITE_HOST_NAME, WeappViteConfig, WeappViteHostMeta, WeappViteRuntime, applyWeappViteHostMeta, createWeappViteHostMeta, defineAppJson, defineComponentJson, defineConfig, definePageJson, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };
|
package/dist/config.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-D0HkutE0.mjs";
|
|
2
|
-
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-
|
|
2
|
+
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-BEnGeaSo.mjs";
|
|
3
3
|
import { t as defineConfig } from "./config-DJjSbpNX.mjs";
|
|
4
4
|
export { WEAPP_VITE_HOST_NAME, applyWeappViteHostMeta, createWeappViteHostMeta, defineAppJson, defineComponentJson, defineConfig, definePageJson, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as applyWeappViteHostMeta } from "./pluginHost-
|
|
1
|
+
import { n as applyWeappViteHostMeta } from "./pluginHost-BEnGeaSo.mjs";
|
|
2
2
|
import { n as configureLogger, r as logger_default } from "./logger-CgxdNjvb.mjs";
|
|
3
|
-
import { _ as jsExtensions, a as findJsonEntry, b as vueExtensions, c as isJsOrTs, d as touch, g as configExtensions, i as findJsEntry, l as isTemplate, n as changeFileExtension, o as findTemplateEntry, p as inlineAutoRoutesImports, r as findCssEntry, s as findVueEntry, t as extractConfigFromVue, v as supportedCssLangs, y as templateExtensions } from "./file-
|
|
3
|
+
import { _ as jsExtensions, a as findJsonEntry, b as vueExtensions, c as isJsOrTs, d as touch, g as configExtensions, i as findJsEntry, l as isTemplate, n as changeFileExtension, o as findTemplateEntry, p as inlineAutoRoutesImports, r as findCssEntry, s as findVueEntry, t as extractConfigFromVue, v as supportedCssLangs, y as templateExtensions } from "./file-D57m5ljp.mjs";
|
|
4
4
|
import { createRequire, isBuiltin } from "node:module";
|
|
5
5
|
import path, { posix } from "pathe";
|
|
6
6
|
import path$1, { normalize, relative, win32 } from "node:path";
|
|
@@ -10384,20 +10384,34 @@ function shouldHandleSnapshotSidecarFile(filePath) {
|
|
|
10384
10384
|
}
|
|
10385
10385
|
function createBuildService(ctx) {
|
|
10386
10386
|
let lastHmrSlowTipProfileCount = 0;
|
|
10387
|
+
function createHmrProfileJsonSample(totalMs) {
|
|
10388
|
+
const profile = ctx.runtimeState.build.hmr.profile;
|
|
10389
|
+
const relativeFile = profile.file && ctx.configService ? ctx.configService.relativeCwd(profile.file) : void 0;
|
|
10390
|
+
const sourceRootFile = profile.file && ctx.configService ? ctx.configService.relativeAbsoluteSrcRoot(profile.file) : void 0;
|
|
10391
|
+
return {
|
|
10392
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10393
|
+
totalMs,
|
|
10394
|
+
eventId: profile.eventId,
|
|
10395
|
+
event: profile.event,
|
|
10396
|
+
file: profile.file,
|
|
10397
|
+
relativeFile,
|
|
10398
|
+
sourceRootFile,
|
|
10399
|
+
buildCoreMs: profile.buildCoreMs,
|
|
10400
|
+
transformMs: profile.transformMs,
|
|
10401
|
+
writeMs: profile.writeMs,
|
|
10402
|
+
watchToDirtyMs: profile.watchToDirtyMs,
|
|
10403
|
+
emitMs: profile.emitMs,
|
|
10404
|
+
sharedChunkResolveMs: profile.sharedChunkResolveMs,
|
|
10405
|
+
dirtyCount: profile.dirtyCount,
|
|
10406
|
+
pendingCount: profile.pendingCount,
|
|
10407
|
+
emittedCount: profile.emittedCount,
|
|
10408
|
+
dirtyReasonSummary: profile.dirtyReasonSummary,
|
|
10409
|
+
pendingReasonSummary: profile.pendingReasonSummary
|
|
10410
|
+
};
|
|
10411
|
+
}
|
|
10387
10412
|
function recordHmrProfile(totalMs) {
|
|
10388
10413
|
const hmrState = ctx.runtimeState.build.hmr;
|
|
10389
|
-
hmrState.recentProfiles.push(
|
|
10390
|
-
totalMs,
|
|
10391
|
-
buildCoreMs: hmrState.profile.buildCoreMs,
|
|
10392
|
-
transformMs: hmrState.profile.transformMs,
|
|
10393
|
-
writeMs: hmrState.profile.writeMs,
|
|
10394
|
-
watchToDirtyMs: hmrState.profile.watchToDirtyMs,
|
|
10395
|
-
emitMs: hmrState.profile.emitMs,
|
|
10396
|
-
sharedChunkResolveMs: hmrState.profile.sharedChunkResolveMs,
|
|
10397
|
-
dirtyCount: hmrState.profile.dirtyCount,
|
|
10398
|
-
pendingCount: hmrState.profile.pendingCount,
|
|
10399
|
-
emittedCount: hmrState.profile.emittedCount
|
|
10400
|
-
});
|
|
10414
|
+
hmrState.recentProfiles.push(createHmrProfileJsonSample(totalMs));
|
|
10401
10415
|
if (hmrState.recentProfiles.length > 5) hmrState.recentProfiles.splice(0, hmrState.recentProfiles.length - 5);
|
|
10402
10416
|
}
|
|
10403
10417
|
function resetHmrProfile() {
|
|
@@ -10556,31 +10570,6 @@ function createBuildService(ctx) {
|
|
|
10556
10570
|
logger_default.info(`检测到 HMR 重建明显变慢:当前 ${currentProfile.totalMs.toFixed(2)} ms,近${previousProfiles.length}次均值 ${previousAverage.toFixed(2)} ms${formatHmrPhaseRegressionHint(currentProfile, previousProfiles)};建议运行 weapp-vite analyze --hmr-profile 查看阶段统计。`);
|
|
10557
10571
|
return true;
|
|
10558
10572
|
}
|
|
10559
|
-
function createHmrProfileJsonSample(totalMs) {
|
|
10560
|
-
const profile = ctx.runtimeState.build.hmr.profile;
|
|
10561
|
-
const relativeFile = profile.file && ctx.configService ? ctx.configService.relativeCwd(profile.file) : void 0;
|
|
10562
|
-
const sourceRootFile = profile.file && ctx.configService ? ctx.configService.relativeAbsoluteSrcRoot(profile.file) : void 0;
|
|
10563
|
-
return {
|
|
10564
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10565
|
-
totalMs,
|
|
10566
|
-
eventId: profile.eventId,
|
|
10567
|
-
event: profile.event,
|
|
10568
|
-
file: profile.file,
|
|
10569
|
-
relativeFile,
|
|
10570
|
-
sourceRootFile,
|
|
10571
|
-
buildCoreMs: profile.buildCoreMs,
|
|
10572
|
-
transformMs: profile.transformMs,
|
|
10573
|
-
writeMs: profile.writeMs,
|
|
10574
|
-
watchToDirtyMs: profile.watchToDirtyMs,
|
|
10575
|
-
emitMs: profile.emitMs,
|
|
10576
|
-
sharedChunkResolveMs: profile.sharedChunkResolveMs,
|
|
10577
|
-
dirtyCount: profile.dirtyCount,
|
|
10578
|
-
pendingCount: profile.pendingCount,
|
|
10579
|
-
emittedCount: profile.emittedCount,
|
|
10580
|
-
dirtyReasonSummary: profile.dirtyReasonSummary,
|
|
10581
|
-
pendingReasonSummary: profile.pendingReasonSummary
|
|
10582
|
-
};
|
|
10583
|
-
}
|
|
10584
10573
|
async function writeHmrProfileJsonSample(totalMs) {
|
|
10585
10574
|
const outputPath = resolveHmrProfileJsonPath$1();
|
|
10586
10575
|
if (!outputPath) return;
|
|
@@ -10955,10 +10944,11 @@ function resolveMultiPlatformConfig(value) {
|
|
|
10955
10944
|
};
|
|
10956
10945
|
if (typeof value === "object" && value !== null) {
|
|
10957
10946
|
const record = value;
|
|
10947
|
+
const targets = resolveMultiPlatformTargets(record.targets);
|
|
10958
10948
|
return {
|
|
10959
10949
|
enabled: record.enabled !== false,
|
|
10960
10950
|
projectConfigRoot: normalizeMultiPlatformProjectConfigRoot(record.projectConfigRoot),
|
|
10961
|
-
targets
|
|
10951
|
+
targets
|
|
10962
10952
|
};
|
|
10963
10953
|
}
|
|
10964
10954
|
return {
|
|
@@ -11178,7 +11168,8 @@ function getWeappViteConfig() {
|
|
|
11178
11168
|
autoStart: false,
|
|
11179
11169
|
host: "127.0.0.1",
|
|
11180
11170
|
port: 3088,
|
|
11181
|
-
endpoint: "/mcp"
|
|
11171
|
+
endpoint: "/mcp",
|
|
11172
|
+
restEndpoint: "/api/weapp/devtools"
|
|
11182
11173
|
},
|
|
11183
11174
|
forwardConsole: {
|
|
11184
11175
|
enabled: "auto",
|
|
@@ -11285,6 +11276,75 @@ function resolveWeappWebConfig(options) {
|
|
|
11285
11276
|
};
|
|
11286
11277
|
}
|
|
11287
11278
|
//#endregion
|
|
11279
|
+
//#region src/runtimeTarget.ts
|
|
11280
|
+
const WEB_PLATFORM_ALIASES = Object.freeze(["web", "h5"]);
|
|
11281
|
+
function isWebPlatform(input) {
|
|
11282
|
+
if (!input) return false;
|
|
11283
|
+
return WEB_PLATFORM_ALIASES.includes(input.trim().toLowerCase());
|
|
11284
|
+
}
|
|
11285
|
+
function getSupportedWeappViteTargetDescriptors() {
|
|
11286
|
+
return [...getSupportedMiniProgramPlatforms$1().map((platform) => ({
|
|
11287
|
+
platform,
|
|
11288
|
+
runtime: "miniprogram",
|
|
11289
|
+
aliases: [platform],
|
|
11290
|
+
label: platform
|
|
11291
|
+
})), {
|
|
11292
|
+
platform: "web",
|
|
11293
|
+
runtime: "web",
|
|
11294
|
+
aliases: WEB_PLATFORM_ALIASES,
|
|
11295
|
+
label: "web"
|
|
11296
|
+
}];
|
|
11297
|
+
}
|
|
11298
|
+
function getSupportedWeappVitePlatforms() {
|
|
11299
|
+
return getSupportedWeappViteTargetDescriptors().map((descriptor) => descriptor.platform);
|
|
11300
|
+
}
|
|
11301
|
+
function resolveWeappViteTarget(input, options = {}) {
|
|
11302
|
+
const raw = typeof input === "string" ? input : void 0;
|
|
11303
|
+
if (!raw) return {
|
|
11304
|
+
kind: "miniprogram",
|
|
11305
|
+
runMini: true,
|
|
11306
|
+
runWeb: false,
|
|
11307
|
+
label: "config",
|
|
11308
|
+
raw
|
|
11309
|
+
};
|
|
11310
|
+
const normalized = normalizeMiniPlatform(raw);
|
|
11311
|
+
const lowerRaw = raw.trim().toLowerCase();
|
|
11312
|
+
if (lowerRaw === "all" || lowerRaw === "both") return {
|
|
11313
|
+
kind: "all",
|
|
11314
|
+
runMini: true,
|
|
11315
|
+
runWeb: true,
|
|
11316
|
+
label: "weapp + web",
|
|
11317
|
+
raw
|
|
11318
|
+
};
|
|
11319
|
+
if (isWebPlatform(normalized ?? lowerRaw)) return {
|
|
11320
|
+
kind: "web",
|
|
11321
|
+
runMini: false,
|
|
11322
|
+
runWeb: true,
|
|
11323
|
+
platform: "web",
|
|
11324
|
+
label: "web",
|
|
11325
|
+
raw
|
|
11326
|
+
};
|
|
11327
|
+
const platform = resolveMiniPlatform(normalized ?? raw);
|
|
11328
|
+
if (platform) return {
|
|
11329
|
+
kind: "miniprogram",
|
|
11330
|
+
runMini: true,
|
|
11331
|
+
runWeb: false,
|
|
11332
|
+
platform,
|
|
11333
|
+
label: platform,
|
|
11334
|
+
raw
|
|
11335
|
+
};
|
|
11336
|
+
const fallbackMiniPlatform = options.fallbackMiniPlatform ?? DEFAULT_MP_PLATFORM;
|
|
11337
|
+
options.warn?.(`未识别的平台 "${raw}",已回退到 ${fallbackMiniPlatform}`);
|
|
11338
|
+
return {
|
|
11339
|
+
kind: "miniprogram",
|
|
11340
|
+
runMini: true,
|
|
11341
|
+
runWeb: false,
|
|
11342
|
+
platform: fallbackMiniPlatform,
|
|
11343
|
+
label: fallbackMiniPlatform,
|
|
11344
|
+
raw
|
|
11345
|
+
};
|
|
11346
|
+
}
|
|
11347
|
+
//#endregion
|
|
11288
11348
|
//#region src/runtime/config/legacyEs5.ts
|
|
11289
11349
|
function importSwcCore() {
|
|
11290
11350
|
return import("@swc/core");
|
|
@@ -11473,10 +11533,10 @@ async function loadPackageJson(cwd) {
|
|
|
11473
11533
|
//#endregion
|
|
11474
11534
|
//#region src/runtime/config/internal/loadConfig/build.ts
|
|
11475
11535
|
function resolveCliPlatformRuntime(cliPlatform) {
|
|
11476
|
-
const
|
|
11536
|
+
const target = resolveWeappViteTarget(cliPlatform);
|
|
11477
11537
|
return {
|
|
11478
|
-
normalizedCliPlatform,
|
|
11479
|
-
isWebRuntime:
|
|
11538
|
+
normalizedCliPlatform: target.platform ?? (target.runWeb ? target.label : void 0),
|
|
11539
|
+
isWebRuntime: target.runWeb && !target.runMini
|
|
11480
11540
|
};
|
|
11481
11541
|
}
|
|
11482
11542
|
function resolveMultiPlatformProjectConfigHint(platform, projectConfigRoot = "config") {
|
|
@@ -11766,7 +11826,7 @@ async function loadConfigFileWithFallback(configEnv, configFile, cwd, configLoad
|
|
|
11766
11826
|
if (configLoader !== "native") throw error;
|
|
11767
11827
|
const message = error instanceof Error ? error.message : String(error);
|
|
11768
11828
|
logger_default.warn(`[prepare] 原生配置加载失败,已回退到 runner:${message}`);
|
|
11769
|
-
return
|
|
11829
|
+
return loadConfigFileWithFallback(configEnv, configFile, cwd, "runner");
|
|
11770
11830
|
}
|
|
11771
11831
|
}
|
|
11772
11832
|
function createLoadConfig(options) {
|
|
@@ -11929,10 +11989,12 @@ function createLoadConfig(options) {
|
|
|
11929
11989
|
const aliasEntries = getAliasEntries(config.weapp?.jsonAlias);
|
|
11930
11990
|
config.plugins ??= [];
|
|
11931
11991
|
const tsconfigPathsOptions = config.weapp?.tsconfigPaths;
|
|
11932
|
-
if (tsconfigPathsOptions !== false)
|
|
11933
|
-
|
|
11934
|
-
|
|
11935
|
-
|
|
11992
|
+
if (tsconfigPathsOptions !== false) {
|
|
11993
|
+
if (typeof tsconfigPathsOptions === "object" && tsconfigPathsOptions !== null) config.plugins.push(tsconfigPaths(tsconfigPathsOptions));
|
|
11994
|
+
else if (tsconfigPathsOptions === true || tsconfigPathsUsage.enabled) {
|
|
11995
|
+
config.resolve ??= {};
|
|
11996
|
+
config.resolve.tsconfigPaths ??= true;
|
|
11997
|
+
}
|
|
11936
11998
|
}
|
|
11937
11999
|
const configFilePath = weappLoaded?.path ?? loaded?.path ?? resolvedConfigFile;
|
|
11938
12000
|
const configMergeInfo = loaded?.path && weappLoaded?.path && !shouldReuseLoadedWeappConfig(weappLoaded.path, loaded.path) ? {
|
|
@@ -14832,6 +14894,8 @@ function resolvePendingEntryIds(options) {
|
|
|
14832
14894
|
};
|
|
14833
14895
|
const startedAt = performance.now();
|
|
14834
14896
|
const relatedChunkIds = /* @__PURE__ */ new Set();
|
|
14897
|
+
const shouldExpandLayoutSharedChunks = pendingReasonSummary.includes("layout-propagation") || pendingReasonSummary.includes("layout-fallback-full");
|
|
14898
|
+
if (shouldExpandLayoutSharedChunks) for (const chunkId of options.sharedChunkImporters.keys()) relatedChunkIds.add(chunkId);
|
|
14835
14899
|
for (const entryId of options.dirtyEntrySet) {
|
|
14836
14900
|
if (options.dirtyEntryReasons.get(entryId) === "metadata") continue;
|
|
14837
14901
|
const chunkIds = options.sharedChunksByEntry.get(entryId);
|
|
@@ -14848,7 +14912,7 @@ function resolvePendingEntryIds(options) {
|
|
|
14848
14912
|
for (const chunkId of relatedChunkIds) {
|
|
14849
14913
|
const importers = options.sharedChunkImporters.get(chunkId);
|
|
14850
14914
|
if (!importers) continue;
|
|
14851
|
-
if (importers.size <= 1) continue;
|
|
14915
|
+
if (importers.size <= 1 && !shouldExpandLayoutSharedChunks) continue;
|
|
14852
14916
|
let hasDependencyDrivenImporter = false;
|
|
14853
14917
|
let hasDirectDirtyImporter = false;
|
|
14854
14918
|
for (const importer of importers) {
|
|
@@ -14858,8 +14922,9 @@ function resolvePendingEntryIds(options) {
|
|
|
14858
14922
|
}
|
|
14859
14923
|
if (options.dirtyEntrySet.has(importer) && options.dirtyEntryReasons.get(importer) === "direct") hasDirectDirtyImporter = true;
|
|
14860
14924
|
}
|
|
14861
|
-
if (!hasDependencyDrivenImporter && !hasDirectDirtyImporter) continue;
|
|
14862
|
-
if (hasDependencyDrivenImporter && hasDirectDirtyImporter) expansionMode = "mixed";
|
|
14925
|
+
if (!hasDependencyDrivenImporter && !hasDirectDirtyImporter && !shouldExpandLayoutSharedChunks) continue;
|
|
14926
|
+
if (shouldExpandLayoutSharedChunks && !hasDependencyDrivenImporter && !hasDirectDirtyImporter) expansionMode = expansionMode && expansionMode !== "dependency" ? "mixed" : "dependency";
|
|
14927
|
+
else if (hasDependencyDrivenImporter && hasDirectDirtyImporter) expansionMode = "mixed";
|
|
14863
14928
|
else if (hasDirectDirtyImporter) expansionMode = expansionMode && expansionMode !== "direct" ? "mixed" : "direct";
|
|
14864
14929
|
else expansionMode = expansionMode && expansionMode !== "dependency" ? "mixed" : "dependency";
|
|
14865
14930
|
for (const importer of importers) {
|
|
@@ -14970,7 +15035,8 @@ function useLoadEntry(ctx, options) {
|
|
|
14970
15035
|
dirtyEntryReasons,
|
|
14971
15036
|
dirtyReasonSummary: ctx.runtimeState.build.hmr.profile.dirtyReasonSummary,
|
|
14972
15037
|
sharedChunkImporters: hmrSharedChunkImporters,
|
|
14973
|
-
sharedChunksByEntry: hmrSharedChunksByEntry
|
|
15038
|
+
sharedChunksByEntry: hmrSharedChunksByEntry,
|
|
15039
|
+
sourceSharedChunks: options?.hmr?.sourceSharedChunks
|
|
14974
15040
|
});
|
|
14975
15041
|
const pendingEntryIds = pendingResolution.pending;
|
|
14976
15042
|
const pending = [];
|
|
@@ -18077,6 +18143,32 @@ async function processChangedFile(state, id, event) {
|
|
|
18077
18143
|
const declaredEntryType = state.entriesMap.get(removeExtensionDeep(relativeSrc))?.type;
|
|
18078
18144
|
const isDeletedMissingSelf = event === "delete" && !await fs.pathExists(normalizedId);
|
|
18079
18145
|
const isAutoRouteFile = Boolean(ctx.autoRoutesService?.isRouteFile(normalizedId));
|
|
18146
|
+
const isTemplateSidecar = Boolean(path.extname(normalizedId) && watchedTemplateExts.has(path.extname(normalizedId)));
|
|
18147
|
+
const isScriptModuleSidecar = Array.from(watchedScriptModuleExts).some((suffix) => normalizedId.endsWith(suffix));
|
|
18148
|
+
const addWxmlImporterEntries = async (startId) => {
|
|
18149
|
+
const wxmlService = ctx.wxmlService;
|
|
18150
|
+
if (!wxmlService || typeof wxmlService.getImporters !== "function") return;
|
|
18151
|
+
const visited = /* @__PURE__ */ new Set();
|
|
18152
|
+
const queue = [startId];
|
|
18153
|
+
while (queue.length) {
|
|
18154
|
+
const current = queue.shift();
|
|
18155
|
+
if (visited.has(current)) continue;
|
|
18156
|
+
visited.add(current);
|
|
18157
|
+
const importers = wxmlService.getImporters(current);
|
|
18158
|
+
for (const importer of importers) {
|
|
18159
|
+
const normalizedImporter = normalizeFsResolvedId(importer);
|
|
18160
|
+
if (!visited.has(normalizedImporter)) queue.push(normalizedImporter);
|
|
18161
|
+
const ext = path.extname(normalizedImporter);
|
|
18162
|
+
if (!ext) continue;
|
|
18163
|
+
const primaryScript = await findJsEntry(normalizedImporter.slice(0, -ext.length));
|
|
18164
|
+
if (!primaryScript.path) continue;
|
|
18165
|
+
const primaryScriptId = normalizeFsResolvedId(primaryScript.path);
|
|
18166
|
+
const reason = isLayoutSourcePath(configService.relativeAbsoluteSrcRoot(primaryScriptId)) ? "dependency" : "direct";
|
|
18167
|
+
if (reason === "dependency") affectedLayoutEntryIds.add(primaryScriptId);
|
|
18168
|
+
else markEntryDirtyWithCause(primaryScriptId, reason, "wxml-importer");
|
|
18169
|
+
}
|
|
18170
|
+
}
|
|
18171
|
+
};
|
|
18080
18172
|
if (isDeletedMissingSelf) ctx.runtimeState.build.hmr.vueEntryNonJsonSignatures.delete(normalizedId);
|
|
18081
18173
|
if ((event === "create" || isDeletedMissingSelf) && isAutoRouteFile) {
|
|
18082
18174
|
if (await ctx.autoRoutesService?.handleFileChange(normalizedId, event)) dirtyReasonStats.set("auto-routes-topology", 1);
|
|
@@ -18090,6 +18182,7 @@ async function processChangedFile(state, id, event) {
|
|
|
18090
18182
|
const wxmlService = ctx.wxmlService;
|
|
18091
18183
|
if (wxmlService) await wxmlService.scan(normalizedId);
|
|
18092
18184
|
}
|
|
18185
|
+
if (isTemplateSidecar || isScriptModuleSidecar) await addWxmlImporterEntries(normalizedId);
|
|
18093
18186
|
const isHtmlTemplateFile = normalizedId.endsWith(".html");
|
|
18094
18187
|
if (isTemplateFile || configSuffix || isStyleFile || isHtmlTemplateFile) {
|
|
18095
18188
|
const primaryScript = await findJsEntry(configSuffix ? normalizedId.slice(0, -configSuffix.length) : (() => {
|
|
@@ -21769,6 +21862,7 @@ function resolveMiniprogramWatchInclude(options) {
|
|
|
21769
21862
|
}
|
|
21770
21863
|
function mergeMiniprogram(options, ...configs) {
|
|
21771
21864
|
const { ctx, subPackageMeta, config, cwd, srcRoot, mpDistRoot, packageJson, isDev, applyRuntimePlatform, injectBuiltinAliases, getDefineImportMetaEnv, setOptions, oxcRolldownPlugin } = options;
|
|
21865
|
+
const platform = ctx.configService?.platform;
|
|
21772
21866
|
applyRuntimePlatform("miniprogram");
|
|
21773
21867
|
const createMiniprogramCustomLogger = () => {
|
|
21774
21868
|
return createLogger("warn");
|
|
@@ -21820,7 +21914,7 @@ function mergeMiniprogram(options, ...configs) {
|
|
|
21820
21914
|
...inline.define ?? {},
|
|
21821
21915
|
__VITE_IS_MODERN__: "false"
|
|
21822
21916
|
};
|
|
21823
|
-
applyWeappViteHostMeta(inline, "miniprogram");
|
|
21917
|
+
applyWeappViteHostMeta(inline, "miniprogram", platform);
|
|
21824
21918
|
stripRollupOptions(inline);
|
|
21825
21919
|
arrangePlugins(inline, ctx, subPackageMeta);
|
|
21826
21920
|
injectBuiltinAliases(inline);
|
|
@@ -21841,7 +21935,7 @@ function mergeMiniprogram(options, ...configs) {
|
|
|
21841
21935
|
...inlineConfig.define ?? {},
|
|
21842
21936
|
__VITE_IS_MODERN__: "false"
|
|
21843
21937
|
};
|
|
21844
|
-
applyWeappViteHostMeta(inlineConfig, "miniprogram");
|
|
21938
|
+
applyWeappViteHostMeta(inlineConfig, "miniprogram", platform);
|
|
21845
21939
|
stripRollupOptions(inlineConfig);
|
|
21846
21940
|
arrangePlugins(inlineConfig, ctx, subPackageMeta);
|
|
21847
21941
|
inlineConfig.logLevel = "warn";
|
|
@@ -21891,7 +21985,7 @@ function mergeWeb(options, ...configs) {
|
|
|
21891
21985
|
inline.build ??= {};
|
|
21892
21986
|
inline.build.outDir = web.outDir;
|
|
21893
21987
|
inline.build.emptyOutDir ??= !isDev;
|
|
21894
|
-
applyWeappViteHostMeta(inline, "web");
|
|
21988
|
+
applyWeappViteHostMeta(inline, "web", "web");
|
|
21895
21989
|
inline.define = defu(inline.define ?? {}, getDefineImportMetaEnv());
|
|
21896
21990
|
injectBuiltinAliases(inline);
|
|
21897
21991
|
return inline;
|
|
@@ -21907,6 +22001,7 @@ function resolveWorkersBuildDefaults(isDev) {
|
|
|
21907
22001
|
}
|
|
21908
22002
|
function mergeWorkers(options, ...configs) {
|
|
21909
22003
|
const { ctx, isDev, config, cwd, injectBuiltinAliases, getDefineImportMetaEnv, applyRuntimePlatform } = options;
|
|
22004
|
+
const platform = ctx.configService?.platform;
|
|
21910
22005
|
applyRuntimePlatform("miniprogram");
|
|
21911
22006
|
if (isDev) {
|
|
21912
22007
|
const inline = defu(config, ...configs, {
|
|
@@ -21916,7 +22011,7 @@ function mergeWorkers(options, ...configs) {
|
|
|
21916
22011
|
define: getDefineImportMetaEnv(),
|
|
21917
22012
|
build: resolveWorkersBuildDefaults(true)
|
|
21918
22013
|
});
|
|
21919
|
-
applyWeappViteHostMeta(inline, "miniprogram");
|
|
22014
|
+
applyWeappViteHostMeta(inline, "miniprogram", platform);
|
|
21920
22015
|
stripRollupOptions(inline);
|
|
21921
22016
|
injectBuiltinAliases(inline);
|
|
21922
22017
|
return inline;
|
|
@@ -21928,7 +22023,7 @@ function mergeWorkers(options, ...configs) {
|
|
|
21928
22023
|
define: getDefineImportMetaEnv(),
|
|
21929
22024
|
build: resolveWorkersBuildDefaults(false)
|
|
21930
22025
|
});
|
|
21931
|
-
applyWeappViteHostMeta(inlineConfig, "miniprogram");
|
|
22026
|
+
applyWeappViteHostMeta(inlineConfig, "miniprogram", platform);
|
|
21932
22027
|
stripRollupOptions(inlineConfig);
|
|
21933
22028
|
inlineConfig.logLevel = "info";
|
|
21934
22029
|
injectBuiltinAliases(inlineConfig);
|
|
@@ -22095,8 +22190,8 @@ function createConfigService(ctx) {
|
|
|
22095
22190
|
return configState.importMetaEnvDefineOverride ?? getUserDefinedImportMetaEnv();
|
|
22096
22191
|
}
|
|
22097
22192
|
function getImportMetaBaseEnv() {
|
|
22098
|
-
const
|
|
22099
|
-
const resolvedPlatform = defineEnv.PLATFORM ??
|
|
22193
|
+
const miniPlatform = options?.platform ?? DEFAULT_MP_PLATFORM;
|
|
22194
|
+
const resolvedPlatform = defineEnv.PLATFORM ?? miniPlatform;
|
|
22100
22195
|
return {
|
|
22101
22196
|
PLATFORM: resolvedPlatform,
|
|
22102
22197
|
MP_PLATFORM: resolvedPlatform,
|
|
@@ -22114,8 +22209,8 @@ function createConfigService(ctx) {
|
|
|
22114
22209
|
}
|
|
22115
22210
|
function applyRuntimePlatform(runtime) {
|
|
22116
22211
|
const isWeb = runtime === "web";
|
|
22117
|
-
const
|
|
22118
|
-
setDefineEnv("PLATFORM", isWeb ? "web" :
|
|
22212
|
+
const miniPlatform = options?.platform ?? DEFAULT_MP_PLATFORM;
|
|
22213
|
+
setDefineEnv("PLATFORM", isWeb ? "web" : miniPlatform);
|
|
22119
22214
|
setDefineEnv("IS_WEB", isWeb);
|
|
22120
22215
|
setDefineEnv("IS_MINIPROGRAM", !isWeb);
|
|
22121
22216
|
}
|
|
@@ -22785,7 +22880,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
22785
22880
|
const vueAppPath = await findVueEntry(appBasename);
|
|
22786
22881
|
let configFromVue;
|
|
22787
22882
|
if (!appConfigFile && vueAppPath) {
|
|
22788
|
-
const { extractConfigFromVue } = await import("./file-
|
|
22883
|
+
const { extractConfigFromVue } = await import("./file-Dxf7qCi6.mjs");
|
|
22789
22884
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
22790
22885
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
22791
22886
|
}
|
|
@@ -23795,33 +23890,27 @@ function getAppPaths(ctx, legacyConfig) {
|
|
|
23795
23890
|
}
|
|
23796
23891
|
function createSharedTsconfig(ctx, legacyConfig) {
|
|
23797
23892
|
const userConfig = getManagedTypeScriptConfig(ctx);
|
|
23798
|
-
const config = { compilerOptions: {
|
|
23799
|
-
target: "ES2023",
|
|
23800
|
-
module: "ESNext",
|
|
23801
|
-
moduleResolution: "bundler",
|
|
23802
|
-
moduleDetection: "force",
|
|
23803
|
-
resolveJsonModule: true,
|
|
23804
|
-
allowImportingTsExtensions: true,
|
|
23805
|
-
strict: true,
|
|
23806
|
-
noFallthroughCasesInSwitch: true,
|
|
23807
|
-
noUnusedLocals: true,
|
|
23808
|
-
noUnusedParameters: true,
|
|
23809
|
-
noEmit: true,
|
|
23810
|
-
verbatimModuleSyntax: true,
|
|
23811
|
-
noUncheckedSideEffectImports: true,
|
|
23812
|
-
erasableSyntaxOnly: true,
|
|
23813
|
-
skipLibCheck: true,
|
|
23814
|
-
...omitDeprecatedCompilerOptions(legacyConfig?.shared?.compilerOptions) ?? {},
|
|
23815
|
-
...omitDeprecatedCompilerOptions(userConfig?.shared?.compilerOptions) ?? {}
|
|
23816
|
-
} };
|
|
23817
|
-
const exclude = unique([...legacyConfig?.shared?.exclude ?? [], ...userConfig?.shared?.exclude ?? []]);
|
|
23818
|
-
const files = unique([...legacyConfig?.shared?.files ?? [], ...userConfig?.shared?.files ?? []]);
|
|
23819
|
-
const include = unique([...legacyConfig?.shared?.include ?? [], ...userConfig?.shared?.include ?? []]);
|
|
23820
23893
|
return {
|
|
23821
|
-
|
|
23822
|
-
|
|
23823
|
-
|
|
23824
|
-
|
|
23894
|
+
compilerOptions: {
|
|
23895
|
+
target: "ES2023",
|
|
23896
|
+
module: "ESNext",
|
|
23897
|
+
moduleResolution: "bundler",
|
|
23898
|
+
moduleDetection: "force",
|
|
23899
|
+
resolveJsonModule: true,
|
|
23900
|
+
allowImportingTsExtensions: true,
|
|
23901
|
+
strict: true,
|
|
23902
|
+
noFallthroughCasesInSwitch: true,
|
|
23903
|
+
noUnusedLocals: true,
|
|
23904
|
+
noUnusedParameters: true,
|
|
23905
|
+
noEmit: true,
|
|
23906
|
+
verbatimModuleSyntax: true,
|
|
23907
|
+
noUncheckedSideEffectImports: true,
|
|
23908
|
+
erasableSyntaxOnly: true,
|
|
23909
|
+
skipLibCheck: true,
|
|
23910
|
+
...omitDeprecatedCompilerOptions(legacyConfig?.shared?.compilerOptions) ?? {},
|
|
23911
|
+
...omitDeprecatedCompilerOptions(userConfig?.shared?.compilerOptions) ?? {}
|
|
23912
|
+
},
|
|
23913
|
+
files: ["./tsconfig.shared.empty.d.ts"]
|
|
23825
23914
|
};
|
|
23826
23915
|
}
|
|
23827
23916
|
function createAppTsconfig(ctx, legacyConfig) {
|
|
@@ -23921,6 +24010,10 @@ async function createManagedTsconfigFiles(ctx) {
|
|
|
23921
24010
|
const nodePath = path.join(managedDir, "tsconfig.node.json");
|
|
23922
24011
|
const serverPath = path.join(managedDir, "tsconfig.server.json");
|
|
23923
24012
|
return [
|
|
24013
|
+
{
|
|
24014
|
+
path: path.join(managedDir, "tsconfig.shared.empty.d.ts"),
|
|
24015
|
+
content: "export {}\n"
|
|
24016
|
+
},
|
|
23924
24017
|
{
|
|
23925
24018
|
path: sharedPath,
|
|
23926
24019
|
content: toJson(createSharedTsconfig(ctx, legacyConfig))
|
|
@@ -23939,6 +24032,17 @@ async function createManagedTsconfigFiles(ctx) {
|
|
|
23939
24032
|
}
|
|
23940
24033
|
];
|
|
23941
24034
|
}
|
|
24035
|
+
function createManagedRootTsconfig() {
|
|
24036
|
+
return toJson({
|
|
24037
|
+
references: [
|
|
24038
|
+
{ path: "./.weapp-vite/tsconfig.app.json" },
|
|
24039
|
+
{ path: "./.weapp-vite/tsconfig.server.json" },
|
|
24040
|
+
{ path: "./.weapp-vite/tsconfig.node.json" },
|
|
24041
|
+
{ path: "./.weapp-vite/tsconfig.shared.json" }
|
|
24042
|
+
],
|
|
24043
|
+
files: []
|
|
24044
|
+
});
|
|
24045
|
+
}
|
|
23942
24046
|
async function hasManagedTsconfigChanges$1(ctx) {
|
|
23943
24047
|
const files = await createManagedTsconfigFiles(ctx);
|
|
23944
24048
|
for (const file of files) if (await fs.readFile(file.path, "utf8").catch(() => void 0) !== file.content) return true;
|
|
@@ -23958,6 +24062,12 @@ async function syncManagedTsconfigBootstrapFiles(cwd) {
|
|
|
23958
24062
|
weappViteConfig: {}
|
|
23959
24063
|
} };
|
|
23960
24064
|
let changed = false;
|
|
24065
|
+
const rootTsconfigPath = path.resolve(cwd, "tsconfig.json");
|
|
24066
|
+
const rootJsconfigPath = path.resolve(cwd, "jsconfig.json");
|
|
24067
|
+
if (!(await fs.pathExists(rootTsconfigPath) || await fs.pathExists(rootJsconfigPath))) {
|
|
24068
|
+
await fs.outputFile(rootTsconfigPath, createManagedRootTsconfig(), "utf8");
|
|
24069
|
+
changed = true;
|
|
24070
|
+
}
|
|
23961
24071
|
for (const file of await createManagedTsconfigFiles(bootstrapCtx)) {
|
|
23962
24072
|
if (await fs.readFile(file.path, "utf8").catch(() => void 0) != null) continue;
|
|
23963
24073
|
await fs.outputFile(file.path, file.content, "utf8");
|
|
@@ -24061,4 +24171,4 @@ async function createCompilerContext(options) {
|
|
|
24061
24171
|
return ctx;
|
|
24062
24172
|
}
|
|
24063
24173
|
//#endregion
|
|
24064
|
-
export {
|
|
24174
|
+
export { getDefaultIdeProjectRoot as C, createCjsConfigLoadError as S, isPathInside as T, resolveWeappConfigFile as _, resetCompilerContext as a, loadViteConfigFile as b, WEB_PLATFORM_ALIASES as c, isWebPlatform as d, resolveWeappViteTarget as f, getRouteRuntimeGlobalKeys as g, resolveHmrProfileJsonPath as h, getCompilerContext as i, getSupportedWeappVitePlatforms as l, SHARED_CHUNK_VIRTUAL_PREFIX as m, syncProjectSupportFiles as n, setActiveCompilerContextKey as o, createSharedBuildConfig as p, syncManagedTsconfigBootstrapFiles as r, formatBytes as s, createCompilerContext as t, getSupportedWeappViteTargetDescriptors as u, checkRuntime as v, shouldPassPlatformArgToIdeOpen as w, parseCommentJson as x, getProjectConfigFileName as y };
|
package/dist/docs/volar.md
CHANGED
|
@@ -29,7 +29,25 @@ weapp-vite 集成了 Volar 插件,为 `<json>` 代码块提供完整的智能
|
|
|
29
29
|
}
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
### 2.1
|
|
32
|
+
### 2.1 TypeScript project 入口
|
|
33
|
+
|
|
34
|
+
推荐保留根 `tsconfig.json` 的 solution references 结构,并把业务 `.vue` 类型检查入口交给 `.weapp-vite/tsconfig.app.json`:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"references": [
|
|
39
|
+
{ "path": "./.weapp-vite/tsconfig.app.json" },
|
|
40
|
+
{ "path": "./.weapp-vite/tsconfig.server.json" },
|
|
41
|
+
{ "path": "./.weapp-vite/tsconfig.node.json" },
|
|
42
|
+
{ "path": "./.weapp-vite/tsconfig.shared.json" }
|
|
43
|
+
],
|
|
44
|
+
"files": []
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`.weapp-vite/tsconfig.shared.json` 只用于 `extends` 共享公共 `compilerOptions`,即使被根 solution config reference,也只会通过 `files` 引用一个空占位声明文件,避免作为独立 project 时隐式包含全仓库声明文件。`.vue`、自动导入组件、`definePageJson` 和 `wevu/router` 的类型归属应由 `.weapp-vite/tsconfig.app.json` 承接。
|
|
49
|
+
|
|
50
|
+
### 2.2 模板类型推断注意事项
|
|
33
51
|
|
|
34
52
|
如果你依赖模板里的额外绑定推断,例如:
|
|
35
53
|
|
|
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
|
|
|
84
84
|
}
|
|
85
85
|
async function resolveAutoRoutesInlineSnapshot() {
|
|
86
86
|
try {
|
|
87
|
-
const { getCompilerContext } = await import("./getInstance-
|
|
87
|
+
const { getCompilerContext } = await import("./getInstance-BWhJaTcd.mjs");
|
|
88
88
|
const compilerContext = getCompilerContext();
|
|
89
89
|
const service = compilerContext.autoRoutesService;
|
|
90
90
|
const reference = service?.getReference?.();
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Ref, Bn as
|
|
1
|
+
import { $n as getSupportedWeappViteTargetDescriptors, A as Ref, Bn as createWeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Gn as WEB_PLATFORM_ALIASES, Hn as resolveWeappViteHostMeta, I as RolldownPluginOption, Jn as WeappViteTargetDescriptor, Kn as WeappVitePlatform, L as RolldownWatchOptions, Ln as WEAPP_VITE_HOST_NAME, M as RolldownBuild, N as RolldownOptions, O as Plugin, P as RolldownOutput, Qn as getSupportedWeappVitePlatforms, R as RolldownWatcher, Rn as WeappViteHostMeta, S as CompilerContext, T as ConfigEnv, Un as ResolveWeappViteTargetOptions, Vn as isWeappViteHost, Wn as ResolvedWeappViteTarget, Xn as WeappViteTargetKind, Yn as WeappViteTargetInput, Zn as WebPlatform, _ as definePageJson, a as UserConfigFnNoEnvPlain, at as WeappViteConfig, c as UserConfigFnPromise, d as Component, er as isWebPlatform, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, j as ResolvedConfig, k as PluginOption, l as defineConfig, m as Theme, n as UserConfigExport, o as UserConfigFnObject, p as Sitemap, qn as WeappViteRuntime, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, tr as resolveWeappViteTarget, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer, zn as applyWeappViteHostMeta } from "./config-CXABkCb8.mjs";
|
|
2
2
|
import { a as createWevuComponent, i as WevuComponentOptions, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-DSLk7kWi.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/createContext.d.ts
|
|
@@ -12,4 +12,4 @@ interface CreateCompilerContextOptions extends Partial<LoadConfigOptions> {
|
|
|
12
12
|
*/
|
|
13
13
|
declare function createCompilerContext(options?: CreateCompilerContextOptions): Promise<CompilerContext>;
|
|
14
14
|
//#endregion
|
|
15
|
-
export { App, Component, ComputedDefinitions, ConfigEnv, InlineConfig, MethodDefinitions, Page, Plugin, PluginOption, Ref, ResolvedConfig, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatchOptions, RolldownWatcher, Sitemap, Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, ViteDevServer, WEAPP_VITE_HOST_NAME, WeappViteConfig, WeappViteHostMeta, WeappViteRuntime, type WevuComponentOptions, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta, setPageLayout };
|
|
15
|
+
export { App, Component, ComputedDefinitions, ConfigEnv, InlineConfig, MethodDefinitions, Page, Plugin, PluginOption, Ref, ResolveWeappViteTargetOptions, ResolvedConfig, ResolvedWeappViteTarget, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatchOptions, RolldownWatcher, Sitemap, Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, ViteDevServer, WEAPP_VITE_HOST_NAME, WEB_PLATFORM_ALIASES, WeappViteConfig, WeappViteHostMeta, WeappVitePlatform, WeappViteRuntime, WeappViteTargetDescriptor, WeappViteTargetInput, WeappViteTargetKind, WebPlatform, type WevuComponentOptions, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, getSupportedWeappVitePlatforms, getSupportedWeappViteTargetDescriptors, isWeappViteHost, isWebPlatform, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-D0HkutE0.mjs";
|
|
2
|
-
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-
|
|
2
|
+
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-BEnGeaSo.mjs";
|
|
3
3
|
import { t as defineConfig } from "./config-DJjSbpNX.mjs";
|
|
4
|
-
import { t as createCompilerContext } from "./createContext-
|
|
4
|
+
import { c as WEB_PLATFORM_ALIASES, d as isWebPlatform, f as resolveWeappViteTarget, l as getSupportedWeappVitePlatforms, t as createCompilerContext, u as getSupportedWeappViteTargetDescriptors } from "./createContext-CoTaL8he.mjs";
|
|
5
5
|
import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-DN3lxU9s.mjs";
|
|
6
|
-
export { WEAPP_VITE_HOST_NAME, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta, setPageLayout };
|
|
6
|
+
export { WEAPP_VITE_HOST_NAME, WEB_PLATFORM_ALIASES, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, getSupportedWeappVitePlatforms, getSupportedWeappViteTargetDescriptors, isWeappViteHost, isWebPlatform, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout };
|
package/dist/json.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-
|
|
1
|
+
import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-CXABkCb8.mjs";
|
|
2
2
|
export { App, Component, Page, Sitemap, Theme, defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as logger_default } from "./logger-CgxdNjvb.mjs";
|
|
2
2
|
import { connectMiniProgram } from "weapp-ide-cli";
|
|
3
|
-
import { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, createWeappViteMcpServer, startWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
3
|
+
import { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, createWeappViteMcpServer, startWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
4
4
|
//#region src/mcp.ts
|
|
5
5
|
function normalizeEndpoint(input) {
|
|
6
6
|
const value = typeof input === "string" ? input.trim() : "";
|
|
@@ -17,7 +17,8 @@ function resolveWeappMcpConfig(config) {
|
|
|
17
17
|
autoStart: false,
|
|
18
18
|
host: DEFAULT_MCP_HOST,
|
|
19
19
|
port: DEFAULT_MCP_PORT,
|
|
20
|
-
endpoint: DEFAULT_MCP_ENDPOINT
|
|
20
|
+
endpoint: DEFAULT_MCP_ENDPOINT,
|
|
21
|
+
restEndpoint: DEFAULT_RUNTIME_REST_ENDPOINT
|
|
21
22
|
};
|
|
22
23
|
const record = typeof config === "object" && config ? config : {};
|
|
23
24
|
return {
|
|
@@ -25,7 +26,8 @@ function resolveWeappMcpConfig(config) {
|
|
|
25
26
|
autoStart: record.autoStart === true,
|
|
26
27
|
host: typeof record.host === "string" && record.host.trim().length > 0 ? record.host.trim() : DEFAULT_MCP_HOST,
|
|
27
28
|
port: normalizePort(record.port),
|
|
28
|
-
endpoint: normalizeEndpoint(record.endpoint)
|
|
29
|
+
endpoint: normalizeEndpoint(record.endpoint),
|
|
30
|
+
restEndpoint: record.restEndpoint === false ? false : normalizeEndpoint(record.restEndpoint ?? DEFAULT_RUNTIME_REST_ENDPOINT)
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
async function startWeappViteMcpServer$1(options) {
|
|
@@ -38,4 +40,4 @@ async function startWeappViteMcpServer$1(options) {
|
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
//#endregion
|
|
41
|
-
export {
|
|
43
|
+
export { createWeappViteMcpServer as a, DEFAULT_RUNTIME_REST_ENDPOINT as i, DEFAULT_MCP_HOST as n, resolveWeappMcpConfig as o, DEFAULT_MCP_PORT as r, startWeappViteMcpServer$1 as s, DEFAULT_MCP_ENDPOINT as t };
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { wt as WeappMcpConfig } from "./config-
|
|
2
|
-
import { CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, McpServerHandle, StartMcpServerOptions, createWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
1
|
+
import { wt as WeappMcpConfig } from "./config-CXABkCb8.mjs";
|
|
2
|
+
import { CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, McpServerHandle, StartMcpServerOptions, createWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
3
3
|
|
|
4
4
|
//#region src/mcp.d.ts
|
|
5
5
|
interface ResolvedWeappMcpConfig {
|
|
@@ -8,10 +8,11 @@ interface ResolvedWeappMcpConfig {
|
|
|
8
8
|
host: string;
|
|
9
9
|
port: number;
|
|
10
10
|
endpoint: string;
|
|
11
|
+
restEndpoint: string | false;
|
|
11
12
|
}
|
|
12
13
|
interface WeappViteMcpServerOptions extends StartMcpServerOptions {}
|
|
13
14
|
interface WeappViteMcpServerHandle extends McpServerHandle {}
|
|
14
15
|
declare function resolveWeappMcpConfig(config?: boolean | WeappMcpConfig): ResolvedWeappMcpConfig;
|
|
15
16
|
declare function startWeappViteMcpServer(options?: WeappViteMcpServerOptions): Promise<WeappViteMcpServerHandle>;
|
|
16
17
|
//#endregion
|
|
17
|
-
export { type CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, ResolvedWeappMcpConfig, WeappViteMcpServerHandle, WeappViteMcpServerOptions, createWeappViteMcpServer, resolveWeappMcpConfig, startWeappViteMcpServer };
|
|
18
|
+
export { type CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, ResolvedWeappMcpConfig, WeappViteMcpServerHandle, WeappViteMcpServerOptions, createWeappViteMcpServer, resolveWeappMcpConfig, startWeappViteMcpServer };
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, createWeappViteMcpServer, resolveWeappMcpConfig, startWeappViteMcpServer };
|
|
1
|
+
import { a as createWeappViteMcpServer, i as DEFAULT_RUNTIME_REST_ENDPOINT, n as DEFAULT_MCP_HOST, o as resolveWeappMcpConfig, r as DEFAULT_MCP_PORT, s as startWeappViteMcpServer, t as DEFAULT_MCP_ENDPOINT } from "./mcp-DV3K2AVD.mjs";
|
|
2
|
+
export { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, createWeappViteMcpServer, resolveWeappMcpConfig, startWeappViteMcpServer };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
//#region src/pluginHost.ts
|
|
2
2
|
const WEAPP_VITE_HOST_NAME = "weapp-vite";
|
|
3
|
-
function createWeappViteHostMeta(runtime) {
|
|
4
|
-
|
|
3
|
+
function createWeappViteHostMeta(runtime, platform) {
|
|
4
|
+
const meta = {
|
|
5
5
|
name: WEAPP_VITE_HOST_NAME,
|
|
6
6
|
runtime
|
|
7
7
|
};
|
|
8
|
+
if (platform) meta.platform = platform;
|
|
9
|
+
return meta;
|
|
8
10
|
}
|
|
9
|
-
function applyWeappViteHostMeta(config, runtime) {
|
|
10
|
-
config.weappVite = createWeappViteHostMeta(runtime);
|
|
11
|
+
function applyWeappViteHostMeta(config, runtime, platform) {
|
|
12
|
+
config.weappVite = createWeappViteHostMeta(runtime, platform);
|
|
11
13
|
return config;
|
|
12
14
|
}
|
|
13
15
|
function resolveWeappViteHostMeta(config) {
|
|
@@ -15,6 +17,7 @@ function resolveWeappViteHostMeta(config) {
|
|
|
15
17
|
if (!meta || typeof meta !== "object") return;
|
|
16
18
|
if (meta.name !== "weapp-vite") return;
|
|
17
19
|
if (meta.runtime !== "miniprogram" && meta.runtime !== "web") return;
|
|
20
|
+
if (meta.platform !== void 0 && typeof meta.platform !== "string") return;
|
|
18
21
|
return meta;
|
|
19
22
|
}
|
|
20
23
|
function isWeappViteHost(config) {
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { c as Resolver } from "./index-C1yQldy3.mjs";
|
|
2
2
|
import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-DiEBrMtj.mjs";
|
|
3
|
-
import { $ as WeappAnalyzeBudgetConfig, $t as GenerateTemplateScope, A as Ref, An as WeappLibVueTscOptions, At as WeappVueConfig, B as BindingErrorLike, Bt as CopyGlobs, Cn as SubPackageStyleScope, Ct as WeappInjectWebRuntimeGlobalsTarget, D as MethodDefinitions, Dn as WeappLibEntryContext, Dt as WeappRouteRule, E as InlineConfig, En as WeappLibDtsOptions, Et as WeappRequestRuntimeConfig, F as RolldownPlugin, Fn as WeappManagedTypeScriptConfig, Ft as Alias, G as EntryJsonFragment, Gt as GenerateFilenamesOptions, H as BaseEntry, Ht as GenerateDirsOptions, I as RolldownPluginOption, In as WeappWebConfig, It as AliasOptions, J as ScanComponentItem, Jt as GenerateTemplateContext, K as PageEntry, Kt as GenerateOptions, L as RolldownWatchOptions, Lt as AlipayNpmMode, M as RolldownBuild, Mn as WeappManagedNodeTsconfigConfig, Mt as WeappWebRuntimeConfig, N as RolldownOptions, Nn as WeappManagedServerTsconfigConfig, Nt as WeappWevuConfig, O as Plugin, On as WeappLibFileName, Ot as WeappRouteRules, P as RolldownOutput, Pn as WeappManagedSharedTsconfigConfig, Pt as WeappWorkerConfig, Q as UserConfig, Qt as GenerateTemplateInlineSource, R as RolldownWatcher, Rn as WeappViteHostMeta, Rt as BuildNpmPackageMeta, Sn as SubPackageStyleEntry, St as WeappInjectWebRuntimeGlobalsConfig, T as ConfigEnv, Tn as WeappLibConfig, Tt as WeappNpmConfig, U as ComponentEntry, Ut as GenerateExtensionsOptions, V as AppEntry, Vt as CopyOptions, W as Entry, Wt as GenerateFileType, X as ProjectConfig, Xt as GenerateTemplateFactory, Y as WxmlDep, Yt as GenerateTemplateEntry, Z as SubPackageMetaValue, Zt as GenerateTemplateFileSource, _n as SharedChunkOverride, _t as WeappAutoRoutesIncludePattern, an as JsonMergeStage, at as WeappViteConfig, b as ChangeEvent, bn as SubPackageStyleConfigEntry, bt as WeappInjectRequestGlobalsTarget, cn as NpmBuildOptions, ct as EnhanceOptions, dn as NpmPluginPackageConfig, dt as MultiPlatformConfig, en as GenerateTemplatesConfig, et as WeappAnalyzeConfig, fn as NpmStrategy, ft as ScanWxmlOptions, gn as SharedChunkMode, gt as WeappAutoRoutesInclude, hn as SharedChunkDynamicImports, ht as WeappAutoRoutesConfig, in as JsonMergeFunction, it as WeappForwardConsoleLogLevel, j as ResolvedConfig, jn as WeappManagedAppTsconfigConfig, jt as WeappVueTemplateConfig, k as PluginOption, kn as WeappLibInternalDtsOptions, kt as WeappSubPackageConfig, ln as NpmDependencyPattern, lt as EnhanceWxmlOptions, mn as ResolvedAlias, mt as WeappAppPreludeMode, nn as JsonConfig, nt as WeappDebugConfig, on as JsonMergeStrategy, ot as AutoImportComponents, pn as NpmSubPackageConfig, pt as WeappAppPreludeConfig, q as ComponentsMap, qt as GenerateTemplate, rn as JsonMergeContext, rt as WeappForwardConsoleConfig, sn as MpPlatform, st as AutoImportComponentsOption, tn as JsFormat, tt as WeappAnalyzeHistoryConfig, un as NpmMainPackageConfig, ut as HandleWxmlOptions, vn as SharedChunkStrategy, vt as WeappHmrConfig, w as ComputedDefinitions, wn as WeappLibComponentJson, wt as WeappMcpConfig, x as WeappVitePluginApi, xn as SubPackageStyleConfigObject, xt as WeappInjectWeapiConfig, yn as SubPackage, yt as WeappInjectRequestGlobalsConfig, z as ViteDevServer,
|
|
3
|
+
import { $ as WeappAnalyzeBudgetConfig, $t as GenerateTemplateScope, A as Ref, An as WeappLibVueTscOptions, At as WeappVueConfig, B as BindingErrorLike, Bt as CopyGlobs, Cn as SubPackageStyleScope, Ct as WeappInjectWebRuntimeGlobalsTarget, D as MethodDefinitions, Dn as WeappLibEntryContext, Dt as WeappRouteRule, E as InlineConfig, En as WeappLibDtsOptions, Et as WeappRequestRuntimeConfig, F as RolldownPlugin, Fn as WeappManagedTypeScriptConfig, Ft as Alias, G as EntryJsonFragment, Gt as GenerateFilenamesOptions, H as BaseEntry, Ht as GenerateDirsOptions, I as RolldownPluginOption, In as WeappWebConfig, It as AliasOptions, J as ScanComponentItem, Jt as GenerateTemplateContext, K as PageEntry, Kt as GenerateOptions, L as RolldownWatchOptions, Lt as AlipayNpmMode, M as RolldownBuild, Mn as WeappManagedNodeTsconfigConfig, Mt as WeappWebRuntimeConfig, N as RolldownOptions, Nn as WeappManagedServerTsconfigConfig, Nt as WeappWevuConfig, O as Plugin, On as WeappLibFileName, Ot as WeappRouteRules, P as RolldownOutput, Pn as WeappManagedSharedTsconfigConfig, Pt as WeappWorkerConfig, Q as UserConfig, Qt as GenerateTemplateInlineSource, R as RolldownWatcher, Rn as WeappViteHostMeta, Rt as BuildNpmPackageMeta, Sn as SubPackageStyleEntry, St as WeappInjectWebRuntimeGlobalsConfig, T as ConfigEnv, Tn as WeappLibConfig, Tt as WeappNpmConfig, U as ComponentEntry, Ut as GenerateExtensionsOptions, V as AppEntry, Vt as CopyOptions, W as Entry, Wt as GenerateFileType, X as ProjectConfig, Xt as GenerateTemplateFactory, Y as WxmlDep, Yt as GenerateTemplateEntry, Z as SubPackageMetaValue, Zt as GenerateTemplateFileSource, _n as SharedChunkOverride, _t as WeappAutoRoutesIncludePattern, an as JsonMergeStage, at as WeappViteConfig, b as ChangeEvent, bn as SubPackageStyleConfigEntry, bt as WeappInjectRequestGlobalsTarget, cn as NpmBuildOptions, ct as EnhanceOptions, dn as NpmPluginPackageConfig, dt as MultiPlatformConfig, en as GenerateTemplatesConfig, et as WeappAnalyzeConfig, fn as NpmStrategy, ft as ScanWxmlOptions, gn as SharedChunkMode, gt as WeappAutoRoutesInclude, hn as SharedChunkDynamicImports, ht as WeappAutoRoutesConfig, in as JsonMergeFunction, it as WeappForwardConsoleLogLevel, j as ResolvedConfig, jn as WeappManagedAppTsconfigConfig, jt as WeappVueTemplateConfig, k as PluginOption, kn as WeappLibInternalDtsOptions, kt as WeappSubPackageConfig, ln as NpmDependencyPattern, lt as EnhanceWxmlOptions, mn as ResolvedAlias, mt as WeappAppPreludeMode, nn as JsonConfig, nt as WeappDebugConfig, on as JsonMergeStrategy, ot as AutoImportComponents, pn as NpmSubPackageConfig, pt as WeappAppPreludeConfig, q as ComponentsMap, qn as WeappViteRuntime, qt as GenerateTemplate, rn as JsonMergeContext, rt as WeappForwardConsoleConfig, sn as MpPlatform, st as AutoImportComponentsOption, tn as JsFormat, tt as WeappAnalyzeHistoryConfig, un as NpmMainPackageConfig, ut as HandleWxmlOptions, vn as SharedChunkStrategy, vt as WeappHmrConfig, w as ComputedDefinitions, wn as WeappLibComponentJson, wt as WeappMcpConfig, x as WeappVitePluginApi, xn as SubPackageStyleConfigObject, xt as WeappInjectWeapiConfig, yn as SubPackage, yt as WeappInjectRequestGlobalsConfig, z as ViteDevServer, zt as ChunksConfig } from "./config-CXABkCb8.mjs";
|
|
4
4
|
export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, ComputedDefinitions, ConfigEnv, CopyGlobs, CopyOptions, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, InlineConfig, JsFormat, JsonConfig, JsonMergeContext, JsonMergeFunction, JsonMergeStage, JsonMergeStrategy, MethodDefinitions, MpPlatform, MultiPlatformConfig, NpmBuildOptions, NpmDependencyPattern, NpmMainPackageConfig, NpmPluginPackageConfig, NpmStrategy, NpmSubPackageConfig, PageEntry, Plugin, PluginOption, ProjectConfig, Ref, ResolvedAlias, ResolvedConfig, Resolver, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatchOptions, RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, ViteDevServer, WeappAnalyzeBudgetConfig, WeappAnalyzeConfig, WeappAnalyzeHistoryConfig, WeappAppPreludeConfig, WeappAppPreludeMode, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappInjectWebRuntimeGlobalsConfig, WeappInjectWebRuntimeGlobalsTarget, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappRequestRuntimeConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappViteConfig, WeappViteHostMeta, WeappVitePluginApi, WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWebRuntimeConfig, WeappWevuConfig, WeappWorkerConfig, WxmlDep };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.16.
|
|
4
|
+
"version": "6.16.4",
|
|
5
5
|
"description": "weapp-vite 一个现代化的小程序打包工具",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@jridgewell/remapping": "^2.3.5",
|
|
94
94
|
"@vercel/detect-agent": "^1.2.3",
|
|
95
95
|
"@volar/typescript": "^2.4.28",
|
|
96
|
-
"@vue/language-core": "^3.2.
|
|
96
|
+
"@vue/language-core": "^3.2.8",
|
|
97
97
|
"cac": "^7.0.0",
|
|
98
98
|
"chokidar": "^5.0.0",
|
|
99
99
|
"comment-json": "^5.0.0",
|
|
@@ -101,14 +101,14 @@
|
|
|
101
101
|
"fdir": "^6.5.0",
|
|
102
102
|
"htmlparser2": "^12.0.0",
|
|
103
103
|
"local-pkg": "^1.1.2",
|
|
104
|
-
"lru-cache": "^11.3.
|
|
104
|
+
"lru-cache": "^11.3.6",
|
|
105
105
|
"magic-string": "^0.30.21",
|
|
106
106
|
"merge": "^2.1.1",
|
|
107
107
|
"p-queue": "^9.2.0",
|
|
108
108
|
"package-manager-detector": "^1.6.0",
|
|
109
109
|
"pathe": "^2.0.3",
|
|
110
110
|
"picomatch": "^4.0.4",
|
|
111
|
-
"postcss": "^8.5.
|
|
111
|
+
"postcss": "^8.5.14",
|
|
112
112
|
"rolldown": "1.0.0-rc.17",
|
|
113
113
|
"rolldown-plugin-dts": "0.23.2",
|
|
114
114
|
"semver": "^7.7.4",
|
|
@@ -116,30 +116,30 @@
|
|
|
116
116
|
"vite": "8.0.10",
|
|
117
117
|
"vite-tsconfig-paths": "^6.1.1",
|
|
118
118
|
"vue": "^3.5.33",
|
|
119
|
-
"vue-tsc": "^3.2.
|
|
119
|
+
"vue-tsc": "^3.2.8",
|
|
120
120
|
"@weapp-core/constants": "^0.1.4",
|
|
121
121
|
"@weapp-core/init": "6.0.8",
|
|
122
122
|
"@weapp-core/logger": "3.1.1",
|
|
123
123
|
"@weapp-core/schematics": "6.0.4",
|
|
124
124
|
"@weapp-core/shared": "3.0.4",
|
|
125
|
-
"@weapp-vite/ast": "6.16.
|
|
126
|
-
"@weapp-vite/mcp": "1.3.
|
|
127
|
-
"@weapp-vite/miniprogram-automator": "1.0.
|
|
125
|
+
"@weapp-vite/ast": "6.16.4",
|
|
126
|
+
"@weapp-vite/mcp": "1.3.1",
|
|
127
|
+
"@weapp-vite/miniprogram-automator": "1.0.5",
|
|
128
128
|
"@weapp-vite/volar": "2.1.0",
|
|
129
129
|
"@weapp-vite/web": "1.3.19",
|
|
130
130
|
"@wevu/api": "0.2.6",
|
|
131
131
|
"@wevu/web-apis": "1.2.10",
|
|
132
132
|
"rolldown-require": "2.0.15",
|
|
133
133
|
"vite-plugin-performance": "2.0.1",
|
|
134
|
-
"weapp-ide-cli": "5.2.
|
|
135
|
-
"wevu": "6.16.
|
|
134
|
+
"weapp-ide-cli": "5.2.8",
|
|
135
|
+
"wevu": "6.16.4"
|
|
136
136
|
},
|
|
137
137
|
"publishConfig": {
|
|
138
138
|
"access": "public",
|
|
139
139
|
"registry": "https://registry.npmjs.org"
|
|
140
140
|
},
|
|
141
141
|
"devDependencies": {
|
|
142
|
-
"oxc-parser": "^0.
|
|
142
|
+
"oxc-parser": "^0.129.0",
|
|
143
143
|
"oxc-walker": "^0.7.0",
|
|
144
144
|
"tailwindcss": "^4.2.4",
|
|
145
145
|
"ts-morph": "^28.0.0"
|
package/dist/file-C0XHk9ks.mjs
DELETED