From 40c47fbeb3e82774c8d89347785c4f7ed8cf326a Mon Sep 17 00:00:00 2001 From: claude-bot Date: Mon, 18 May 2026 02:14:55 +0900 Subject: [PATCH] build: bundle sharp's win32-x64 prebuilt for Windows packaging The packaged installer-rp crashed on launch with "Could not load the 'sharp' module using the win32-x64 runtime" because electron-builder ran on Linux and only the Linux sharp variants were present in node_modules. - Add `preinstall:sharp-win32` script that force-installs `@img/sharp-win32-x64@0.34.5` into the local node_modules (npm refuses it on Linux without --force due to its os/cpu restrictions). - Chain that script before both `dist:win` and `dist:win:rp` so future Windows builds always have the native prebuilt available. - Exclude `@img/sharp-{,libvips-}linux*` from the packaged files list in both electron-builder configs so the unused Linux variants don't bloat the portable exe. Verified `release/win-unpacked/resources/app.asar.unpacked/node_modules/ @img/sharp-win32-x64/lib/sharp-win32-x64.node` is present and that no linux sharp variants ship inside the asar. Co-Authored-By: Claude Opus 4.7 --- electron-builder-rp.yml | 6 ++++++ electron-builder.yml | 6 ++++++ package.json | 5 +++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/electron-builder-rp.yml b/electron-builder-rp.yml index b5b6c51..68879da 100644 --- a/electron-builder-rp.yml +++ b/electron-builder-rp.yml @@ -13,6 +13,12 @@ files: - installer-rp/** - build/icon.* - package.json + # sharp 는 플랫폼별 prebuilt 가 분리 패키지로 배포됨. Windows 빌드에서는 + # win32-x64 만 포함하고 linux/* 변종은 묶지 않아 exe 크기를 줄임. + - "!node_modules/@img/sharp-linux-*" + - "!node_modules/@img/sharp-linuxmusl-*" + - "!node_modules/@img/sharp-libvips-linux-*" + - "!node_modules/@img/sharp-libvips-linuxmusl-*" # 메인 설치기와 동일하게 빌드 전용 `.env.build` 와 locales 를 함께 배포. extraResources: - from: . diff --git a/electron-builder.yml b/electron-builder.yml index 4cd0657..47135ac 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -9,6 +9,12 @@ files: - installer/** - build/icon.* - package.json + # sharp 는 플랫폼별 prebuilt 가 분리 패키지로 배포됨. Windows 빌드에서는 + # win32-x64 만 포함하고 linux/* 변종은 묶지 않아 exe 크기를 줄임. + - "!node_modules/@img/sharp-linux-*" + - "!node_modules/@img/sharp-linuxmusl-*" + - "!node_modules/@img/sharp-libvips-linux-*" + - "!node_modules/@img/sharp-libvips-linuxmusl-*" # 빌드 전용 `.env.build` 를 설치기 옆에 함께 배포(없으면 조용히 패스). # `.env` 는 서버/개발 실행용이라 빌드 산출물에는 포함되지 않으며, 패키지된 exe # 는 `resources/.env.build` 를 우선 로드함(없으면 `resources/.env` 로 폴백). diff --git a/package.json b/package.json index ea860cf..6244452 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,9 @@ "dev:server": "tsc -p tsconfig.server.json && node dist/server/app.js", "installer": "tsc -p tsconfig.installer.json && electron .", "installer:rp": "tsc -p tsconfig.installer-rp.json && electron dist/installer-rp/main.js", - "dist:win": "tsc -p tsconfig.installer.json && electron-builder --win --config electron-builder.yml", - "dist:win:rp": "tsc -p tsconfig.installer-rp.json && electron-builder --win --config electron-builder-rp.yml" + "preinstall:sharp-win32": "npm install --no-save --force @img/sharp-win32-x64@0.34.5", + "dist:win": "npm run preinstall:sharp-win32 && tsc -p tsconfig.installer.json && electron-builder --win --config electron-builder.yml", + "dist:win:rp": "npm run preinstall:sharp-win32 && tsc -p tsconfig.installer-rp.json && electron-builder --win --config electron-builder-rp.yml" }, "dependencies": { "@types/archiver": "^7.0.0",