@proteus-vue/plugin-vite 0.2.0-beta.4 → 0.2.0-beta.5

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.
@@ -20,6 +20,17 @@ export interface GenRoutesOptions {
20
20
  dependencies?: Record<string, string>;
21
21
  preload?: string[];
22
22
  }>;
23
+ /**
24
+ * ★Web 目标只生成**应用侧路由表**(2026-09-19 修外部实战报告的第 3 条阻断项):
25
+ * `auto-routes.ts` 是 **双端共用** 产物(Web 的 RouterView 与 MP 的 app.json 同源),
26
+ * 但此前 gen-routes 只在 MP 目标被调用(`needsGenRoutes: isMp`)→ 使用 `proteus build --target web`
27
+ * 的工程新增页面后路由表不更新 → **页面 404**(外部项目实测:新增 `src/pages/editor/` 后
28
+ * Web 构建成功但路由表未收录)。
29
+ * `webOnly: true` 时:只 `scanPages → buildRoutes → validate → writeAutoRoutes`,
30
+ * **跳过 MP 专属产物**(app.json/page.json/component.json/project.config.json,web 构建不需要)
31
+ * 且**不清理 `dist/mp-weixin`**(否则会把已构建的 MP 产物删掉——那不属于 web 构建的职责)。
32
+ */
33
+ webOnly?: boolean;
23
34
  }
24
35
  /**
25
36
  * 运行路由表生成(纯函数,可单测):清理 dist 产物 → 扫描页面 → 生成 auto-routes/app.json/page.json/component.json
package/dist/index.js CHANGED
@@ -294,6 +294,10 @@ function runGenRoutes(options) {
294
294
  return ` { ${parts.join(", ")} },`;
295
295
  }
296
296
  function writeAutoRoutes(routes2) {
297
+ if (!rc.routesOutput) {
298
+ console.log("[gen-routes] routesOutput \u4E3A\u7A7A \u2192 \u6309\u914D\u7F6E**\u8DF3\u8FC7**\u5E94\u7528\u4FA7\u8DEF\u7531\u8868\u751F\u6210\uFF08\u5DE5\u7A0B\u81EA\u5E26\u8DEF\u7531\u673A\u5236\uFF09");
299
+ return;
300
+ }
297
301
  const lines = [
298
302
  `// ${rc.routesOutput} \u2014\u2014 \u5E94\u7528\u4FA7\u8DEF\u7531\u8868\uFF08AUTO-GENERATED by scripts/gen-routes.ts\uFF0C\u52FF\u624B\u52A8\u7F16\u8F91\uFF09`,
299
303
  "// \u2605\u62C6\u5305\u6B65\u9AA4 4\uFF1Aauto-routes \u968F\u5E94\u7528\u5B58\u653E\uFF08\u5DE5\u5382\u5316\u540E\u8DEF\u7531\u8868\u7531\u5E94\u7528\u6CE8\u5165 createRouter\uFF09\uFF0C\u4E0D\u518D\u5C5E\u4E8E @proteus-vue/router \u5305",
@@ -715,10 +719,15 @@ function runGenRoutes(options) {
715
719
  fs2.writeFileSync(path2.join(OUT_DIR, "project.config.json"), JSON.stringify(projectConfig, null, 2) + "\n");
716
720
  console.log(`[gen-routes] \u5DF2\u751F\u6210 dist/mp-weixin/project.config.json\uFF08appid=${config.appid}\uFF0Cprojectname=${projectName}\uFF09`);
717
721
  }
718
- fs2.rmSync(OUT_DIR, { recursive: true, force: true });
719
722
  const pages = scanPages();
720
723
  const routes = buildRoutes(pages);
721
724
  validate(pages, routes);
725
+ if (options.webOnly) {
726
+ writeAutoRoutes(routes);
727
+ console.log(`[gen-routes] \uFF08web \u76EE\u6807\uFF09\u5DF2\u66F4\u65B0\u5E94\u7528\u4FA7\u8DEF\u7531\u8868\uFF1A\u5171 ${pages.length} \u4E2A\u9875\u9762`);
728
+ return;
729
+ }
730
+ fs2.rmSync(OUT_DIR, { recursive: true, force: true });
722
731
  writeAutoRoutes(routes);
723
732
  writeAppJson(pages, routes);
724
733
  writePageJsons(pages);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proteus-vue/plugin-vite",
3
- "version": "0.2.0-beta.4",
3
+ "version": "0.2.0-beta.5",
4
4
  "description": "Proteus Vite 插件(mp-weixin 编译管线适配层)+ gen-routes 路由表生成器",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@proteus-vue/compiler": "0.3.0-beta.3",
23
23
  "@proteus-vue/module": "0.1.1-beta.0",
24
- "@proteus-vue/router": "0.2.0-beta.4",
24
+ "@proteus-vue/router": "0.2.0-beta.5",
25
25
  "@proteus-vue/types": "0.2.0-beta.2",
26
26
  "esbuild": "^0.28.2",
27
27
  "sass": "^1.103.1",