diff --git a/config/electron-builder.config.cjs b/config/electron-builder.config.cjs index 1982a378600..8a5f8c27475 100644 --- a/config/electron-builder.config.cjs +++ b/config/electron-builder.config.cjs @@ -150,8 +150,10 @@ const MARKDOWN_FILE_EXTENSIONS = ['md', 'markdown', 'mdx'] // Why: the config must load on a host-only install without resolving unused Windows addons. // This is load-time tolerance only; beforePack enforces that the target's natives are installed. -const windowsRuntimeResources = ['@vscode/windows-process-tree', 'windows-native-registry'].every( - (name) => existsSync(join(__dirname, '..', 'node_modules', name, 'package.json')) +// Why one package: @vscode/windows-process-tree is the only os: win32 npm addon; +// @orca/windows-registry is a workspace link present on every host, so its presence proves nothing. +const windowsRuntimeResources = existsSync( + join(__dirname, '..', 'node_modules', '@vscode', 'windows-process-tree', 'package.json') ) ? createPackagedRuntimeNodeModuleResources('win32') : [] diff --git a/config/packaged-runtime-node-modules.cjs b/config/packaged-runtime-node-modules.cjs index 4a5585806b5..30784e79f5c 100644 --- a/config/packaged-runtime-node-modules.cjs +++ b/config/packaged-runtime-node-modules.cjs @@ -552,20 +552,18 @@ function assertPackagedNativeVariantsInstalled(electronPlatformName, electronArc } } + // Why one package: @vscode/windows-process-tree is the only os: win32 npm addon; + // @orca/windows-registry is a workspace link present on every host, so its presence proves nothing. const missingWindowsAddons = [] - if (electronPlatformName === 'win32') { - for (const name of ['@vscode/windows-process-tree', 'windows-native-registry']) { - if (!isInstalled(name)) { - missingWindowsAddons.push(name) - } - } + if (electronPlatformName === 'win32' && !isInstalled('@vscode/windows-process-tree')) { + missingWindowsAddons.push('@vscode/windows-process-tree') } if (missing.length === 0 && missingWindowsAddons.length === 0) { return } - // Why separate remedies: install:release widens only the CPU set, so the os: win32 addons - // never arrive on a non-Windows host and are compiled only by the Windows-only rebuild. + // Why separate remedies: install:release widens only the CPU set, so the os: win32 addon + // never arrives on a non-Windows host and is compiled only by the Windows-only rebuild. const remedies = [] if (missing.length > 0) { remedies.push('Run pnpm install:release to install another architecture.') diff --git a/config/scripts/electron-builder-runtime-resources.test.mjs b/config/scripts/electron-builder-runtime-resources.test.mjs index f926b03d213..6eb34aff896 100644 --- a/config/scripts/electron-builder-runtime-resources.test.mjs +++ b/config/scripts/electron-builder-runtime-resources.test.mjs @@ -22,10 +22,11 @@ const { verifyPackagedMainRuntimeDeps } = require('../packaged-runtime-node-modules.cjs') -// Why not process.platform: the win32 plan resolves wherever its node-gyp addons are -// installed, which a cross-architecture release install can also produce off Windows. -const windowsAddonsInstalled = ['@vscode/windows-process-tree', 'windows-native-registry'].every( - (name) => existsSync(join(projectRoot, 'node_modules', name, 'package.json')) +// Why this and not process.platform: @vscode/windows-process-tree is the only os: win32 npm +// addon left, so its presence is what decides whether the win32 plan resolves. +// @orca/windows-registry is a workspace link present on every host, so it proves nothing. +const windowsAddonsInstalled = existsSync( + join(projectRoot, 'node_modules', '@vscode', 'windows-process-tree', 'package.json') ) describe('packaged runtime resources', () => { diff --git a/docs/reference/pnpm-install-policy.md b/docs/reference/pnpm-install-policy.md index 57ba55d9929..6e53ecac77a 100644 --- a/docs/reference/pnpm-install-policy.md +++ b/docs/reference/pnpm-install-policy.md @@ -30,18 +30,20 @@ broken. `beforePack` in therefore calls `assertPackagedNativeVariantsInstalled` in [`config/packaged-runtime-node-modules.cjs`](../../config/packaged-runtime-node-modules.cjs), which fails the build when the target platform/architecture's native variants -are not installed: `sherpa-onnx-*`, `@parcel/watcher-*`, and on Windows the two -node-gyp addons (`@vscode/windows-process-tree`, `windows-native-registry`). The -error names every missing package and gives the remedy that fits: another -architecture's variants come from `pnpm install:release`, the Windows addons do -not (see below). +are not installed: `sherpa-onnx-*`, `@parcel/watcher-*`, and on Windows the +node-gyp addon `@vscode/windows-process-tree`. The error names every missing +package and gives the remedy that fits: another architecture's variants come +from `pnpm install:release`, the Windows addon does not (see below). -Windows packaging requires a Windows host. The two addons are `os: win32` -packages, so they are installed only where that matches, and they are compiled -only by the Windows-only rebuild in `config/scripts/rebuild-native-deps.mjs` +Windows packaging requires a Windows host. `@vscode/windows-process-tree` is an +`os: win32` npm addon, so it is installed only where that matches; +`@orca/windows-registry` is a workspace package that links on every host, but +its native binary is still compiled only on Windows. Both are compiled only by +the Windows-only rebuild in `config/scripts/rebuild-native-deps.mjs` (`allowBuilds` in `pnpm-workspace.yaml` keeps pnpm itself from running node-gyp -for them). `pnpm install:release` does not help on macOS or Linux because it -does not widen the OS set. +for them). The guard checks `@vscode/windows-process-tree` alone because the +workspace link is present everywhere and proves nothing. `pnpm install:release` +does not help on macOS or Linux because it does not widen the OS set. Tests that inspect installed Windows addons and their packaging closure run on Windows, where those dependencies are required. The PR Windows lane explicitly