Skip to content

fix: replace simple-plist with plutil and fix Vite bundling for produ…#46

Open
blgn94 wants to merge 1 commit intopd4d10:mainfrom
blgn94:fix/plutil-and-vite-production-bundle
Open

fix: replace simple-plist with plutil and fix Vite bundling for produ…#46
blgn94 wants to merge 1 commit intopd4d10:mainfrom
blgn94:fix/plutil-and-vite-production-bundle

Conversation

@blgn94
Copy link

@blgn94 blgn94 commented Feb 11, 2026

…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, 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: 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: 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

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments