控制台的 sidecar 是 .mjs,此前只能在装了 Node 的机器上跑(resolve_node 会回退系统 node)。 新增 scripts/prepare-console.mjs 把 Node 运行时准备为 Tauri resource,随包分发给最终用户。 - prepare-console.mjs:复制本机 node → apps/console/src-tauri/runtime/,macOS 上 strip -x (108MB→86MB)**并 adhoc 重签**,再生成注入片段 tauri.bundle.gen.json;带幂等(同源跳过) 与**产物自检**(真跑一次 node,失败即删除产物并报错,避免坏产物被静默复用)。 - apps/console/scripts/verify-bundle.mjs:验证「打包产物能否自举」——真 spawn 打包内的 node 去跑打包内的 sidecar 并走一次真实 JSON-RPC 握手。 - package.json:新增 prepare:node / verify:bundle,bundle = sidecar:build → prepare:node → tauri build --config → verify:bundle(一条命令产出可分发件并自证可用)。 - src-tauri/.gitignore:忽略 /runtime/(~86MB)与生成的注入片段(生成物不入库)。 三处实测踩出来的约束(均已写进脚本注释与 console-plan.md): 1. **macOS 上 strip 会使 Mach-O 代码签名失效 → 内核直接 SIGKILL(exit 137)**,且无任何有用报错。 实测对照:原样复制 ✓ / strip 不重签 ✗(137) / strip + `codesign --force --sign -` ✓。 故 strip 之后的 adhoc 重签是**必要配套**,不是可选优化。 2. **Node 运行时不得声明进默认 tauri.conf.json** —— bundle.resources 是编译期契约 (tauri-build 校验声明的文件必须存在),声明「运行期才就绪」的资源会让 cargo check/test 在 build.rs 阶段直接失败(2026-10-10 已踩)。故一律走 `tauri build --config` 注入。 3. **resource 映射必须与 resolve_node 对齐** —— `runtime/node → node` 使产物落在 Contents/Resources/node,正是 src-tauri/src/sidecar.rs 里 resolve_node 查找的路径。 实测(macOS arm64):.app **90.8 MiB**(原 6.75 MiB,增量即运行时 86MB)/ .dmg **33.78 MiB**(分发件,仍低于 40MB 目标);应用进程实测可启动且无崩溃输出。 对照:本机实测 Electron 运行时本体(Electron Framework.framework)207MB —— 不到一半。
36 lines
1.0 KiB
JSON
36 lines
1.0 KiB
JSON
{
|
|
"name": "nodeagent-console",
|
|
"private": true,
|
|
"version": "2.0.1",
|
|
"type": "module",
|
|
"scripts": {
|
|
"dev": "vite",
|
|
"build": "vue-tsc --noEmit && vite build",
|
|
"preview": "vite preview",
|
|
"tauri": "tauri",
|
|
"sidecar:dev": "node sidecar/main.mjs",
|
|
"sidecar:build": "node sidecar/build.mjs",
|
|
"prepare:node": "node ../../scripts/prepare-console.mjs",
|
|
"verify:bundle": "node scripts/verify-bundle.mjs",
|
|
"bundle": "pnpm sidecar:build && pnpm prepare:node && tauri build --config src-tauri/tauri.bundle.gen.json && pnpm verify:bundle"
|
|
},
|
|
"dependencies": {
|
|
"@tauri-apps/api": "^2",
|
|
"@tauri-apps/plugin-opener": "^2",
|
|
"echarts": "^6.1.0",
|
|
"naive-ui": "^2.45.3",
|
|
"pinia": "^4.0.3",
|
|
"vue": "^3.5.13",
|
|
"vue-router": "^5.3.1",
|
|
"@nodeagent/client": "workspace:*",
|
|
"@nodeagent/protocol": "workspace:*"
|
|
},
|
|
"devDependencies": {
|
|
"@tauri-apps/cli": "^2",
|
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
"typescript": "~6.0.3",
|
|
"vite": "^8.0.16",
|
|
"vue-tsc": "^3.3.5"
|
|
}
|
|
}
|