weapp-vite 6.15.4 → 6.15.6
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/README.md +45 -2
- package/dist/auto-routes.mjs +1 -1
- package/dist/cli.mjs +50 -8
- package/dist/{config-B5YFoO3u.d.mts → config-BbL8Gqez.d.mts} +7 -0
- package/dist/config.d.mts +1 -1
- package/dist/{createContext-BuwQryVc.mjs → createContext-DPe-Wp3_.mjs} +78 -10
- package/dist/docs/README.md +45 -2
- package/dist/docs/vue-sfc.md +27 -0
- package/dist/docs/weapp-config.md +10 -0
- package/dist/{file-x_pM3sdN.mjs → file-CCWF5mwT.mjs} +1 -1
- package/dist/file-DY9paehF.mjs +2 -0
- package/dist/getInstance-DPNGGEFm.mjs +2 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/json.d.mts +1 -1
- package/dist/mcp.d.mts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +7 -7
- package/dist/file-BVlUDAip.mjs +0 -2
- package/dist/getInstance-DPy6RmDl.mjs +0 -2
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
### Vue 项目
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
|
-
// vite.config.ts
|
|
39
|
+
// vite.config.ts 或 weapp-vite.config.ts
|
|
40
40
|
import { defineConfig } from 'weapp-vite/config'
|
|
41
41
|
|
|
42
42
|
export default defineConfig({
|
|
@@ -46,12 +46,21 @@ export default defineConfig({
|
|
|
46
46
|
enable: true,
|
|
47
47
|
template: {
|
|
48
48
|
removeComments: true,
|
|
49
|
+
htmlTagToWxml: true,
|
|
50
|
+
htmlTagToWxmlTagClass: true,
|
|
49
51
|
},
|
|
50
52
|
},
|
|
51
53
|
},
|
|
52
54
|
})
|
|
53
55
|
```
|
|
54
56
|
|
|
57
|
+
如果你在把传统 HTML/Vue 模板迁移到小程序 `.vue`,这两个模板配置通常最有用:
|
|
58
|
+
|
|
59
|
+
- `weapp.vue.template.htmlTagToWxml`
|
|
60
|
+
把 `div/span/img/a/h1...` 等常见 HTML 标签映射成小程序内置标签。
|
|
61
|
+
- `weapp.vue.template.htmlTagToWxmlTagClass`
|
|
62
|
+
默认开启。在映射发生时追加原标签名 class,例如 `h3 -> <view class="h3">`、`br -> <view class="br" />`,便于你自己写 CSS 低成本恢复默认外观;不需要时可设为 `false`。
|
|
63
|
+
|
|
55
64
|
```vue
|
|
56
65
|
<!-- App.vue -->
|
|
57
66
|
<script setup>
|
|
@@ -178,6 +187,38 @@ wv ide logs
|
|
|
178
187
|
wv ide logs --open
|
|
179
188
|
```
|
|
180
189
|
|
|
190
|
+
## DevTools 配置预热
|
|
191
|
+
|
|
192
|
+
`weapp-vite` 在打开微信开发者工具前,会复用 `weapp-ide-cli` 的底层能力,自动尝试预热本机 DevTools 配置:
|
|
193
|
+
|
|
194
|
+
- 确保安全设置中的服务端口处于开启状态
|
|
195
|
+
- 按命令参数或全局配置决定是否自动信任当前项目
|
|
196
|
+
|
|
197
|
+
如果你只想预热配置、不立即打开 IDE,可以使用:
|
|
198
|
+
|
|
199
|
+
```sh
|
|
200
|
+
weapp-vite ide setup .
|
|
201
|
+
# 等价写法
|
|
202
|
+
wv ide setup .
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
如果你希望以后 `open` / `dev --open` / `build --open` 都默认自动信任项目,直接配置 `weapp-ide-cli` 即可:
|
|
206
|
+
|
|
207
|
+
```sh
|
|
208
|
+
weapp config set autoBootstrapDevtools true
|
|
209
|
+
weapp config set autoTrustProject true
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
这样以后执行:
|
|
213
|
+
|
|
214
|
+
```sh
|
|
215
|
+
weapp-vite open .
|
|
216
|
+
weapp-vite dev --open
|
|
217
|
+
weapp-vite build --open
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
都会沿用同一套默认策略。
|
|
221
|
+
|
|
181
222
|
## CLI 中调用 weapp-ide-cli
|
|
182
223
|
|
|
183
224
|
`weapp-vite` 内置了对 `weapp-ide-cli` 的透传能力,除了 `dev/build/open/init/generate/analyze/npm` 等原生命令外,其它 IDE 相关命令都可以直接调用:
|
|
@@ -188,6 +229,7 @@ weapp-vite upload --project ./dist/build/mp-weixin -v 1.0.0 -d "release"
|
|
|
188
229
|
weapp-vite cache --clean compile
|
|
189
230
|
weapp-vite cache --clean all
|
|
190
231
|
weapp-vite config lang zh
|
|
232
|
+
weapp-vite config set autoTrustProject true
|
|
191
233
|
weapp-vite navigate pages/index/index --project ./dist/build/mp-weixin
|
|
192
234
|
# 等价写法
|
|
193
235
|
wv preview --project ./dist/build/mp-weixin
|
|
@@ -199,6 +241,7 @@ wv cache --clean all
|
|
|
199
241
|
```sh
|
|
200
242
|
weapp-vite ide preview --project ./dist/build/mp-weixin
|
|
201
243
|
weapp-vite ide config show
|
|
244
|
+
weapp-vite ide setup .
|
|
202
245
|
weapp-vite ide logs --open
|
|
203
246
|
# 等价写法
|
|
204
247
|
wv ide preview --project ./dist/build/mp-weixin
|
|
@@ -239,7 +282,7 @@ weapp-vite mcp --workspace-root /absolute/path/to/weapp-vite
|
|
|
239
282
|
wv mcp --workspace-root /absolute/path/to/weapp-vite
|
|
240
283
|
```
|
|
241
284
|
|
|
242
|
-
在 `vite.config.ts` 中开启自动启动:
|
|
285
|
+
在 `vite.config.ts` 或 `weapp-vite.config.ts` 中开启自动启动:
|
|
243
286
|
|
|
244
287
|
```ts
|
|
245
288
|
import { defineConfig } from 'weapp-vite/config'
|
package/dist/auto-routes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as getCompilerContext, u as getRouteRuntimeGlobalKeys } from "./createContext-
|
|
1
|
+
import { i as getCompilerContext, u as getRouteRuntimeGlobalKeys } from "./createContext-DPe-Wp3_.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,6 +1,6 @@
|
|
|
1
|
-
import { S as isPathInside, _ as DEFAULT_MP_PLATFORM, b as resolveMiniPlatform, c as createSharedBuildConfig, d as resolveWeappConfigFile, f as checkRuntime, g as createCjsConfigLoadError, h as parseCommentJson, l as SHARED_CHUNK_VIRTUAL_PREFIX, m as loadViteConfigFile, n as syncProjectSupportFiles, p as getProjectConfigFileName, r as syncManagedTsconfigBootstrapFiles, s as formatBytes, t as createCompilerContext, v as getDefaultIdeProjectRoot, x as shouldPassPlatformArgToIdeOpen, y as normalizeMiniPlatform } from "./createContext-
|
|
1
|
+
import { S as isPathInside, _ as DEFAULT_MP_PLATFORM, b as resolveMiniPlatform, c as createSharedBuildConfig, d as resolveWeappConfigFile, f as checkRuntime, g as createCjsConfigLoadError, h as parseCommentJson, l as SHARED_CHUNK_VIRTUAL_PREFIX, m as loadViteConfigFile, n as syncProjectSupportFiles, p as getProjectConfigFileName, r as syncManagedTsconfigBootstrapFiles, s as formatBytes, t as createCompilerContext, v as getDefaultIdeProjectRoot, x as shouldPassPlatformArgToIdeOpen, y as normalizeMiniPlatform } from "./createContext-DPe-Wp3_.mjs";
|
|
2
2
|
import { r as logger_default, t as colors } from "./logger-CgxdNjvb.mjs";
|
|
3
|
-
import { h as VERSION } from "./file-
|
|
3
|
+
import { h as VERSION } from "./file-CCWF5mwT.mjs";
|
|
4
4
|
import { a as resolveWeappMcpConfig, o as startWeappViteMcpServer } from "./mcp-DRlj32v4.mjs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import path, { posix } from "pathe";
|
|
@@ -15,7 +15,7 @@ import fs$2 from "node:fs";
|
|
|
15
15
|
import { cac } from "cac";
|
|
16
16
|
import { resolveCommand } from "package-manager-detector/commands";
|
|
17
17
|
import { promisify } from "node:util";
|
|
18
|
-
import { closeSharedMiniProgram, connectOpenedAutomator, formatRetryHotkeyPrompt, formatWechatIdeLoginRequiredError, getConfig, isWeappIdeTopLevelCommand, isWechatIdeLoginRequiredError, launchAutomator, parse, startForwardConsole, takeScreenshot, waitForRetryKeypress } from "weapp-ide-cli";
|
|
18
|
+
import { bootstrapWechatDevtoolsSettings, closeSharedMiniProgram, connectOpenedAutomator, formatAutomatorLoginError, formatRetryHotkeyPrompt, formatWechatIdeLoginRequiredError, getConfig, isAutomatorLoginError, isWeappIdeTopLevelCommand, isWechatIdeLoginRequiredError, launchAutomator, parse, startForwardConsole, takeScreenshot, waitForRetryKeypress } from "weapp-ide-cli";
|
|
19
19
|
import { generateJs, generateJson, generateWxml, generateWxss } from "@weapp-core/schematics";
|
|
20
20
|
import { determineAgent } from "@vercel/detect-agent";
|
|
21
21
|
import { initConfig } from "@weapp-core/init";
|
|
@@ -1076,13 +1076,45 @@ async function tryReuseOpenedWechatIde(projectPath) {
|
|
|
1076
1076
|
reused: false
|
|
1077
1077
|
};
|
|
1078
1078
|
}
|
|
1079
|
+
async function reopenOpenedWechatIde(projectPath) {
|
|
1080
|
+
let miniProgram;
|
|
1081
|
+
try {
|
|
1082
|
+
miniProgram = await connectOpenedAutomator({
|
|
1083
|
+
projectPath,
|
|
1084
|
+
timeout: 3e3
|
|
1085
|
+
});
|
|
1086
|
+
} catch {
|
|
1087
|
+
return false;
|
|
1088
|
+
}
|
|
1089
|
+
miniProgram.disconnect();
|
|
1090
|
+
logger_default.info("目标项目已在微信开发者工具中打开,当前命令将主动重开以刷新最新构建产物。");
|
|
1091
|
+
if (!await closeIde()) logger_default.warn("关闭当前微信开发者工具失败,仍继续尝试重新打开目标项目。");
|
|
1092
|
+
await openWechatIdeByAutomator(projectPath);
|
|
1093
|
+
return true;
|
|
1094
|
+
}
|
|
1079
1095
|
async function openIde(platform, projectPath, options = {}) {
|
|
1096
|
+
if (platform === "weapp" && projectPath) try {
|
|
1097
|
+
await bootstrapWechatDevtoolsSettings({
|
|
1098
|
+
projectPath,
|
|
1099
|
+
trustProject: options.trustProject
|
|
1100
|
+
});
|
|
1101
|
+
} catch (error) {
|
|
1102
|
+
logger_default.warn("预写入微信开发者工具安全设置或项目信任状态失败,继续执行 open 流程。");
|
|
1103
|
+
logger_default.error(error);
|
|
1104
|
+
}
|
|
1080
1105
|
if (platform === "weapp" && projectPath && options.trustProject !== false) try {
|
|
1106
|
+
if (options.reuseOpenedProject === false) {
|
|
1107
|
+
if (await reopenOpenedWechatIde(projectPath)) return;
|
|
1108
|
+
}
|
|
1081
1109
|
const reuseResult = await tryReuseOpenedWechatIde(projectPath);
|
|
1082
1110
|
if (reuseResult?.reused || reuseResult?.reopened) return;
|
|
1083
1111
|
await openWechatIdeByAutomator(projectPath);
|
|
1084
1112
|
return;
|
|
1085
1113
|
} catch (error) {
|
|
1114
|
+
if (isAutomatorLoginError(error)) {
|
|
1115
|
+
logger_default.error("检测到微信开发者工具登录状态失效,请先登录后重试。");
|
|
1116
|
+
logger_default.warn(formatAutomatorLoginError(error));
|
|
1117
|
+
}
|
|
1086
1118
|
logger_default.warn("通过 automator 启动微信开发者工具并自动信任项目失败,回退到普通 open 流程。");
|
|
1087
1119
|
logger_default.error(error);
|
|
1088
1120
|
}
|
|
@@ -1367,8 +1399,7 @@ async function loadConfig(configFile) {
|
|
|
1367
1399
|
}
|
|
1368
1400
|
}
|
|
1369
1401
|
if (!loaded && !weappLoaded) return;
|
|
1370
|
-
const config = loaded?.config ??
|
|
1371
|
-
if (weappLoaded?.config?.weapp) config.weapp = defu(weappLoaded.config.weapp, config.weapp ?? {});
|
|
1402
|
+
const config = weappLoaded?.config ? defu(weappLoaded.config, loaded?.config ?? {}) : loaded?.config ?? {};
|
|
1372
1403
|
const dependencySet = /* @__PURE__ */ new Set();
|
|
1373
1404
|
for (const dependency of loaded?.dependencies ?? []) dependencySet.add(dependency);
|
|
1374
1405
|
for (const dependency of weappLoaded?.dependencies ?? []) dependencySet.add(dependency);
|
|
@@ -1573,7 +1604,7 @@ async function waitForTermination(cleanup) {
|
|
|
1573
1604
|
* @description 执行 ide 子命令。
|
|
1574
1605
|
*/
|
|
1575
1606
|
async function runIdeCommand(action, root, options) {
|
|
1576
|
-
if (action !== "logs") throw new Error(`未知 ide 子命令: ${action ?? "(empty)"}`);
|
|
1607
|
+
if (action !== "logs" && action !== "setup") throw new Error(`未知 ide 子命令: ${action ?? "(empty)"}`);
|
|
1577
1608
|
filterDuplicateOptions(options);
|
|
1578
1609
|
const configFile = resolveConfigFile(options);
|
|
1579
1610
|
const targets = resolveRuntimeTargets(options);
|
|
@@ -1586,6 +1617,14 @@ async function runIdeCommand(action, root, options) {
|
|
|
1586
1617
|
});
|
|
1587
1618
|
if (resolved.platform !== "weapp") throw new Error("`weapp-vite ide logs` 当前仅支持微信小程序平台。");
|
|
1588
1619
|
if (!resolved.projectPath) throw new Error("无法解析微信开发者工具项目目录,请显式传入 root 或检查 project.config.json。");
|
|
1620
|
+
if (action === "setup") {
|
|
1621
|
+
const result = await bootstrapWechatDevtoolsSettings({
|
|
1622
|
+
projectPath: resolved.projectPath,
|
|
1623
|
+
trustProject: options.trustProject
|
|
1624
|
+
});
|
|
1625
|
+
logger_default.info(`已完成微信开发者工具配置预热:扫描实例 ${result.touchedInstanceCount} 个,更新安全设置 ${result.updatedSecurityCount} 处,写入项目信任 ${result.trustedProjectCount} 处。`);
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1589
1628
|
if (options.open) await openIde(resolved.platform, resolved.projectPath, { trustProject: options.trustProject });
|
|
1590
1629
|
const forwardConsoleOptions = await resolveForwardConsoleOptions({
|
|
1591
1630
|
...resolved.weappViteConfig,
|
|
@@ -2077,7 +2116,7 @@ function registerPrepareCommand(cli) {
|
|
|
2077
2116
|
}
|
|
2078
2117
|
//#endregion
|
|
2079
2118
|
//#region package.json
|
|
2080
|
-
var version = "6.15.
|
|
2119
|
+
var version = "6.15.6";
|
|
2081
2120
|
//#endregion
|
|
2082
2121
|
//#region src/cli/devHotkeys/format.ts
|
|
2083
2122
|
const FULLWIDTH_ASCII_START = 65281;
|
|
@@ -2781,7 +2820,10 @@ function registerServeCommand(cli) {
|
|
|
2781
2820
|
mpDistRoot: configService.mpDistRoot,
|
|
2782
2821
|
cwd: configService.cwd,
|
|
2783
2822
|
weappViteConfig: configService.weappViteConfig
|
|
2784
|
-
})) await openIde(configService.platform, resolveIdeProjectRoot(configService.mpDistRoot, configService.cwd), {
|
|
2823
|
+
})) await openIde(configService.platform, resolveIdeProjectRoot(configService.mpDistRoot, configService.cwd), {
|
|
2824
|
+
reuseOpenedProject: false,
|
|
2825
|
+
trustProject: options.trustProject
|
|
2826
|
+
});
|
|
2785
2827
|
devHotkeysSession?.restore();
|
|
2786
2828
|
}
|
|
2787
2829
|
if (analyzeHandle) await analyzeController.waitForExit();
|
|
@@ -496,6 +496,7 @@ interface WeappVueTemplateConfig {
|
|
|
496
496
|
removeComments?: boolean;
|
|
497
497
|
simplifyWhitespace?: boolean;
|
|
498
498
|
htmlTagToWxml?: boolean | Record<string, string>;
|
|
499
|
+
htmlTagToWxmlTagClass?: boolean;
|
|
499
500
|
scopedSlotsCompiler?: 'auto' | 'augmented' | 'off';
|
|
500
501
|
scopedSlotsRequireProps?: boolean;
|
|
501
502
|
slotMultipleInstance?: boolean;
|
|
@@ -1092,6 +1093,12 @@ interface LoadConfigResult {
|
|
|
1092
1093
|
configFilePath?: string;
|
|
1093
1094
|
currentSubPackageRoot?: string;
|
|
1094
1095
|
weappWeb?: ResolvedWeappWebConfig;
|
|
1096
|
+
configMergeInfo?: ResolvedConfigMergeInfo;
|
|
1097
|
+
}
|
|
1098
|
+
interface ResolvedConfigMergeInfo {
|
|
1099
|
+
merged: boolean;
|
|
1100
|
+
viteConfigPath?: string;
|
|
1101
|
+
weappConfigPath?: string;
|
|
1095
1102
|
}
|
|
1096
1103
|
interface ResolvedWeappLibConfig {
|
|
1097
1104
|
enabled: boolean;
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Bn as resolveWeappViteHostMeta, Fn as WeappViteHostMeta, In as WeappViteRuntime, Ln as applyWeappViteHostMeta, Pn as WEAPP_VITE_HOST_NAME, Rn as createWeappViteHostMeta, _ as definePageJson, a as UserConfigFnNoEnvPlain, 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, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson, zn as isWeappViteHost } from "./config-
|
|
1
|
+
import { Bn as resolveWeappViteHostMeta, Fn as WeappViteHostMeta, In as WeappViteRuntime, Ln as applyWeappViteHostMeta, Pn as WEAPP_VITE_HOST_NAME, Rn as createWeappViteHostMeta, _ as definePageJson, a as UserConfigFnNoEnvPlain, 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, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson, zn as isWeappViteHost } from "./config-BbL8Gqez.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 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as applyWeappViteHostMeta } from "./pluginHost-BzPJL4F-.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-CCWF5mwT.mjs";
|
|
4
4
|
import { createRequire, isBuiltin } from "node:module";
|
|
5
5
|
import path, { posix } from "pathe";
|
|
6
6
|
import { normalize, relative, win32 } from "node:path";
|
|
@@ -4944,6 +4944,10 @@ const DEFAULT_VITE_CONFIG_FILES = [
|
|
|
4944
4944
|
"vite.config.mjs",
|
|
4945
4945
|
"vite.config.cjs"
|
|
4946
4946
|
];
|
|
4947
|
+
const DEFAULT_VITE_CONFIG_FILE_SET = new Set(DEFAULT_VITE_CONFIG_FILES);
|
|
4948
|
+
function isDefaultViteConfigBasename(filePath) {
|
|
4949
|
+
return DEFAULT_VITE_CONFIG_FILE_SET.has(path.basename(filePath));
|
|
4950
|
+
}
|
|
4947
4951
|
async function resolveImplicitConfigFile(configRoot) {
|
|
4948
4952
|
for (const fileName of DEFAULT_VITE_CONFIG_FILES) {
|
|
4949
4953
|
const filePath = path.resolve(configRoot, fileName);
|
|
@@ -5258,6 +5262,9 @@ function resolveSpecifiedWeappConfigPath(root, specified) {
|
|
|
5258
5262
|
function isWeappConfigBasename(filePath) {
|
|
5259
5263
|
return WEAPP_VITE_CONFIG_SET.has(path.basename(filePath));
|
|
5260
5264
|
}
|
|
5265
|
+
function isExplicitCustomConfigFile(filePath) {
|
|
5266
|
+
return path.basename(filePath).includes(".config.") && !isDefaultViteConfigBasename(filePath) && !isWeappConfigBasename(filePath);
|
|
5267
|
+
}
|
|
5261
5268
|
async function findWeappConfigInDirectory(directory) {
|
|
5262
5269
|
for (const filename of WEAPP_VITE_CONFIG_CANDIDATES) {
|
|
5263
5270
|
const candidatePath = path.resolve(directory, filename);
|
|
@@ -5272,6 +5279,7 @@ async function resolveWeappConfigFile(options) {
|
|
|
5272
5279
|
if (await fs.pathExists(resolvedSpecified)) return resolvedSpecified;
|
|
5273
5280
|
return;
|
|
5274
5281
|
}
|
|
5282
|
+
if (isExplicitCustomConfigFile(resolvedSpecified)) return;
|
|
5275
5283
|
const fromSpecifiedDirectory = await findWeappConfigInDirectory(path.dirname(resolvedSpecified));
|
|
5276
5284
|
if (fromSpecifiedDirectory) return fromSpecifiedDirectory;
|
|
5277
5285
|
}
|
|
@@ -9687,6 +9695,7 @@ function createAdvancedChunkNameResolver(options) {
|
|
|
9687
9695
|
const REG_NODE_MODULES_DIR = /[\\/]node_modules[\\/]/gi;
|
|
9688
9696
|
const REG_COMMONJS_HELPERS = /commonjsHelpers\.js$/;
|
|
9689
9697
|
const REG_REQUEST_GLOBAL_RUNTIME_VENDOR_ID = /(?:^|[/\\])(?:@wevu[/\\]web-apis|web-apis[/\\]dist[/\\]index\.(?:m?js|cjs)|weapp-vite[/\\](?:dist[/\\]web-apis\.mjs|src[/\\](?:webApis\.ts|runtime[/\\]webApis[/\\]index\.ts)))(?:$|[?#])/;
|
|
9698
|
+
const REG_HASHED_DIST_CHUNK_ID = /(?:^|[/\\])dist[/\\]([^/\\]+)-(\w{6,})\.(?:m?js|cjs)(?:$|[?#])/;
|
|
9690
9699
|
function resolveSharedPathRoot(configService, sharedPathRoot) {
|
|
9691
9700
|
const absoluteSrcRoot = configService.absoluteSrcRoot;
|
|
9692
9701
|
const configuredRoot = sharedPathRoot ? path.resolve(configService.cwd, sharedPathRoot) : absoluteSrcRoot;
|
|
@@ -9773,6 +9782,35 @@ function isRequestGlobalsRuntimeChunk(chunk) {
|
|
|
9773
9782
|
return REG_REQUEST_GLOBAL_RUNTIME_VENDOR_ID.test(id);
|
|
9774
9783
|
});
|
|
9775
9784
|
}
|
|
9785
|
+
function sanitizePackageToken(value) {
|
|
9786
|
+
return value.replace(/^@/, "").replaceAll(/[\\/]/g, "-").replaceAll(/[^\w-]/g, "-").replaceAll(/-+/g, "-").replace(/^-|-$/g, "");
|
|
9787
|
+
}
|
|
9788
|
+
function resolveDistChunkPackageToken(cleanedAbsoluteId) {
|
|
9789
|
+
const npmRelativePath = resolveNodeModulesSharedPath(cleanedAbsoluteId);
|
|
9790
|
+
if (npmRelativePath) {
|
|
9791
|
+
const [packagePath] = npmRelativePath.split("/dist/");
|
|
9792
|
+
if (packagePath) return sanitizePackageToken(packagePath);
|
|
9793
|
+
}
|
|
9794
|
+
const segments = cleanedAbsoluteId.replaceAll("\\", "/").split("/");
|
|
9795
|
+
const distIndex = segments.lastIndexOf("dist");
|
|
9796
|
+
if (distIndex <= 0) return;
|
|
9797
|
+
const packageToken = segments[distIndex - 1];
|
|
9798
|
+
if (!packageToken) return;
|
|
9799
|
+
return sanitizePackageToken(packageToken);
|
|
9800
|
+
}
|
|
9801
|
+
function resolveStableHashedDistChunkFileName(chunk) {
|
|
9802
|
+
const candidateIds = [chunk.facadeModuleId, ...chunk.moduleIds ?? []].filter((id) => typeof id === "string");
|
|
9803
|
+
for (const id of candidateIds) {
|
|
9804
|
+
const cleanedAbsoluteId = normalizeSharedPathCandidate(id);
|
|
9805
|
+
if (!path.isAbsolute(cleanedAbsoluteId)) continue;
|
|
9806
|
+
const matched = cleanedAbsoluteId.match(REG_HASHED_DIST_CHUNK_ID);
|
|
9807
|
+
if (!matched) continue;
|
|
9808
|
+
const baseName = matched[1];
|
|
9809
|
+
const packageToken = resolveDistChunkPackageToken(cleanedAbsoluteId);
|
|
9810
|
+
if (!baseName || !packageToken) continue;
|
|
9811
|
+
return `weapp-vendors/${packageToken}-${baseName}.js`;
|
|
9812
|
+
}
|
|
9813
|
+
}
|
|
9776
9814
|
function createSharedBuildResolver(configService, getSubPackageRoots) {
|
|
9777
9815
|
const nodeModulesDeps = [REG_NODE_MODULES_DIR];
|
|
9778
9816
|
const commonjsHelpersDeps = [REG_COMMONJS_HELPERS];
|
|
@@ -9797,6 +9835,8 @@ function createSharedBuildOutput(configService, getSubPackageRoots) {
|
|
|
9797
9835
|
codeSplitting: { groups: [{ name: (id, ctx) => resolveAdvancedChunkName(id, ctx) }] },
|
|
9798
9836
|
chunkFileNames: (chunk) => {
|
|
9799
9837
|
if (isRequestGlobalsRuntimeChunk(chunk)) return REQUEST_GLOBAL_RUNTIME_CHUNK_FILE_BASENAME;
|
|
9838
|
+
const stableHashedDistChunkFileName = resolveStableHashedDistChunkFileName(chunk);
|
|
9839
|
+
if (stableHashedDistChunkFileName) return stableHashedDistChunkFileName;
|
|
9800
9840
|
return "[name].js";
|
|
9801
9841
|
}
|
|
9802
9842
|
};
|
|
@@ -10081,9 +10121,9 @@ function checkWorkersOptions(target, configService, scanService) {
|
|
|
10081
10121
|
const workersDir = scanService.workersDir;
|
|
10082
10122
|
const hasWorkersDir = Boolean(workersDir);
|
|
10083
10123
|
if (hasWorkersDir && configService.weappViteConfig?.worker?.entry === void 0) {
|
|
10084
|
-
logger_default.error("检测到已经开启了 `worker`,请在 `vite.config.ts` 中设置 `weapp.worker.entry` 路径");
|
|
10124
|
+
logger_default.error("检测到已经开启了 `worker`,请在 `vite.config.ts` / `weapp-vite.config.ts` 中设置 `weapp.worker.entry` 路径");
|
|
10085
10125
|
logger_default.error("比如引入的 `worker` 路径为 `workers/index`, 此时 `weapp.worker.entry` 设置为 `[index]` ");
|
|
10086
|
-
throw new Error("请在 `vite.config.ts` 中设置 `weapp.worker.entry` 路径");
|
|
10126
|
+
throw new Error("请在 `vite.config.ts` / `weapp-vite.config.ts` 中设置 `weapp.worker.entry` 路径");
|
|
10087
10127
|
}
|
|
10088
10128
|
return {
|
|
10089
10129
|
hasWorkersDir,
|
|
@@ -11111,10 +11151,11 @@ function createLoadConfig(options) {
|
|
|
11111
11151
|
if (cjsError) throw cjsError;
|
|
11112
11152
|
throw error;
|
|
11113
11153
|
}
|
|
11154
|
+
const mergedLoadedConfig = weappLoaded?.config ? defu(weappLoaded.config, loadedConfig) : loadedConfig;
|
|
11114
11155
|
const config = defu(inlineConfig, {
|
|
11115
11156
|
mode,
|
|
11116
11157
|
configFile: false
|
|
11117
|
-
},
|
|
11158
|
+
}, mergedLoadedConfig, {
|
|
11118
11159
|
build: {
|
|
11119
11160
|
rolldownOptions: { output: {
|
|
11120
11161
|
entryFileNames: (chunkInfo) => {
|
|
@@ -11127,7 +11168,6 @@ function createLoadConfig(options) {
|
|
|
11127
11168
|
logLevel: "warn",
|
|
11128
11169
|
weapp: getWeappViteConfig()
|
|
11129
11170
|
});
|
|
11130
|
-
if (weappLoaded?.config?.weapp) config.weapp = defu(weappLoaded.config.weapp, config.weapp ?? {});
|
|
11131
11171
|
const chunksConfigured = Boolean(inlineConfig?.weapp?.chunks || loadedConfig.weapp?.chunks || weappLoaded?.config?.weapp?.chunks);
|
|
11132
11172
|
const shouldWarnEnhance = [
|
|
11133
11173
|
inlineConfig?.weapp?.enhance,
|
|
@@ -11234,6 +11274,15 @@ function createLoadConfig(options) {
|
|
|
11234
11274
|
config.resolve.tsconfigPaths ??= true;
|
|
11235
11275
|
}
|
|
11236
11276
|
const configFilePath = weappLoaded?.path ?? loaded?.path ?? resolvedConfigFile;
|
|
11277
|
+
const configMergeInfo = loaded?.path && weappLoaded?.path && !shouldReuseLoadedWeappConfig(weappLoaded.path, loaded.path) ? {
|
|
11278
|
+
merged: true,
|
|
11279
|
+
viteConfigPath: loaded.path,
|
|
11280
|
+
weappConfigPath: weappLoaded.path
|
|
11281
|
+
} : {
|
|
11282
|
+
merged: false,
|
|
11283
|
+
viteConfigPath: loaded?.path,
|
|
11284
|
+
weappConfigPath: shouldReuseLoadedWeappConfig(weappLoaded?.path, loaded?.path) ? void 0 : weappLoaded?.path
|
|
11285
|
+
};
|
|
11237
11286
|
const outputExtensions = getOutputExtensions(platform);
|
|
11238
11287
|
const relativeSrcRoot = (p) => {
|
|
11239
11288
|
if (srcRoot) return path.relative(srcRoot, p);
|
|
@@ -11261,7 +11310,8 @@ function createLoadConfig(options) {
|
|
|
11261
11310
|
configFilePath,
|
|
11262
11311
|
currentSubPackageRoot: void 0,
|
|
11263
11312
|
weappWeb: resolvedWebConfig,
|
|
11264
|
-
weappLib: resolvedLibConfig
|
|
11313
|
+
weappLib: resolvedLibConfig,
|
|
11314
|
+
configMergeInfo
|
|
11265
11315
|
};
|
|
11266
11316
|
};
|
|
11267
11317
|
}
|
|
@@ -32393,6 +32443,7 @@ function createCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, con
|
|
|
32393
32443
|
const scopedSlotsRequireProps = configService.weappViteConfig?.vue?.template?.scopedSlotsRequireProps ?? scopedSlotsCompiler !== "augmented";
|
|
32394
32444
|
const slotMultipleInstance = configService.weappViteConfig?.vue?.template?.slotMultipleInstance ?? true;
|
|
32395
32445
|
const htmlTagToWxml = configService.weappViteConfig?.vue?.template?.htmlTagToWxml;
|
|
32446
|
+
const htmlTagToWxmlTagClass = configService.weappViteConfig?.vue?.template?.htmlTagToWxmlTagClass ?? true;
|
|
32396
32447
|
const classStyleRuntimeConfig = configService.weappViteConfig?.vue?.template?.classStyleRuntime ?? "js";
|
|
32397
32448
|
const objectLiteralBindMode = configService.weappViteConfig?.vue?.template?.objectLiteralBindMode ?? "runtime";
|
|
32398
32449
|
const mustacheInterpolation = configService.weappViteConfig?.vue?.template?.mustacheInterpolation ?? "compact";
|
|
@@ -32431,6 +32482,7 @@ function createCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, con
|
|
|
32431
32482
|
template: {
|
|
32432
32483
|
platform: templatePlatformOptions.templatePlatform,
|
|
32433
32484
|
htmlTagToWxml,
|
|
32485
|
+
htmlTagToWxmlTagClass,
|
|
32434
32486
|
scopedSlotsCompiler,
|
|
32435
32487
|
scopedSlotsRequireProps,
|
|
32436
32488
|
slotMultipleInstance,
|
|
@@ -34120,6 +34172,7 @@ function mergeMiniprogram(options, ...configs) {
|
|
|
34120
34172
|
define: miniprogramDefines,
|
|
34121
34173
|
build: {
|
|
34122
34174
|
modulePreload: false,
|
|
34175
|
+
minify: false,
|
|
34123
34176
|
emptyOutDir: false,
|
|
34124
34177
|
rolldownOptions: { ...rolldownOptions }
|
|
34125
34178
|
}
|
|
@@ -34397,6 +34450,11 @@ function createConfigService(ctx) {
|
|
|
34397
34450
|
oxcRolldownPlugin: oxcRuntimeSupport.rolldownPlugin,
|
|
34398
34451
|
oxcVitePlugin: oxcRuntimeSupport.vitePlugin
|
|
34399
34452
|
});
|
|
34453
|
+
function formatConfigDisplayPath(filePath) {
|
|
34454
|
+
if (!filePath) return;
|
|
34455
|
+
const relative = normalizeRelativePath(path.relative(options.cwd, filePath));
|
|
34456
|
+
return relative && relative !== "" ? relative : path.basename(filePath);
|
|
34457
|
+
}
|
|
34400
34458
|
async function load(optionsInput) {
|
|
34401
34459
|
const defaultCwd = process$1.cwd();
|
|
34402
34460
|
const input = defu(optionsInput, {
|
|
@@ -34419,6 +34477,11 @@ function createConfigService(ctx) {
|
|
|
34419
34477
|
});
|
|
34420
34478
|
setOptions(resolvedConfig);
|
|
34421
34479
|
configureLogger(resolvedConfig.config.weapp?.logger);
|
|
34480
|
+
if (resolvedConfig.configMergeInfo?.merged) {
|
|
34481
|
+
const weappConfigDisplay = formatConfigDisplayPath(resolvedConfig.configMergeInfo.weappConfigPath) ?? "weapp-vite.config.ts";
|
|
34482
|
+
const viteConfigDisplay = formatConfigDisplayPath(resolvedConfig.configMergeInfo.viteConfigPath) ?? "vite.config.ts";
|
|
34483
|
+
logger_default.info(`[config] 检测到同时存在 ${weappConfigDisplay} 与 ${viteConfigDisplay},已合并两份 Vite 配置,优先级:${weappConfigDisplay} > ${viteConfigDisplay}`);
|
|
34484
|
+
}
|
|
34422
34485
|
packageManager = await detect() ?? {
|
|
34423
34486
|
agent: "npm",
|
|
34424
34487
|
name: "npm"
|
|
@@ -34781,7 +34844,8 @@ function createDefaultLoadConfigResult() {
|
|
|
34781
34844
|
platform: "weapp",
|
|
34782
34845
|
srcRoot: "",
|
|
34783
34846
|
configFilePath: void 0,
|
|
34784
|
-
weappWeb: void 0
|
|
34847
|
+
weappWeb: void 0,
|
|
34848
|
+
configMergeInfo: void 0
|
|
34785
34849
|
};
|
|
34786
34850
|
}
|
|
34787
34851
|
function createDefaultPackageInfo() {
|
|
@@ -34996,7 +35060,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
34996
35060
|
const vueAppPath = await findVueEntry(appBasename);
|
|
34997
35061
|
let configFromVue;
|
|
34998
35062
|
if (!appConfigFile && vueAppPath) {
|
|
34999
|
-
const { extractConfigFromVue } = await import("./file-
|
|
35063
|
+
const { extractConfigFromVue } = await import("./file-DY9paehF.mjs");
|
|
35000
35064
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
35001
35065
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
35002
35066
|
}
|
|
@@ -35047,7 +35111,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
35047
35111
|
}
|
|
35048
35112
|
throw new Error("`app.json` 解析失败,请确保 `app.json` 文件格式正确");
|
|
35049
35113
|
}
|
|
35050
|
-
throw new Error(`在 ${appDirname} 目录下没有找到 \`app.json\` 或 \`app.vue\`,请确保你初始化了小程序项目,或者在 \`vite.config.ts\`
|
|
35114
|
+
throw new Error(`在 ${appDirname} 目录下没有找到 \`app.json\` 或 \`app.vue\`,请确保你初始化了小程序项目,或者在 \`vite.config.ts\` / \`weapp-vite.config.ts\` 中设置正确的 \`weapp.srcRoot\` 配置路径`);
|
|
35051
35115
|
}
|
|
35052
35116
|
//#endregion
|
|
35053
35117
|
//#region src/runtime/scanPlugin/styleEntries/config.ts
|
|
@@ -35364,7 +35428,7 @@ function loadSubPackages(ctx) {
|
|
|
35364
35428
|
scanState.isDirty = false;
|
|
35365
35429
|
} else for (const meta of subPackageMap.values()) meta.entries = resolveSubPackageEntries(meta.subPackage);
|
|
35366
35430
|
if (scanState.appEntry) return [...subPackageMap.values()];
|
|
35367
|
-
throw new Error(`在 ${configService.absoluteSrcRoot} 目录下没有找到 \`app.json\`, 请确保你初始化了小程序项目,或者在 \`vite.config.ts\`
|
|
35431
|
+
throw new Error(`在 ${configService.absoluteSrcRoot} 目录下没有找到 \`app.json\`, 请确保你初始化了小程序项目,或者在 \`vite.config.ts\` / \`weapp-vite.config.ts\` 中设置正确的 \`weapp.srcRoot\` 配置路径`);
|
|
35368
35432
|
}
|
|
35369
35433
|
//#endregion
|
|
35370
35434
|
//#region src/runtime/scanPlugin/service/index.ts
|
|
@@ -35901,6 +35965,10 @@ const DEFAULT_NODE_INCLUDE = [
|
|
|
35901
35965
|
"../vite.config.*.ts",
|
|
35902
35966
|
"../vite.config.mts",
|
|
35903
35967
|
"../vite.config.*.mts",
|
|
35968
|
+
"../weapp-vite.config.ts",
|
|
35969
|
+
"../weapp-vite.config.*.ts",
|
|
35970
|
+
"../weapp-vite.config.mts",
|
|
35971
|
+
"../weapp-vite.config.*.mts",
|
|
35904
35972
|
"../*.config.ts",
|
|
35905
35973
|
"../*.config.mts",
|
|
35906
35974
|
"../config/**/*.ts",
|
package/dist/docs/README.md
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
### Vue 项目
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
|
-
// vite.config.ts
|
|
39
|
+
// vite.config.ts 或 weapp-vite.config.ts
|
|
40
40
|
import { defineConfig } from 'weapp-vite/config'
|
|
41
41
|
|
|
42
42
|
export default defineConfig({
|
|
@@ -46,12 +46,21 @@ export default defineConfig({
|
|
|
46
46
|
enable: true,
|
|
47
47
|
template: {
|
|
48
48
|
removeComments: true,
|
|
49
|
+
htmlTagToWxml: true,
|
|
50
|
+
htmlTagToWxmlTagClass: true,
|
|
49
51
|
},
|
|
50
52
|
},
|
|
51
53
|
},
|
|
52
54
|
})
|
|
53
55
|
```
|
|
54
56
|
|
|
57
|
+
如果你在把传统 HTML/Vue 模板迁移到小程序 `.vue`,这两个模板配置通常最有用:
|
|
58
|
+
|
|
59
|
+
- `weapp.vue.template.htmlTagToWxml`
|
|
60
|
+
把 `div/span/img/a/h1...` 等常见 HTML 标签映射成小程序内置标签。
|
|
61
|
+
- `weapp.vue.template.htmlTagToWxmlTagClass`
|
|
62
|
+
默认开启。在映射发生时追加原标签名 class,例如 `h3 -> <view class="h3">`、`br -> <view class="br" />`,便于你自己写 CSS 低成本恢复默认外观;不需要时可设为 `false`。
|
|
63
|
+
|
|
55
64
|
```vue
|
|
56
65
|
<!-- App.vue -->
|
|
57
66
|
<script setup>
|
|
@@ -178,6 +187,38 @@ wv ide logs
|
|
|
178
187
|
wv ide logs --open
|
|
179
188
|
```
|
|
180
189
|
|
|
190
|
+
## DevTools 配置预热
|
|
191
|
+
|
|
192
|
+
`weapp-vite` 在打开微信开发者工具前,会复用 `weapp-ide-cli` 的底层能力,自动尝试预热本机 DevTools 配置:
|
|
193
|
+
|
|
194
|
+
- 确保安全设置中的服务端口处于开启状态
|
|
195
|
+
- 按命令参数或全局配置决定是否自动信任当前项目
|
|
196
|
+
|
|
197
|
+
如果你只想预热配置、不立即打开 IDE,可以使用:
|
|
198
|
+
|
|
199
|
+
```sh
|
|
200
|
+
weapp-vite ide setup .
|
|
201
|
+
# 等价写法
|
|
202
|
+
wv ide setup .
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
如果你希望以后 `open` / `dev --open` / `build --open` 都默认自动信任项目,直接配置 `weapp-ide-cli` 即可:
|
|
206
|
+
|
|
207
|
+
```sh
|
|
208
|
+
weapp config set autoBootstrapDevtools true
|
|
209
|
+
weapp config set autoTrustProject true
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
这样以后执行:
|
|
213
|
+
|
|
214
|
+
```sh
|
|
215
|
+
weapp-vite open .
|
|
216
|
+
weapp-vite dev --open
|
|
217
|
+
weapp-vite build --open
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
都会沿用同一套默认策略。
|
|
221
|
+
|
|
181
222
|
## CLI 中调用 weapp-ide-cli
|
|
182
223
|
|
|
183
224
|
`weapp-vite` 内置了对 `weapp-ide-cli` 的透传能力,除了 `dev/build/open/init/generate/analyze/npm` 等原生命令外,其它 IDE 相关命令都可以直接调用:
|
|
@@ -188,6 +229,7 @@ weapp-vite upload --project ./dist/build/mp-weixin -v 1.0.0 -d "release"
|
|
|
188
229
|
weapp-vite cache --clean compile
|
|
189
230
|
weapp-vite cache --clean all
|
|
190
231
|
weapp-vite config lang zh
|
|
232
|
+
weapp-vite config set autoTrustProject true
|
|
191
233
|
weapp-vite navigate pages/index/index --project ./dist/build/mp-weixin
|
|
192
234
|
# 等价写法
|
|
193
235
|
wv preview --project ./dist/build/mp-weixin
|
|
@@ -199,6 +241,7 @@ wv cache --clean all
|
|
|
199
241
|
```sh
|
|
200
242
|
weapp-vite ide preview --project ./dist/build/mp-weixin
|
|
201
243
|
weapp-vite ide config show
|
|
244
|
+
weapp-vite ide setup .
|
|
202
245
|
weapp-vite ide logs --open
|
|
203
246
|
# 等价写法
|
|
204
247
|
wv ide preview --project ./dist/build/mp-weixin
|
|
@@ -239,7 +282,7 @@ weapp-vite mcp --workspace-root /absolute/path/to/weapp-vite
|
|
|
239
282
|
wv mcp --workspace-root /absolute/path/to/weapp-vite
|
|
240
283
|
```
|
|
241
284
|
|
|
242
|
-
在 `vite.config.ts` 中开启自动启动:
|
|
285
|
+
在 `vite.config.ts` 或 `weapp-vite.config.ts` 中开启自动启动:
|
|
243
286
|
|
|
244
287
|
```ts
|
|
245
288
|
import { defineConfig } from 'weapp-vite/config'
|
package/dist/docs/vue-sfc.md
CHANGED
|
@@ -38,6 +38,33 @@
|
|
|
38
38
|
|
|
39
39
|
当你在页面或组件里需要显式注册原生小程序组件时,优先明确当前文件使用的 JSON 宏与配置来源,避免多个入口互相覆盖。
|
|
40
40
|
|
|
41
|
+
## HTML 标签迁移辅助
|
|
42
|
+
|
|
43
|
+
如果你把偏 Web 风格的模板迁到 `.vue`,可以优先关注这两个配置:
|
|
44
|
+
|
|
45
|
+
- `weapp.vue.template.htmlTagToWxml`
|
|
46
|
+
把常见 HTML 标签映射为小程序内置标签。
|
|
47
|
+
- `weapp.vue.template.htmlTagToWxmlTagClass`
|
|
48
|
+
默认开启。映射发生时,会再补一个原标签名 class,方便你自己用 CSS 恢复默认外观。
|
|
49
|
+
|
|
50
|
+
例如:
|
|
51
|
+
|
|
52
|
+
```vue
|
|
53
|
+
<template>
|
|
54
|
+
<h3 class="title">
|
|
55
|
+
标题
|
|
56
|
+
</h3>
|
|
57
|
+
<br>
|
|
58
|
+
</template>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
启用默认行为后,会得到类似:
|
|
62
|
+
|
|
63
|
+
```wxml
|
|
64
|
+
<view class="h3 title">标题</view>
|
|
65
|
+
<view class="br" />
|
|
66
|
+
```
|
|
67
|
+
|
|
41
68
|
## 何时继续看其他文档
|
|
42
69
|
|
|
43
70
|
- 需要更完整的编辑器提示说明:[`../volar.md`](../volar.md)
|
|
@@ -32,6 +32,16 @@ export default defineConfig({
|
|
|
32
32
|
|
|
33
33
|
用于给页面路由追加规则,例如 layout、运行时行为等。它属于项目级编排,而不是组件内部语义。
|
|
34
34
|
|
|
35
|
+
### `vue.template.htmlTagToWxml`
|
|
36
|
+
|
|
37
|
+
适合从 Web/Vue 模板迁移到小程序 `.vue` 的项目。开启后,会把常见 HTML 标签映射成小程序内置标签,例如 `div -> view`、`span -> text`、`img -> image`、`a -> navigator`,也包含 `br/hr` 这类容易在迁移时“消失”的标签。
|
|
38
|
+
|
|
39
|
+
### `vue.template.htmlTagToWxmlTagClass`
|
|
40
|
+
|
|
41
|
+
默认开启。仅当 `htmlTagToWxml` 发生标签映射时,为输出节点追加原标签名 class,例如 `h3 -> <view class="h3">`、`br -> <view class="br" />`。
|
|
42
|
+
|
|
43
|
+
如果你的迁移策略是“先跑通,再用 CSS 逐步恢复默认外观”,这个开关很有价值;如果不希望产物里自动带这层语义 class,可以显式设为 `false`。
|
|
44
|
+
|
|
35
45
|
### `layout`
|
|
36
46
|
|
|
37
47
|
页面 layout 既可能来自项目级规则,也可能来自页面侧 `definePageMeta`。排查时先确认是哪一层生效。
|
|
@@ -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-DPNGGEFm.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 resolveWeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Fn as WeappViteHostMeta, I as RolldownPluginOption, In as WeappViteRuntime, L as RolldownWatchOptions, Ln as applyWeappViteHostMeta, M as RolldownBuild, N as RolldownOptions, O as Plugin, P as RolldownOutput, Pn as WEAPP_VITE_HOST_NAME, R as RolldownWatcher, Rn as createWeappViteHostMeta, S as CompilerContext, T as ConfigEnv, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, 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, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer, zn as isWeappViteHost } from "./config-
|
|
1
|
+
import { A as Ref, Bn as resolveWeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Fn as WeappViteHostMeta, I as RolldownPluginOption, In as WeappViteRuntime, L as RolldownWatchOptions, Ln as applyWeappViteHostMeta, M as RolldownBuild, N as RolldownOptions, O as Plugin, P as RolldownOutput, Pn as WEAPP_VITE_HOST_NAME, R as RolldownWatcher, Rn as createWeappViteHostMeta, S as CompilerContext, T as ConfigEnv, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, 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, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer, zn as isWeappViteHost } from "./config-BbL8Gqez.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
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createCompilerContext } from "./createContext-
|
|
1
|
+
import { t as createCompilerContext } from "./createContext-DPe-Wp3_.mjs";
|
|
2
2
|
import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-wnfVS9jE.mjs";
|
|
3
3
|
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-BzPJL4F-.mjs";
|
|
4
4
|
import { t as defineConfig } from "./config-B2xtjEug.mjs";
|
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-BbL8Gqez.mjs";
|
|
2
2
|
export { App, Component, Page, Sitemap, Theme, defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson };
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { xt as WeappMcpConfig } from "./config-
|
|
1
|
+
import { xt as WeappMcpConfig } from "./config-BbL8Gqez.mjs";
|
|
2
2
|
import { CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, McpServerHandle, StartMcpServerOptions, createWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
3
3
|
|
|
4
4
|
//#region src/mcp.d.ts
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { c as Resolver } from "./index-6QUk3Zbc.mjs";
|
|
2
2
|
import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-DiEBrMtj.mjs";
|
|
3
|
-
import { $ as WeappDebugConfig, $t as JsonConfig, A as Ref, An as WeappManagedServerTsconfigConfig, At as WeappWevuConfig, B as BindingErrorLike, Bt as GenerateExtensionsOptions, Cn as WeappLibDtsOptions, Ct as WeappRequestRuntimeConfig, D as MethodDefinitions, Dn as WeappLibVueTscOptions, Dt as WeappVueConfig, E as InlineConfig, En as WeappLibInternalDtsOptions, Et as WeappSubPackageConfig, F as RolldownPlugin, Fn as WeappViteHostMeta, Ft as BuildNpmPackageMeta, G as EntryJsonFragment, Gt as GenerateTemplateContext, H as BaseEntry, Ht as GenerateFilenamesOptions, I as RolldownPluginOption, In as WeappViteRuntime, It as ChunksConfig, J as ScanComponentItem, Jt as GenerateTemplateFileSource, K as PageEntry, Kt as GenerateTemplateEntry, L as RolldownWatchOptions, Lt as CopyGlobs, M as RolldownBuild, Mn as WeappManagedTypeScriptConfig, Mt as Alias, N as RolldownOptions, Nn as WeappWebConfig, Nt as AliasOptions, O as Plugin, On as WeappManagedAppTsconfigConfig, Ot as WeappVueTemplateConfig, P as RolldownOutput, Pt as AlipayNpmMode, Q as UserConfig, Qt as JsFormat, R as RolldownWatcher, Rt as CopyOptions, Sn as WeappLibConfig, St as WeappNpmConfig, T as ConfigEnv, Tn as WeappLibFileName, Tt as WeappRouteRules, U as ComponentEntry, Ut as GenerateOptions, V as AppEntry, Vt as GenerateFileType, W as Entry, Wt as GenerateTemplate, X as ProjectConfig, Xt as GenerateTemplateScope, Y as WxmlDep, Yt as GenerateTemplateInlineSource, Z as SubPackageMetaValue, Zt as GenerateTemplatesConfig, _n as SubPackageStyleConfigEntry, _t as WeappInjectRequestGlobalsTarget, an as NpmBuildOptions, at as EnhanceOptions, b as ChangeEvent, bn as SubPackageStyleScope, bt as WeappInjectWebRuntimeGlobalsTarget, cn as NpmPluginPackageConfig, ct as MultiPlatformConfig, dn as ResolvedAlias, dt as WeappAppPreludeMode, en as JsonMergeContext, et as WeappForwardConsoleConfig, fn as SharedChunkDynamicImports, ft as WeappAutoRoutesConfig, gn as SubPackage, gt as WeappInjectRequestGlobalsConfig, hn as SharedChunkStrategy, ht as WeappHmrConfig, in as MpPlatform, it as AutoImportComponentsOption, j as ResolvedConfig, jn as WeappManagedSharedTsconfigConfig, jt as WeappWorkerConfig, k as PluginOption, kn as WeappManagedNodeTsconfigConfig, kt as WeappWebRuntimeConfig, ln as NpmStrategy, lt as ScanWxmlOptions, mn as SharedChunkOverride, mt as WeappAutoRoutesIncludePattern, nn as JsonMergeStage, nt as WeappViteConfig, on as NpmDependencyPattern, ot as EnhanceWxmlOptions, pn as SharedChunkMode, pt as WeappAutoRoutesInclude, q as ComponentsMap, qt as GenerateTemplateFactory, rn as JsonMergeStrategy, rt as AutoImportComponents, sn as NpmMainPackageConfig, st as HandleWxmlOptions, tn as JsonMergeFunction, tt as WeappForwardConsoleLogLevel, un as NpmSubPackageConfig, ut as WeappAppPreludeConfig, vn as SubPackageStyleConfigObject, vt as WeappInjectWeapiConfig, w as ComputedDefinitions, wn as WeappLibEntryContext, wt as WeappRouteRule, x as WeappVitePluginApi, xn as WeappLibComponentJson, xt as WeappMcpConfig, yn as SubPackageStyleEntry, yt as WeappInjectWebRuntimeGlobalsConfig, z as ViteDevServer, zt as GenerateDirsOptions } from "./config-
|
|
3
|
+
import { $ as WeappDebugConfig, $t as JsonConfig, A as Ref, An as WeappManagedServerTsconfigConfig, At as WeappWevuConfig, B as BindingErrorLike, Bt as GenerateExtensionsOptions, Cn as WeappLibDtsOptions, Ct as WeappRequestRuntimeConfig, D as MethodDefinitions, Dn as WeappLibVueTscOptions, Dt as WeappVueConfig, E as InlineConfig, En as WeappLibInternalDtsOptions, Et as WeappSubPackageConfig, F as RolldownPlugin, Fn as WeappViteHostMeta, Ft as BuildNpmPackageMeta, G as EntryJsonFragment, Gt as GenerateTemplateContext, H as BaseEntry, Ht as GenerateFilenamesOptions, I as RolldownPluginOption, In as WeappViteRuntime, It as ChunksConfig, J as ScanComponentItem, Jt as GenerateTemplateFileSource, K as PageEntry, Kt as GenerateTemplateEntry, L as RolldownWatchOptions, Lt as CopyGlobs, M as RolldownBuild, Mn as WeappManagedTypeScriptConfig, Mt as Alias, N as RolldownOptions, Nn as WeappWebConfig, Nt as AliasOptions, O as Plugin, On as WeappManagedAppTsconfigConfig, Ot as WeappVueTemplateConfig, P as RolldownOutput, Pt as AlipayNpmMode, Q as UserConfig, Qt as JsFormat, R as RolldownWatcher, Rt as CopyOptions, Sn as WeappLibConfig, St as WeappNpmConfig, T as ConfigEnv, Tn as WeappLibFileName, Tt as WeappRouteRules, U as ComponentEntry, Ut as GenerateOptions, V as AppEntry, Vt as GenerateFileType, W as Entry, Wt as GenerateTemplate, X as ProjectConfig, Xt as GenerateTemplateScope, Y as WxmlDep, Yt as GenerateTemplateInlineSource, Z as SubPackageMetaValue, Zt as GenerateTemplatesConfig, _n as SubPackageStyleConfigEntry, _t as WeappInjectRequestGlobalsTarget, an as NpmBuildOptions, at as EnhanceOptions, b as ChangeEvent, bn as SubPackageStyleScope, bt as WeappInjectWebRuntimeGlobalsTarget, cn as NpmPluginPackageConfig, ct as MultiPlatformConfig, dn as ResolvedAlias, dt as WeappAppPreludeMode, en as JsonMergeContext, et as WeappForwardConsoleConfig, fn as SharedChunkDynamicImports, ft as WeappAutoRoutesConfig, gn as SubPackage, gt as WeappInjectRequestGlobalsConfig, hn as SharedChunkStrategy, ht as WeappHmrConfig, in as MpPlatform, it as AutoImportComponentsOption, j as ResolvedConfig, jn as WeappManagedSharedTsconfigConfig, jt as WeappWorkerConfig, k as PluginOption, kn as WeappManagedNodeTsconfigConfig, kt as WeappWebRuntimeConfig, ln as NpmStrategy, lt as ScanWxmlOptions, mn as SharedChunkOverride, mt as WeappAutoRoutesIncludePattern, nn as JsonMergeStage, nt as WeappViteConfig, on as NpmDependencyPattern, ot as EnhanceWxmlOptions, pn as SharedChunkMode, pt as WeappAutoRoutesInclude, q as ComponentsMap, qt as GenerateTemplateFactory, rn as JsonMergeStrategy, rt as AutoImportComponents, sn as NpmMainPackageConfig, st as HandleWxmlOptions, tn as JsonMergeFunction, tt as WeappForwardConsoleLogLevel, un as NpmSubPackageConfig, ut as WeappAppPreludeConfig, vn as SubPackageStyleConfigObject, vt as WeappInjectWeapiConfig, w as ComputedDefinitions, wn as WeappLibEntryContext, wt as WeappRouteRule, x as WeappVitePluginApi, xn as WeappLibComponentJson, xt as WeappMcpConfig, yn as SubPackageStyleEntry, yt as WeappInjectWebRuntimeGlobalsConfig, z as ViteDevServer, zt as GenerateDirsOptions } from "./config-BbL8Gqez.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, 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.15.
|
|
4
|
+
"version": "6.15.6",
|
|
5
5
|
"description": "weapp-vite 一个现代化的小程序打包工具",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -117,21 +117,21 @@
|
|
|
117
117
|
"vue": "^3.5.32",
|
|
118
118
|
"vue-tsc": "^3.2.6",
|
|
119
119
|
"@weapp-core/constants": "^0.1.1",
|
|
120
|
-
"@weapp-core/init": "6.0.
|
|
120
|
+
"@weapp-core/init": "6.0.7",
|
|
121
121
|
"@weapp-core/logger": "3.1.1",
|
|
122
122
|
"@weapp-core/schematics": "6.0.4",
|
|
123
123
|
"@weapp-core/shared": "3.0.3",
|
|
124
|
-
"@weapp-vite/ast": "6.15.
|
|
124
|
+
"@weapp-vite/ast": "6.15.6",
|
|
125
125
|
"@weapp-vite/mcp": "1.2.1",
|
|
126
126
|
"@weapp-vite/miniprogram-automator": "1.0.2",
|
|
127
127
|
"@weapp-vite/volar": "2.0.8",
|
|
128
|
-
"@weapp-vite/web": "1.3.
|
|
128
|
+
"@weapp-vite/web": "1.3.16",
|
|
129
129
|
"@wevu/api": "0.2.3",
|
|
130
|
-
"@wevu/web-apis": "1.2.
|
|
130
|
+
"@wevu/web-apis": "1.2.7",
|
|
131
131
|
"rolldown-require": "2.0.13",
|
|
132
132
|
"vite-plugin-performance": "2.0.1",
|
|
133
|
-
"weapp-ide-cli": "5.2.
|
|
134
|
-
"wevu": "6.15.
|
|
133
|
+
"weapp-ide-cli": "5.2.3",
|
|
134
|
+
"wevu": "6.15.6"
|
|
135
135
|
},
|
|
136
136
|
"publishConfig": {
|
|
137
137
|
"access": "public",
|
package/dist/file-BVlUDAip.mjs
DELETED