PRA-only-demo/electron-builder.config.mjs
yu 22a7ee1595 修复外部浏览器 CDP 无响应: ws 从主进程 bundle 外部化
根因: ws 被打进主进程 bundle 时, 其可选依赖 bufferutil 的打包解析产物
破坏了客户端发帧的 mask fallback; permessage-deflate 协商开启时错误被
压缩路径静默吞掉 —— 表现为 ws 握手成功但所有 CDP 命令零字节发出、
无响应(输入文本节点 10s 超时), dev 与打包版皆受影响。

- electron.vite.config: externalizeDepsPlugin include ws, 运行时 require
- package.json: ws 提升到根依赖, electron-builder 随包收集
- electron-builder.config: 确认 node_modules/ws 进入 asar
- transport: 显式 perMessageDeflate:false(双保险, 附注释)
- package.mjs: verifyLaunch 剥离 ELECTRON_RUN_AS_NODE/NODE_OPTIONS,
  防止外部工具链环境把打包应用带进纯 Node 模式(bad option 退出码 9)
- flows: 演示流程支持 RPA_DEMO_BROWSER 强制指定浏览器(Chrome 缺装回退 Edge)

验证: 全量测试 349 绿 + 浏览器 e2e 绿 + portable/NSIS 双冒烟通过,
安装包/zip/SHA256 已产出。
2026-11-04 17:19:32 +08:00

66 lines
2.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { readFileSync } from "node:fs";
import path from "node:path";
import os from "node:os";
import process from "node:process";
import { fileURLToPath } from "node:url";
const root = path.dirname(fileURLToPath(import.meta.url));
const packageJson = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8"));
/** @type {import('electron-builder').Configuration} */
export default {
appId: "com.rpastudio.desktop",
productName: "RPA Studio",
artifactName: "RPA-Studio-Setup-${version}-win-${arch}.${ext}",
directories: {
output: path.join(os.tmpdir(), "RPA-Studio-electron-builder"),
buildResources: path.join(root, "build")
},
files: [
"out/**/*",
"package.json",
// ws 已从主进程 bundle 外部化(运行时 require),必须随包发布;
// ws 为零依赖纯 JS 库,asar 内即可解析
"node_modules/ws/**/*"
],
extraResources: [
{ from: path.join(root, "resources", "catalog.json"), to: "catalog.json" },
{ from: path.join(root, "resources", "excluded.json"), to: "excluded.json" },
{ from: path.join(root, "resources", "capability-duplicates.json"), to: "capability-duplicates.json" },
{ from: path.join(root, "resources", "desktop-picker.ps1"), to: "desktop-picker.ps1" },
{ from: path.join(root, "resources", "models", "ui-element-detect"), to: "models/ui-element-detect" },
{ from: path.join(root, "resources", "fixture"), to: "fixture" }
],
asar: true,
asarUnpack: [
"node_modules/onnxruntime-node/**",
"node_modules/sharp/**",
"node_modules/@gutenye/**",
"node_modules/@napi-rs/**"
],
compression: "maximum",
npmRebuild: false,
electronVersion: packageJson.devDependencies.electron,
electronDist: path.join(root, "node_modules", "electron", "dist"),
win: {
target: [{ target: "nsis", arch: ["x64"] }],
icon: path.join(root, "build", "icon.ico"),
signAndEditExecutable: true
},
nsis: {
oneClick: false,
perMachine: false,
allowElevation: false,
allowToChangeInstallationDirectory: true,
installerLanguages: ["zh_CN"],
language: "2052",
shortcutName: "RPA Studio",
uninstallDisplayName: "RPA Studio ${version}",
createDesktopShortcut: true,
createStartMenuShortcut: true,
runAfterFinish: true,
deleteAppDataOnUninstall: false
},
publish: null
};