fix: replace simple-plist with plutil and fix Vite bundling for produ…#46
Open
blgn94 wants to merge 1 commit intopd4d10:mainfrom
Open
fix: replace simple-plist with plutil and fix Vite bundling for produ…#46blgn94 wants to merge 1 commit intopd4d10:mainfrom
blgn94 wants to merge 1 commit intopd4d10:mainfrom
Conversation
…ction builds ## Problem The packaged production build fails at runtime with two issues: 1. **`Cannot find module 'electron-squirrel-startup'`** — The Vite main config was externalizing all `dependencies` from [package.json](cci:7://file:///Users/Bilguun/development/projects/debugtron/package.json:0:0-0:0), but Electron Forge with the Vite plugin doesn't copy `node_modules` into the packaged app. This caused `electron-squirrel-startup` to be missing at runtime. 2. **`Could not dynamically require "bplist-creator"`** — The `simple-plist` package uses a UMD factory pattern that passes `require` as a function parameter, making it impossible for Rollup's CommonJS plugin to statically resolve its dependencies (`bplist-creator`, `bplist-parser`). ## Solution - **[vite.main.config.ts](cci:7://file:///Users/Bilguun/development/projects/debugtron/vite.main.config.ts:0:0-0:0)**: Changed `external` from `Object.keys(packageJson.dependencies)` to only `["registry-js"]` (the only true native module that must remain external). This ensures all pure JS dependencies are properly bundled by Vite. - **[src/main/targets/local/platforms/macos.ts](cci:7://file:///Users/Bilguun/development/projects/debugtron/src/main/targets/local/platforms/macos.ts:0:0-0:0)**: Replaced the `simple-plist` dependency with macOS's built-in `plutil -convert json` command via `child_process.execFile`. This is more reliable since: - `plutil` is always available on macOS - It handles both XML and binary plist formats natively - It eliminates the CommonJS/UMD bundling incompatibility entirely ## Testing - Built the app with `electron-forge make` on macOS (Apple Silicon) - Verified the app launches without module errors - Verified the local device app list loads correctly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ction builds
Problem
The packaged production build fails at runtime with two issues:
Cannot find module 'electron-squirrel-startup'— The Vite main config was externalizing alldependenciesfrom package.json, but Electron Forge with the Vite plugin doesn't copynode_modulesinto the packaged app. This causedelectron-squirrel-startupto be missing at runtime.Could not dynamically require "bplist-creator"— Thesimple-plistpackage uses a UMD factory pattern that passesrequireas a function parameter, making it impossible for Rollup's CommonJS plugin to statically resolve its dependencies (bplist-creator,bplist-parser).Solution
vite.main.config.ts: Changed
externalfromObject.keys(packageJson.dependencies)to only["registry-js"](the only true native module that must remain external). This ensures all pure JS dependencies are properly bundled by Vite.src/main/targets/local/platforms/macos.ts: Replaced the
simple-plistdependency with macOS's built-inplutil -convert jsoncommand viachild_process.execFile. This is more reliable since:plutilis always available on macOSTesting
electron-forge makeon macOS (Apple Silicon)