weapp-vite 6.12.0 → 6.12.3
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 +49 -0
- package/dist/auto-import-components/resolvers.mjs +1 -0
- package/dist/auto-routes.mjs +1 -1
- package/dist/cli.mjs +6 -6
- package/dist/{config-Av2eTTDE.d.mts → config-DKt372Bv.d.mts} +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/{createContext-Cy_160Dm.mjs → createContext-f0OMYoia.mjs} +39 -10
- package/dist/docs/README.md +237 -0
- package/dist/docs/ai-workflows.md +64 -0
- package/dist/docs/define-config-overloads.md +108 -0
- package/dist/docs/getting-started.md +74 -0
- package/dist/docs/index.md +30 -0
- package/dist/docs/mcp.md +230 -0
- package/dist/docs/project-structure.md +52 -0
- package/dist/docs/troubleshooting.md +62 -0
- package/dist/docs/volar.md +433 -0
- package/dist/docs/vue-sfc.md +45 -0
- package/dist/docs/weapp-config.md +64 -0
- package/dist/docs/wevu-authoring.md +47 -0
- package/dist/{file-DKg072cZ.mjs → file-DRs69M1m.mjs} +1 -1
- 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 +4 -4
package/README.md
CHANGED
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
|
|
32
32
|
## 快速开始
|
|
33
33
|
|
|
34
|
+
> 说明:CLI 同时支持完整命令 `weapp-vite` 与简写命令 `wv`,两者等价。下面的示例默认使用 `weapp-vite`,你也可以按个人习惯替换成 `wv`。
|
|
35
|
+
|
|
34
36
|
### Vue 项目
|
|
35
37
|
|
|
36
38
|
```typescript
|
|
@@ -85,6 +87,42 @@ function handleClick() {
|
|
|
85
87
|
- Vite 插件识别 weapp-vite 宿主:https://vite.icebreaker.top/guide/vite-plugin-host
|
|
86
88
|
- MCP 集成使用指南:[docs/mcp.md](./docs/mcp.md)
|
|
87
89
|
|
|
90
|
+
## AI 项目指引
|
|
91
|
+
|
|
92
|
+
通过 `create-weapp-vite` 创建的新项目,现在会默认携带一个根目录 `AGENTS.md`。同时,`weapp-vite` npm 包会随版本发布一份本地文档目录:`node_modules/weapp-vite/dist/docs/`。
|
|
93
|
+
|
|
94
|
+
这个文件会告诉常见 AI 编程代理:
|
|
95
|
+
|
|
96
|
+
- 安装依赖后,优先阅读 `node_modules/weapp-vite/dist/docs/README.md`、`node_modules/weapp-vite/dist/docs/mcp.md` 等本地版本文档
|
|
97
|
+
- CLI 同时支持 `weapp-vite` 与 `wv`
|
|
98
|
+
- 需要做小程序截图验收时,优先使用 `weapp-vite screenshot` 或 `wv screenshot`
|
|
99
|
+
- 不要把小程序运行时截图退化成通用浏览器截图
|
|
100
|
+
- 需要看 DevTools 终端日志时,优先使用 `weapp-vite ide logs --open` 或 `wv ide logs --open`
|
|
101
|
+
|
|
102
|
+
`dist/docs` 当前会内置这些文件:
|
|
103
|
+
|
|
104
|
+
- `README.md`
|
|
105
|
+
- `getting-started.md`
|
|
106
|
+
- `ai-workflows.md`
|
|
107
|
+
- `project-structure.md`
|
|
108
|
+
- `weapp-config.md`
|
|
109
|
+
- `wevu-authoring.md`
|
|
110
|
+
- `vue-sfc.md`
|
|
111
|
+
- `troubleshooting.md`
|
|
112
|
+
- `mcp.md`
|
|
113
|
+
- `volar.md`
|
|
114
|
+
- `define-config-overloads.md`
|
|
115
|
+
- `index.md`
|
|
116
|
+
|
|
117
|
+
推荐的截图命令示例:
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
weapp-vite screenshot --project ./dist/build/mp-weixin --page pages/index/index --output .tmp/acceptance.png --json
|
|
121
|
+
|
|
122
|
+
# 等价写法
|
|
123
|
+
wv screenshot --project ./dist/build/mp-weixin --page pages/index/index --output .tmp/acceptance.png --json
|
|
124
|
+
```
|
|
125
|
+
|
|
88
126
|
## DevTools 日志桥接
|
|
89
127
|
|
|
90
128
|
`weapp-vite` 现在支持把微信开发者工具里的小程序 `console` 输出桥接到当前终端。
|
|
@@ -116,6 +154,9 @@ export default defineConfig({
|
|
|
116
154
|
```sh
|
|
117
155
|
weapp-vite ide logs
|
|
118
156
|
weapp-vite ide logs --open
|
|
157
|
+
# 等价写法
|
|
158
|
+
wv ide logs
|
|
159
|
+
wv ide logs --open
|
|
119
160
|
```
|
|
120
161
|
|
|
121
162
|
## CLI 中调用 weapp-ide-cli
|
|
@@ -127,6 +168,8 @@ weapp-vite preview --project ./dist/build/mp-weixin
|
|
|
127
168
|
weapp-vite upload --project ./dist/build/mp-weixin -v 1.0.0 -d "release"
|
|
128
169
|
weapp-vite config lang zh
|
|
129
170
|
weapp-vite navigate pages/index/index --project ./dist/build/mp-weixin
|
|
171
|
+
# 等价写法
|
|
172
|
+
wv preview --project ./dist/build/mp-weixin
|
|
130
173
|
```
|
|
131
174
|
|
|
132
175
|
也支持命名空间写法:
|
|
@@ -135,6 +178,8 @@ weapp-vite navigate pages/index/index --project ./dist/build/mp-weixin
|
|
|
135
178
|
weapp-vite ide preview --project ./dist/build/mp-weixin
|
|
136
179
|
weapp-vite ide config show
|
|
137
180
|
weapp-vite ide logs --open
|
|
181
|
+
# 等价写法
|
|
182
|
+
wv ide preview --project ./dist/build/mp-weixin
|
|
138
183
|
```
|
|
139
184
|
|
|
140
185
|
## CLI 启动 MCP
|
|
@@ -146,12 +191,16 @@ weapp-vite ide logs --open
|
|
|
146
191
|
|
|
147
192
|
```sh
|
|
148
193
|
weapp-vite mcp
|
|
194
|
+
# 等价写法
|
|
195
|
+
wv mcp
|
|
149
196
|
```
|
|
150
197
|
|
|
151
198
|
指定工作区根路径:
|
|
152
199
|
|
|
153
200
|
```sh
|
|
154
201
|
weapp-vite mcp --workspace-root /absolute/path/to/weapp-vite
|
|
202
|
+
# 等价写法
|
|
203
|
+
wv mcp --workspace-root /absolute/path/to/weapp-vite
|
|
155
204
|
```
|
|
156
205
|
|
|
157
206
|
在 `vite.config.ts` 中开启自动启动:
|
package/dist/auto-routes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as getCompilerContext, l as getRouteRuntimeGlobalKeys } from "./createContext-
|
|
1
|
+
import { i as getCompilerContext, l as getRouteRuntimeGlobalKeys } from "./createContext-f0OMYoia.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,16 +1,16 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as getDefaultIdeProjectRoot, b as shouldPassPlatformArgToIdeOpen, c as SHARED_CHUNK_VIRTUAL_PREFIX, d as checkRuntime, f as getProjectConfigFileName, g as DEFAULT_MP_PLATFORM, h as createCjsConfigLoadError, m as parseCommentJson, n as syncProjectSupportFiles, o as formatBytes, p as loadViteConfigFile, r as syncManagedTsconfigBootstrapFiles, s as createSharedBuildConfig, t as createCompilerContext, u as resolveWeappConfigFile, v as normalizeMiniPlatform, x as isPathInside, y as resolveMiniPlatform } from "./createContext-f0OMYoia.mjs";
|
|
2
2
|
import { r as logger_default, t as colors } from "./logger-gutcwWKE.mjs";
|
|
3
|
-
import { p as VERSION } from "./file-
|
|
3
|
+
import { p as VERSION } from "./file-DRs69M1m.mjs";
|
|
4
4
|
import { resolveWeappMcpConfig, startWeappViteMcpServer } from "./mcp.mjs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import { defu } from "@weapp-core/shared";
|
|
7
7
|
import path, { posix } from "pathe";
|
|
8
8
|
import fs from "fs-extra";
|
|
9
9
|
import process from "node:process";
|
|
10
|
-
import
|
|
10
|
+
import fs$1 from "node:fs/promises";
|
|
11
|
+
import { build, createServer } from "vite";
|
|
11
12
|
import { execFile } from "node:child_process";
|
|
12
13
|
import { Buffer } from "node:buffer";
|
|
13
|
-
import fs$1 from "node:fs/promises";
|
|
14
14
|
import fs$2 from "node:fs";
|
|
15
15
|
import { cac } from "cac";
|
|
16
16
|
import { resolveCommand } from "package-manager-detector/commands";
|
|
@@ -1289,7 +1289,7 @@ async function loadConfig(configFile) {
|
|
|
1289
1289
|
};
|
|
1290
1290
|
let loaded;
|
|
1291
1291
|
try {
|
|
1292
|
-
loaded = await
|
|
1292
|
+
loaded = await loadViteConfigFile(configEnv, resolvedConfigFile, cwd, void 0, void 0, "runner");
|
|
1293
1293
|
} catch (error) {
|
|
1294
1294
|
const cjsError = createCjsConfigLoadError({
|
|
1295
1295
|
error,
|
|
@@ -1309,7 +1309,7 @@ async function loadConfig(configFile) {
|
|
|
1309
1309
|
const normalizedLoadedPath = loaded?.path ? path.resolve(loaded.path) : void 0;
|
|
1310
1310
|
if (normalizedLoadedPath && normalizedLoadedPath === normalizedWeappPath) weappLoaded = loaded;
|
|
1311
1311
|
else try {
|
|
1312
|
-
weappLoaded = await
|
|
1312
|
+
weappLoaded = await loadViteConfigFile(configEnv, weappConfigFilePath, cwd, void 0, void 0, "runner");
|
|
1313
1313
|
} catch (error) {
|
|
1314
1314
|
const cjsError = createCjsConfigLoadError({
|
|
1315
1315
|
error,
|
|
@@ -3,8 +3,8 @@ import { t as AutoRoutes } from "./routes-DUBjYF43.mjs";
|
|
|
3
3
|
import { LRUCache } from "lru-cache";
|
|
4
4
|
import { LoggerConfig } from "@weapp-core/logger";
|
|
5
5
|
import { WeappAstConfig } from "@weapp-vite/ast";
|
|
6
|
-
import { fdir } from "fdir";
|
|
7
6
|
import { ConfigEnv, ConfigEnv as ConfigEnv$1, InlineConfig, InlineConfig as InlineConfig$1, Plugin as Plugin$1, PluginOption, ResolvedConfig, UserConfig, ViteDevServer, ViteDevServer as ViteDevServer$1, build } from "vite";
|
|
7
|
+
import { fdir } from "fdir";
|
|
8
8
|
import { InputOption, RolldownBuild, RolldownOptions, RolldownOutput, RolldownOutput as RolldownOutput$1, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcher as RolldownWatcher$1, WatchOptions as RolldownWatchOptions } from "rolldown";
|
|
9
9
|
import { Options } from "rolldown-plugin-dts";
|
|
10
10
|
import { Buffer } from "node:buffer";
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { An as resolveWeappViteHostMeta, Dn as applyWeappViteHostMeta, En as WeappViteRuntime, On as createWeappViteHostMeta, Tn as WeappViteHostMeta, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, kn as isWeappViteHost, 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, wn as WEAPP_VITE_HOST_NAME, y as defineThemeJson } from "./config-
|
|
1
|
+
import { An as resolveWeappViteHostMeta, Dn as applyWeappViteHostMeta, En as WeappViteRuntime, On as createWeappViteHostMeta, Tn as WeappViteHostMeta, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, kn as isWeappViteHost, 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, wn as WEAPP_VITE_HOST_NAME, y as defineThemeJson } from "./config-DKt372Bv.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,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-twds-ZHy.mjs";
|
|
2
2
|
import { n as applyWeappViteHostMeta } from "./pluginHost-SJdl15d3.mjs";
|
|
3
3
|
import { n as configureLogger, r as logger_default } from "./logger-gutcwWKE.mjs";
|
|
4
|
-
import { _ as templateExtensions, a as findJsEntry, c as findVueEntry, d as isTemplate, f as touch, g as supportedCssLangs, h as jsExtensions, i as findCssEntry, l as inlineAutoRoutesImports, m as configExtensions, n as extractConfigFromVue, o as findJsonEntry, s as findTemplateEntry, t as changeFileExtension, u as isJsOrTs, v as vueExtensions } from "./file-
|
|
4
|
+
import { _ as templateExtensions, a as findJsEntry, c as findVueEntry, d as isTemplate, f as touch, g as supportedCssLangs, h as jsExtensions, i as findCssEntry, l as inlineAutoRoutesImports, m as configExtensions, n as extractConfigFromVue, o as findJsonEntry, s as findTemplateEntry, t as changeFileExtension, u as isJsOrTs, v as vueExtensions } from "./file-DRs69M1m.mjs";
|
|
5
5
|
import { createRequire, isBuiltin } from "node:module";
|
|
6
6
|
import { addExtension, defu, get, isEmptyObject, isObject, objectHash, removeExtension, removeExtensionDeep, set } from "@weapp-core/shared";
|
|
7
7
|
import { LRUCache } from "lru-cache";
|
|
@@ -18,20 +18,20 @@ import picomatch from "picomatch";
|
|
|
18
18
|
import { VUE_COMPONENT_TAG_RE, WE_VU_MODULE_ID, WE_VU_RUNTIME_APIS, buildClassStyleComputedCode, collectVueTemplateTags, compileJsxFile, compileVueFile, createJsonMerger, createPageEntryMatcher, createPageEntryMatcher as createPageEntryMatcher$1, getClassStyleWxsSource, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, pathExists, readAndParseSfc, readFile as readFile$1, resolveClassStyleWxsLocation } from "wevu/compiler";
|
|
19
19
|
import process from "node:process";
|
|
20
20
|
import { parse as parse$1, stringify } from "comment-json";
|
|
21
|
+
import fs$1, { readFile, readdir, rm } from "node:fs/promises";
|
|
22
|
+
import { build, createServer, loadConfigFromFile, preprocessCSS } from "vite";
|
|
21
23
|
import { createHash } from "node:crypto";
|
|
22
24
|
import { fileURLToPath } from "node:url";
|
|
23
25
|
import semverGte from "semver/functions/gte.js";
|
|
24
26
|
import semverSatisfies from "semver/functions/satisfies.js";
|
|
25
27
|
import semverValid from "semver/functions/valid.js";
|
|
26
28
|
import { fdir } from "fdir";
|
|
27
|
-
import { build, createServer, loadConfigFromFile, preprocessCSS } from "vite";
|
|
28
29
|
import { build as build$1 } from "rolldown";
|
|
29
30
|
import { dts } from "rolldown-plugin-dts";
|
|
30
31
|
import os from "node:os";
|
|
31
32
|
import { getPackageInfo, getPackageInfoSync, resolveModule } from "local-pkg";
|
|
32
33
|
import { spawn } from "node:child_process";
|
|
33
34
|
import { Buffer } from "node:buffer";
|
|
34
|
-
import fs$1, { readFile, readdir, rm } from "node:fs/promises";
|
|
35
35
|
import fs$2, { existsSync } from "node:fs";
|
|
36
36
|
import chokidar from "chokidar";
|
|
37
37
|
import { detect } from "package-manager-detector/detect";
|
|
@@ -225,7 +225,9 @@ function createEnabledAutoImportComponents(configService) {
|
|
|
225
225
|
return {
|
|
226
226
|
...defaults,
|
|
227
227
|
globs: [...globs],
|
|
228
|
+
output: true,
|
|
228
229
|
typedComponents: true,
|
|
230
|
+
htmlCustomData: true,
|
|
229
231
|
vueComponents: true,
|
|
230
232
|
vueComponentsModule: hasWevuDependency$1(configService) ? "wevu" : void 0
|
|
231
233
|
};
|
|
@@ -4706,6 +4708,30 @@ function resolveJson(entry, aliasEntries, platform, options) {
|
|
|
4706
4708
|
}
|
|
4707
4709
|
}
|
|
4708
4710
|
//#endregion
|
|
4711
|
+
//#region src/utils/loadViteConfigFile.ts
|
|
4712
|
+
const DEFAULT_VITE_CONFIG_FILES = [
|
|
4713
|
+
"vite.config.ts",
|
|
4714
|
+
"vite.config.mts",
|
|
4715
|
+
"vite.config.cts",
|
|
4716
|
+
"vite.config.js",
|
|
4717
|
+
"vite.config.mjs",
|
|
4718
|
+
"vite.config.cjs"
|
|
4719
|
+
];
|
|
4720
|
+
async function resolveImplicitConfigFile(configRoot) {
|
|
4721
|
+
for (const fileName of DEFAULT_VITE_CONFIG_FILES) {
|
|
4722
|
+
const filePath = path.resolve(configRoot, fileName);
|
|
4723
|
+
try {
|
|
4724
|
+
await fs$1.access(filePath);
|
|
4725
|
+
return filePath;
|
|
4726
|
+
} catch {
|
|
4727
|
+
continue;
|
|
4728
|
+
}
|
|
4729
|
+
}
|
|
4730
|
+
}
|
|
4731
|
+
async function loadViteConfigFile(configEnv, configFile, configRoot, configFileDependencies, configFileExport, configLoader, runner) {
|
|
4732
|
+
return loadConfigFromFile(configEnv, configFile ?? await resolveImplicitConfigFile(configRoot), configRoot, configFileDependencies, configFileExport, configLoader ?? "bundle", runner);
|
|
4733
|
+
}
|
|
4734
|
+
//#endregion
|
|
4709
4735
|
//#region src/utils/projectConfig.ts
|
|
4710
4736
|
const DEFAULT_PROJECT_PRIVATE_CONFIG_FILE_NAME = "project.private.config.json";
|
|
4711
4737
|
function getProjectConfigFileName(platform) {
|
|
@@ -9493,7 +9519,7 @@ function createLoadConfig(options) {
|
|
|
9493
9519
|
});
|
|
9494
9520
|
let loaded;
|
|
9495
9521
|
try {
|
|
9496
|
-
loaded = await
|
|
9522
|
+
loaded = await loadViteConfigFile({
|
|
9497
9523
|
command: isDev ? "serve" : "build",
|
|
9498
9524
|
mode
|
|
9499
9525
|
}, resolvedConfigFile, cwd, void 0, void 0, "runner");
|
|
@@ -9510,7 +9536,7 @@ function createLoadConfig(options) {
|
|
|
9510
9536
|
let weappLoaded;
|
|
9511
9537
|
if (weappConfigFilePath) if (shouldReuseLoadedWeappConfig(weappConfigFilePath, loaded?.path)) weappLoaded = loaded;
|
|
9512
9538
|
else try {
|
|
9513
|
-
weappLoaded = await
|
|
9539
|
+
weappLoaded = await loadViteConfigFile({
|
|
9514
9540
|
command: isDev ? "serve" : "build",
|
|
9515
9541
|
mode
|
|
9516
9542
|
}, weappConfigFilePath, cwd, void 0, void 0, "runner");
|
|
@@ -18283,6 +18309,9 @@ function resolveNpmDistDirName(configService) {
|
|
|
18283
18309
|
if (configService?.platform) return getPlatformNpmDistDirName(configService.platform, { alipayNpmMode: configService.weappViteConfig?.npm?.alipayNpmMode });
|
|
18284
18310
|
return getPlatformNpmDistDirName("weapp");
|
|
18285
18311
|
}
|
|
18312
|
+
function resolveNpmSourceCacheOutDir(cwd, npmDistDirName) {
|
|
18313
|
+
return path.resolve(cwd, ".weapp-vite/npm-source", npmDistDirName);
|
|
18314
|
+
}
|
|
18286
18315
|
function createNpmService(ctx) {
|
|
18287
18316
|
const oxcVitePlugin = createOxcRuntimeSupport().vitePlugin;
|
|
18288
18317
|
const cache = createDependenciesCache(ctx);
|
|
@@ -18300,7 +18329,7 @@ function createNpmService(ctx) {
|
|
|
18300
18329
|
const pkgJson = await fs.readJson(packageJsonPath);
|
|
18301
18330
|
const npmDistDirName = resolveNpmDistDirName(ctx.configService);
|
|
18302
18331
|
const outDir = path.resolve(ctx.configService.cwd, mainRelation.miniprogramNpmDistDir, npmDistDirName);
|
|
18303
|
-
const cachedSourceOutDir =
|
|
18332
|
+
const cachedSourceOutDir = resolveNpmSourceCacheOutDir(ctx.configService.cwd, npmDistDirName);
|
|
18304
18333
|
const localSubPackageOutRoot = ctx.configService.outDir || path.resolve(ctx.configService.cwd, mainRelation.miniprogramNpmDistDir);
|
|
18305
18334
|
if (pkgJson.dependencies) {
|
|
18306
18335
|
const allDependencies = Object.keys(pkgJson.dependencies);
|
|
@@ -18343,7 +18372,7 @@ function createNpmService(ctx) {
|
|
|
18343
18372
|
await fs.remove(targetDir);
|
|
18344
18373
|
await fs.copy(outDir, targetDir, { overwrite: true });
|
|
18345
18374
|
}));
|
|
18346
|
-
|
|
18375
|
+
for (const meta of localSubPackageMetas) {
|
|
18347
18376
|
const targetDir = path.resolve(localSubPackageOutRoot, meta.subPackage.root, npmDistDirName);
|
|
18348
18377
|
if (await cache.checkDependenciesCacheOutdate(meta.subPackage.root) || !await fs.pathExists(targetDir)) {
|
|
18349
18378
|
await fs.remove(targetDir);
|
|
@@ -18360,7 +18389,7 @@ function createNpmService(ctx) {
|
|
|
18360
18389
|
});
|
|
18361
18390
|
}
|
|
18362
18391
|
await cache.writeDependenciesCache(meta.subPackage.root);
|
|
18363
|
-
}
|
|
18392
|
+
}
|
|
18364
18393
|
}
|
|
18365
18394
|
}
|
|
18366
18395
|
debug$2?.("buildNpm end");
|
|
@@ -18948,7 +18977,7 @@ function createScanService(ctx) {
|
|
|
18948
18977
|
let vueAppPath;
|
|
18949
18978
|
if (!appEntryPath) vueAppPath = await findVueEntry(appBasename);
|
|
18950
18979
|
if (!appConfigFile && vueAppPath) {
|
|
18951
|
-
const { extractConfigFromVue } = await import("./file-
|
|
18980
|
+
const { extractConfigFromVue } = await import("./file-DRs69M1m.mjs").then((n) => n.r);
|
|
18952
18981
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
18953
18982
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
18954
18983
|
}
|
|
@@ -19718,4 +19747,4 @@ async function createCompilerContext(options) {
|
|
|
19718
19747
|
return ctx;
|
|
19719
19748
|
}
|
|
19720
19749
|
//#endregion
|
|
19721
|
-
export {
|
|
19750
|
+
export { getDefaultIdeProjectRoot as _, getInstance_exports as a, shouldPassPlatformArgToIdeOpen as b, SHARED_CHUNK_VIRTUAL_PREFIX as c, checkRuntime as d, getProjectConfigFileName as f, DEFAULT_MP_PLATFORM as g, createCjsConfigLoadError as h, getCompilerContext as i, getRouteRuntimeGlobalKeys as l, parseCommentJson as m, syncProjectSupportFiles as n, formatBytes as o, loadViteConfigFile as p, syncManagedTsconfigBootstrapFiles as r, createSharedBuildConfig as s, createCompilerContext as t, resolveWeappConfigFile as u, normalizeMiniPlatform as v, isPathInside as x, resolveMiniPlatform as y };
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://vite.icebreaker.top">
|
|
3
|
+
<img width="200" height="200" hspace="10" src="https://vite.icebreaker.top/logo.png" alt="vite logo" />
|
|
4
|
+
</a>
|
|
5
|
+
<h1>Weapp Vite</h1>
|
|
6
|
+
<p>
|
|
7
|
+
给小程序以现代化的开发体验
|
|
8
|
+
</p>
|
|
9
|
+
<img src="https://img.shields.io/node/v/weapp-vite" alt="node-current" />
|
|
10
|
+
<img src="https://img.shields.io/npm/dependency-version/weapp-vite/peer/vite" alt="npm peer dependency version" />
|
|
11
|
+
<img src="https://img.shields.io/github/v/release/weapp-vite/weapp-vite" alt="GitHub release" />
|
|
12
|
+
<img src="https://img.shields.io/npm/l/weapp-vite" alt="licence" />
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<p> </p>
|
|
16
|
+
|
|
17
|
+
## 使用文档地址: [vite.icebreaker.top](https://vite.icebreaker.top)
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- 🚀 **Vue 3 支持**:完整的 Vue 单文件组件(SFC)支持,使用 Vue 官方编译器
|
|
22
|
+
- `<script setup>` 和 TypeScript 完整支持
|
|
23
|
+
- 完整的模板语法(v-if、v-for、v-model 等)
|
|
24
|
+
- Scoped CSS 和 CSS Modules
|
|
25
|
+
- 动态组件、过渡动画、KeepAlive
|
|
26
|
+
- [详细文档 →](./test/vue/README.md)
|
|
27
|
+
|
|
28
|
+
- ⚡️ **Vite 构建**:带来了 `typescript` / `scss` / `less` 等等的原生支持
|
|
29
|
+
- 🔌 **插件生态**:Vite 插件生态支持,也可以自定义编写插件,方便扩展
|
|
30
|
+
- 🧰 **IDE 命令增强**:可直接透传 `weapp-ide-cli` 全量命令(`preview/upload/config/automator` 等)
|
|
31
|
+
|
|
32
|
+
## 快速开始
|
|
33
|
+
|
|
34
|
+
> 说明:CLI 同时支持完整命令 `weapp-vite` 与简写命令 `wv`,两者等价。下面的示例默认使用 `weapp-vite`,你也可以按个人习惯替换成 `wv`。
|
|
35
|
+
|
|
36
|
+
### Vue 项目
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// vite.config.ts
|
|
40
|
+
import { defineConfig } from 'weapp-vite/config'
|
|
41
|
+
|
|
42
|
+
export default defineConfig({
|
|
43
|
+
weapp: {
|
|
44
|
+
srcRoot: 'src',
|
|
45
|
+
vue: {
|
|
46
|
+
enable: true,
|
|
47
|
+
template: {
|
|
48
|
+
removeComments: true,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```vue
|
|
56
|
+
<!-- App.vue -->
|
|
57
|
+
<script setup>
|
|
58
|
+
import { ref } from 'vue'
|
|
59
|
+
|
|
60
|
+
const message = ref('Hello Vue in Mini-program!')
|
|
61
|
+
|
|
62
|
+
function handleClick() {
|
|
63
|
+
console.log('Button clicked!')
|
|
64
|
+
}
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<template>
|
|
68
|
+
<view class="container">
|
|
69
|
+
<text>{{ message }}</text>
|
|
70
|
+
<button @click="handleClick">
|
|
71
|
+
Click
|
|
72
|
+
</button>
|
|
73
|
+
</view>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<style scoped>
|
|
77
|
+
.container {
|
|
78
|
+
padding: 20rpx;
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
📚 **完整文档**: [Vue 支持文档](./test/vue/README.md)
|
|
84
|
+
|
|
85
|
+
- 配置智能提示文档:[docs/volar.md](./docs/volar.md)
|
|
86
|
+
- defineConfig 重载说明:[docs/define-config-overloads.md](./docs/define-config-overloads.md)
|
|
87
|
+
- Vite 插件识别 weapp-vite 宿主:https://vite.icebreaker.top/guide/vite-plugin-host
|
|
88
|
+
- MCP 集成使用指南:[docs/mcp.md](./docs/mcp.md)
|
|
89
|
+
|
|
90
|
+
## AI 项目指引
|
|
91
|
+
|
|
92
|
+
通过 `create-weapp-vite` 创建的新项目,现在会默认携带一个根目录 `AGENTS.md`。同时,`weapp-vite` npm 包会随版本发布一份本地文档目录:`node_modules/weapp-vite/dist/docs/`。
|
|
93
|
+
|
|
94
|
+
这个文件会告诉常见 AI 编程代理:
|
|
95
|
+
|
|
96
|
+
- 安装依赖后,优先阅读 `node_modules/weapp-vite/dist/docs/README.md`、`node_modules/weapp-vite/dist/docs/mcp.md` 等本地版本文档
|
|
97
|
+
- CLI 同时支持 `weapp-vite` 与 `wv`
|
|
98
|
+
- 需要做小程序截图验收时,优先使用 `weapp-vite screenshot` 或 `wv screenshot`
|
|
99
|
+
- 不要把小程序运行时截图退化成通用浏览器截图
|
|
100
|
+
- 需要看 DevTools 终端日志时,优先使用 `weapp-vite ide logs --open` 或 `wv ide logs --open`
|
|
101
|
+
|
|
102
|
+
`dist/docs` 当前会内置这些文件:
|
|
103
|
+
|
|
104
|
+
- `README.md`
|
|
105
|
+
- `getting-started.md`
|
|
106
|
+
- `ai-workflows.md`
|
|
107
|
+
- `project-structure.md`
|
|
108
|
+
- `weapp-config.md`
|
|
109
|
+
- `wevu-authoring.md`
|
|
110
|
+
- `vue-sfc.md`
|
|
111
|
+
- `troubleshooting.md`
|
|
112
|
+
- `mcp.md`
|
|
113
|
+
- `volar.md`
|
|
114
|
+
- `define-config-overloads.md`
|
|
115
|
+
- `index.md`
|
|
116
|
+
|
|
117
|
+
推荐的截图命令示例:
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
weapp-vite screenshot --project ./dist/build/mp-weixin --page pages/index/index --output .tmp/acceptance.png --json
|
|
121
|
+
|
|
122
|
+
# 等价写法
|
|
123
|
+
wv screenshot --project ./dist/build/mp-weixin --page pages/index/index --output .tmp/acceptance.png --json
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## DevTools 日志桥接
|
|
127
|
+
|
|
128
|
+
`weapp-vite` 现在支持把微信开发者工具里的小程序 `console` 输出桥接到当前终端。
|
|
129
|
+
|
|
130
|
+
默认行为:
|
|
131
|
+
|
|
132
|
+
- `weapp.forwardConsole` 默认是 `enabled: 'auto'`
|
|
133
|
+
- 当检测到当前运行环境是 AI 终端时,`weapp-vite dev --open` 会自动尝试附加日志桥
|
|
134
|
+
- 也可以手动进入持续监听模式
|
|
135
|
+
|
|
136
|
+
配置示例:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { defineConfig } from 'weapp-vite/config'
|
|
140
|
+
|
|
141
|
+
export default defineConfig({
|
|
142
|
+
weapp: {
|
|
143
|
+
forwardConsole: {
|
|
144
|
+
enabled: 'auto',
|
|
145
|
+
logLevels: ['log', 'info', 'warn', 'error'],
|
|
146
|
+
unhandledErrors: true,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
})
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
手动启动持续监听:
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
weapp-vite ide logs
|
|
156
|
+
weapp-vite ide logs --open
|
|
157
|
+
# 等价写法
|
|
158
|
+
wv ide logs
|
|
159
|
+
wv ide logs --open
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## CLI 中调用 weapp-ide-cli
|
|
163
|
+
|
|
164
|
+
`weapp-vite` 内置了对 `weapp-ide-cli` 的透传能力,除了 `dev/build/open/init/generate/analyze/npm` 等原生命令外,其它 IDE 相关命令都可以直接调用:
|
|
165
|
+
|
|
166
|
+
```sh
|
|
167
|
+
weapp-vite preview --project ./dist/build/mp-weixin
|
|
168
|
+
weapp-vite upload --project ./dist/build/mp-weixin -v 1.0.0 -d "release"
|
|
169
|
+
weapp-vite config lang zh
|
|
170
|
+
weapp-vite navigate pages/index/index --project ./dist/build/mp-weixin
|
|
171
|
+
# 等价写法
|
|
172
|
+
wv preview --project ./dist/build/mp-weixin
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
也支持命名空间写法:
|
|
176
|
+
|
|
177
|
+
```sh
|
|
178
|
+
weapp-vite ide preview --project ./dist/build/mp-weixin
|
|
179
|
+
weapp-vite ide config show
|
|
180
|
+
weapp-vite ide logs --open
|
|
181
|
+
# 等价写法
|
|
182
|
+
wv ide preview --project ./dist/build/mp-weixin
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## CLI 启动 MCP
|
|
186
|
+
|
|
187
|
+
`weapp-vite` 已集成 `@weapp-vite/mcp`:
|
|
188
|
+
|
|
189
|
+
- 默认不自动启动 MCP 服务(可通过配置开启自动启动)
|
|
190
|
+
- 也可以手动启动 MCP Server
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
weapp-vite mcp
|
|
194
|
+
# 等价写法
|
|
195
|
+
wv mcp
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
指定工作区根路径:
|
|
199
|
+
|
|
200
|
+
```sh
|
|
201
|
+
weapp-vite mcp --workspace-root /absolute/path/to/weapp-vite
|
|
202
|
+
# 等价写法
|
|
203
|
+
wv mcp --workspace-root /absolute/path/to/weapp-vite
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
在 `vite.config.ts` 中开启自动启动:
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
import { defineConfig } from 'weapp-vite/config'
|
|
210
|
+
|
|
211
|
+
export default defineConfig({
|
|
212
|
+
weapp: {
|
|
213
|
+
mcp: {
|
|
214
|
+
autoStart: true,
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
})
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
详细说明见:[docs/mcp.md](./docs/mcp.md)
|
|
221
|
+
|
|
222
|
+
## Contribute
|
|
223
|
+
|
|
224
|
+
我们邀请你来贡献和帮助改进 `weapp-vite` 💚💚💚
|
|
225
|
+
|
|
226
|
+
以下有几个方式可以参与:
|
|
227
|
+
|
|
228
|
+
- 报告错误:如果您遇到任何错误或问题,请提`issue`并提供完善的错误信息和复现方式。
|
|
229
|
+
- 建议:有增强 `weapp-vite` 的想法吗?请提 `issue` 来分享您的建议。
|
|
230
|
+
- 文档:如果您对文档有更好的见解或者更棒的修辞方式,欢迎 `pr`。
|
|
231
|
+
- 代码:任何人的代码都不是完美的,我们欢迎你通过 `pr` 给代码提供更好的质量与活力。
|
|
232
|
+
|
|
233
|
+
## License
|
|
234
|
+
|
|
235
|
+
[MIT](./LICENSE)
|
|
236
|
+
|
|
237
|
+
<!-- "//------":""esbuild": "^0.21.3",", -->
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# AI Workflows
|
|
2
|
+
|
|
3
|
+
这个文档面向在其他仓库里使用 `weapp-vite` 的 AI 代理。
|
|
4
|
+
|
|
5
|
+
## 首选信息源
|
|
6
|
+
|
|
7
|
+
当项目已经安装了 `weapp-vite` 时,优先读取本地随包文档,而不是先看网站旧内容:
|
|
8
|
+
|
|
9
|
+
1. `node_modules/weapp-vite/dist/docs/index.md`
|
|
10
|
+
2. `node_modules/weapp-vite/dist/docs/README.md`
|
|
11
|
+
3. `node_modules/weapp-vite/dist/docs/getting-started.md`
|
|
12
|
+
4. `node_modules/weapp-vite/dist/docs/weapp-config.md`
|
|
13
|
+
5. 按需继续阅读 `wevu-authoring.md`、`vue-sfc.md`、`troubleshooting.md`
|
|
14
|
+
|
|
15
|
+
## 项目级约束
|
|
16
|
+
|
|
17
|
+
如果项目由 `create-weapp-vite` 创建,根目录通常会有 `AGENTS.md`。
|
|
18
|
+
|
|
19
|
+
应把它视为项目工作流契约,而不是可忽略的模板文件。优先同时遵守:
|
|
20
|
+
|
|
21
|
+
1. 项目根 `AGENTS.md`
|
|
22
|
+
2. `node_modules/weapp-vite/dist/docs/*.md`
|
|
23
|
+
3. 当前仓库实际代码与 `vite.config.ts`
|
|
24
|
+
|
|
25
|
+
## 常用 AI 命令
|
|
26
|
+
|
|
27
|
+
CLI 同时支持完整命令 `weapp-vite` 与简写命令 `wv`,两者等价。
|
|
28
|
+
|
|
29
|
+
常见工作流:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
weapp-vite prepare
|
|
33
|
+
weapp-vite dev --open
|
|
34
|
+
weapp-vite build
|
|
35
|
+
weapp-vite screenshot --project ./dist/build/mp-weixin --page pages/index/index --output .tmp/acceptance.png --json
|
|
36
|
+
weapp-vite ide logs --open
|
|
37
|
+
weapp-vite mcp
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
等价写法:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
wv prepare
|
|
44
|
+
wv dev --open
|
|
45
|
+
wv build
|
|
46
|
+
wv screenshot --project ./dist/build/mp-weixin --page pages/index/index --output .tmp/acceptance.png --json
|
|
47
|
+
wv ide logs --open
|
|
48
|
+
wv mcp
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 截图与日志
|
|
52
|
+
|
|
53
|
+
- 小程序截图验收优先使用 `weapp-vite screenshot` / `wv screenshot`
|
|
54
|
+
- 不要退化成普通浏览器截图来替代小程序运行时截图
|
|
55
|
+
- 查看 DevTools 终端日志优先使用 `weapp-vite ide logs --open` / `wv ide logs --open`
|
|
56
|
+
|
|
57
|
+
## 推荐阅读顺序
|
|
58
|
+
|
|
59
|
+
- 项目初始化、命令和 AI 使用入口:[`getting-started.md`](./getting-started.md)
|
|
60
|
+
- 项目目录与生成文件:[`project-structure.md`](./project-structure.md)
|
|
61
|
+
- `vite.config.ts` 中的 `weapp` 配置:[`weapp-config.md`](./weapp-config.md)
|
|
62
|
+
- wevu 页面、组件、store 写法:[`wevu-authoring.md`](./wevu-authoring.md)
|
|
63
|
+
- Vue SFC 宏与模板约束:[`vue-sfc.md`](./vue-sfc.md)
|
|
64
|
+
- 常见告警与排障:[`troubleshooting.md`](./troubleshooting.md)
|