weapp-vite 6.15.5 → 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 CHANGED
@@ -187,6 +187,38 @@ wv ide logs
187
187
  wv ide logs --open
188
188
  ```
189
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
+
190
222
  ## CLI 中调用 weapp-ide-cli
191
223
 
192
224
  `weapp-vite` 内置了对 `weapp-ide-cli` 的透传能力,除了 `dev/build/open/init/generate/analyze/npm` 等原生命令外,其它 IDE 相关命令都可以直接调用:
@@ -197,6 +229,7 @@ weapp-vite upload --project ./dist/build/mp-weixin -v 1.0.0 -d "release"
197
229
  weapp-vite cache --clean compile
198
230
  weapp-vite cache --clean all
199
231
  weapp-vite config lang zh
232
+ weapp-vite config set autoTrustProject true
200
233
  weapp-vite navigate pages/index/index --project ./dist/build/mp-weixin
201
234
  # 等价写法
202
235
  wv preview --project ./dist/build/mp-weixin
@@ -208,6 +241,7 @@ wv cache --clean all
208
241
  ```sh
209
242
  weapp-vite ide preview --project ./dist/build/mp-weixin
210
243
  weapp-vite ide config show
244
+ weapp-vite ide setup .
211
245
  weapp-vite ide logs --open
212
246
  # 等价写法
213
247
  wv ide preview --project ./dist/build/mp-weixin
@@ -1,4 +1,4 @@
1
- import { i as getCompilerContext, u as getRouteRuntimeGlobalKeys } from "./createContext-BJXXIcT5.mjs";
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-BJXXIcT5.mjs";
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-DllJX3aP.mjs";
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";
@@ -1093,6 +1093,15 @@ async function reopenOpenedWechatIde(projectPath) {
1093
1093
  return true;
1094
1094
  }
1095
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
+ }
1096
1105
  if (platform === "weapp" && projectPath && options.trustProject !== false) try {
1097
1106
  if (options.reuseOpenedProject === false) {
1098
1107
  if (await reopenOpenedWechatIde(projectPath)) return;
@@ -1102,6 +1111,10 @@ async function openIde(platform, projectPath, options = {}) {
1102
1111
  await openWechatIdeByAutomator(projectPath);
1103
1112
  return;
1104
1113
  } catch (error) {
1114
+ if (isAutomatorLoginError(error)) {
1115
+ logger_default.error("检测到微信开发者工具登录状态失效,请先登录后重试。");
1116
+ logger_default.warn(formatAutomatorLoginError(error));
1117
+ }
1105
1118
  logger_default.warn("通过 automator 启动微信开发者工具并自动信任项目失败,回退到普通 open 流程。");
1106
1119
  logger_default.error(error);
1107
1120
  }
@@ -1386,8 +1399,7 @@ async function loadConfig(configFile) {
1386
1399
  }
1387
1400
  }
1388
1401
  if (!loaded && !weappLoaded) return;
1389
- const config = loaded?.config ?? weappLoaded?.config ?? {};
1390
- if (weappLoaded?.config?.weapp) config.weapp = defu(weappLoaded.config.weapp, config.weapp ?? {});
1402
+ const config = weappLoaded?.config ? defu(weappLoaded.config, loaded?.config ?? {}) : loaded?.config ?? {};
1391
1403
  const dependencySet = /* @__PURE__ */ new Set();
1392
1404
  for (const dependency of loaded?.dependencies ?? []) dependencySet.add(dependency);
1393
1405
  for (const dependency of weappLoaded?.dependencies ?? []) dependencySet.add(dependency);
@@ -1592,7 +1604,7 @@ async function waitForTermination(cleanup) {
1592
1604
  * @description 执行 ide 子命令。
1593
1605
  */
1594
1606
  async function runIdeCommand(action, root, options) {
1595
- if (action !== "logs") throw new Error(`未知 ide 子命令: ${action ?? "(empty)"}`);
1607
+ if (action !== "logs" && action !== "setup") throw new Error(`未知 ide 子命令: ${action ?? "(empty)"}`);
1596
1608
  filterDuplicateOptions(options);
1597
1609
  const configFile = resolveConfigFile(options);
1598
1610
  const targets = resolveRuntimeTargets(options);
@@ -1605,6 +1617,14 @@ async function runIdeCommand(action, root, options) {
1605
1617
  });
1606
1618
  if (resolved.platform !== "weapp") throw new Error("`weapp-vite ide logs` 当前仅支持微信小程序平台。");
1607
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
+ }
1608
1628
  if (options.open) await openIde(resolved.platform, resolved.projectPath, { trustProject: options.trustProject });
1609
1629
  const forwardConsoleOptions = await resolveForwardConsoleOptions({
1610
1630
  ...resolved.weappViteConfig,
@@ -2096,7 +2116,7 @@ function registerPrepareCommand(cli) {
2096
2116
  }
2097
2117
  //#endregion
2098
2118
  //#region package.json
2099
- var version = "6.15.5";
2119
+ var version = "6.15.6";
2100
2120
  //#endregion
2101
2121
  //#region src/cli/devHotkeys/format.ts
2102
2122
  const FULLWIDTH_ASCII_START = 65281;
@@ -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-DllJX3aP.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-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";
@@ -11151,10 +11151,11 @@ function createLoadConfig(options) {
11151
11151
  if (cjsError) throw cjsError;
11152
11152
  throw error;
11153
11153
  }
11154
+ const mergedLoadedConfig = weappLoaded?.config ? defu(weappLoaded.config, loadedConfig) : loadedConfig;
11154
11155
  const config = defu(inlineConfig, {
11155
11156
  mode,
11156
11157
  configFile: false
11157
- }, loadedConfig, {
11158
+ }, mergedLoadedConfig, {
11158
11159
  build: {
11159
11160
  rolldownOptions: { output: {
11160
11161
  entryFileNames: (chunkInfo) => {
@@ -11167,7 +11168,6 @@ function createLoadConfig(options) {
11167
11168
  logLevel: "warn",
11168
11169
  weapp: getWeappViteConfig()
11169
11170
  });
11170
- if (weappLoaded?.config?.weapp) config.weapp = defu(weappLoaded.config.weapp, config.weapp ?? {});
11171
11171
  const chunksConfigured = Boolean(inlineConfig?.weapp?.chunks || loadedConfig.weapp?.chunks || weappLoaded?.config?.weapp?.chunks);
11172
11172
  const shouldWarnEnhance = [
11173
11173
  inlineConfig?.weapp?.enhance,
@@ -34172,6 +34172,7 @@ function mergeMiniprogram(options, ...configs) {
34172
34172
  define: miniprogramDefines,
34173
34173
  build: {
34174
34174
  modulePreload: false,
34175
+ minify: false,
34175
34176
  emptyOutDir: false,
34176
34177
  rolldownOptions: { ...rolldownOptions }
34177
34178
  }
@@ -34479,7 +34480,7 @@ function createConfigService(ctx) {
34479
34480
  if (resolvedConfig.configMergeInfo?.merged) {
34480
34481
  const weappConfigDisplay = formatConfigDisplayPath(resolvedConfig.configMergeInfo.weappConfigPath) ?? "weapp-vite.config.ts";
34481
34482
  const viteConfigDisplay = formatConfigDisplayPath(resolvedConfig.configMergeInfo.viteConfigPath) ?? "vite.config.ts";
34482
- logger_default.info(`[config] 检测到同时存在 ${weappConfigDisplay} 与 ${viteConfigDisplay},已合并其中的 \`weapp\` 配置,优先级:${weappConfigDisplay} > ${viteConfigDisplay}`);
34483
+ logger_default.info(`[config] 检测到同时存在 ${weappConfigDisplay} 与 ${viteConfigDisplay},已合并两份 Vite 配置,优先级:${weappConfigDisplay} > ${viteConfigDisplay}`);
34483
34484
  }
34484
34485
  packageManager = await detect() ?? {
34485
34486
  agent: "npm",
@@ -35059,7 +35060,7 @@ async function loadAppEntry(ctx, scanState) {
35059
35060
  const vueAppPath = await findVueEntry(appBasename);
35060
35061
  let configFromVue;
35061
35062
  if (!appConfigFile && vueAppPath) {
35062
- const { extractConfigFromVue } = await import("./file-D-LpaSgY.mjs");
35063
+ const { extractConfigFromVue } = await import("./file-DY9paehF.mjs");
35063
35064
  configFromVue = await extractConfigFromVue(vueAppPath);
35064
35065
  if (configFromVue) appConfigFile = vueAppPath;
35065
35066
  }
@@ -187,6 +187,38 @@ wv ide logs
187
187
  wv ide logs --open
188
188
  ```
189
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
+
190
222
  ## CLI 中调用 weapp-ide-cli
191
223
 
192
224
  `weapp-vite` 内置了对 `weapp-ide-cli` 的透传能力,除了 `dev/build/open/init/generate/analyze/npm` 等原生命令外,其它 IDE 相关命令都可以直接调用:
@@ -197,6 +229,7 @@ weapp-vite upload --project ./dist/build/mp-weixin -v 1.0.0 -d "release"
197
229
  weapp-vite cache --clean compile
198
230
  weapp-vite cache --clean all
199
231
  weapp-vite config lang zh
232
+ weapp-vite config set autoTrustProject true
200
233
  weapp-vite navigate pages/index/index --project ./dist/build/mp-weixin
201
234
  # 等价写法
202
235
  wv preview --project ./dist/build/mp-weixin
@@ -208,6 +241,7 @@ wv cache --clean all
208
241
  ```sh
209
242
  weapp-vite ide preview --project ./dist/build/mp-weixin
210
243
  weapp-vite ide config show
244
+ weapp-vite ide setup .
211
245
  weapp-vite ide logs --open
212
246
  # 等价写法
213
247
  wv ide preview --project ./dist/build/mp-weixin
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
84
84
  }
85
85
  async function resolveAutoRoutesInlineSnapshot() {
86
86
  try {
87
- const { getCompilerContext } = await import("./getInstance-BuIdW4Wd.mjs");
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?.();
@@ -0,0 +1,2 @@
1
+ import { t as extractConfigFromVue } from "./file-CCWF5mwT.mjs";
2
+ export { extractConfigFromVue };
@@ -0,0 +1,2 @@
1
+ import { i as getCompilerContext } from "./createContext-DPe-Wp3_.mjs";
2
+ export { getCompilerContext };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createCompilerContext } from "./createContext-BJXXIcT5.mjs";
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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "6.15.5",
4
+ "version": "6.15.6",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -121,17 +121,17 @@
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.5",
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.15",
128
+ "@weapp-vite/web": "1.3.16",
129
129
  "@wevu/api": "0.2.3",
130
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.2",
134
- "wevu": "6.15.5"
133
+ "weapp-ide-cli": "5.2.3",
134
+ "wevu": "6.15.6"
135
135
  },
136
136
  "publishConfig": {
137
137
  "access": "public",
@@ -1,2 +0,0 @@
1
- import { t as extractConfigFromVue } from "./file-DllJX3aP.mjs";
2
- export { extractConfigFromVue };
@@ -1,2 +0,0 @@
1
- import { i as getCompilerContext } from "./createContext-BJXXIcT5.mjs";
2
- export { getCompilerContext };