Skip to content

Commit 29ca538

Browse files
committed
precompile native modules
1 parent 6949cc3 commit 29ca538

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,29 @@ pnpm run typecheck # Type checking
3333
pnpm run lint # Linting
3434
```
3535

36+
### Building Distributables
37+
38+
To create production distributables (DMG, ZIP):
39+
40+
```bash
41+
# Package the app
42+
pnpm package
43+
44+
# Create distributables (DMG + ZIP)
45+
pnpm make
46+
```
47+
48+
Output will be in:
49+
- `out/Array-darwin-arm64/Array.app` - Packaged app
50+
- `out/make/Array-*.dmg` - macOS installer
51+
- `out/make/zip/` - ZIP archives
52+
53+
**Note:** Native modules for the DMG maker are automatically compiled via the `prePackage` hook. If you need to manually rebuild them, run:
54+
55+
```bash
56+
pnpm build-native
57+
```
58+
3659
### Environment Variables
3760

3861
You can set these environment variables instead of entering credentials in the app:

forge.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { execSync } from "node:child_process";
2+
import { existsSync } from "node:fs";
13
import { MakerDMG } from "@electron-forge/maker-dmg";
24
import { MakerZIP } from "@electron-forge/maker-zip";
35
import { VitePlugin } from "@electron-forge/plugin-vite";
@@ -18,6 +20,20 @@ const config: ForgeConfig = {
1820
}),
1921
new MakerZIP({}, ["darwin", "linux", "win32"]),
2022
],
23+
hooks: {
24+
prePackage: async () => {
25+
// Build native modules for DMG maker on Node.js 22
26+
const modules = ["macos-alias", "fs-xattr"];
27+
28+
for (const module of modules) {
29+
const modulePath = `node_modules/${module}`;
30+
if (existsSync(modulePath)) {
31+
console.log(`Building native module: ${module}`);
32+
execSync("npm install", { cwd: modulePath, stdio: "inherit" });
33+
}
34+
}
35+
},
36+
},
2137
plugins: [
2238
new VitePlugin({
2339
build: [

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"package": "electron-forge package",
1414
"make": "electron-forge make",
1515
"publish": "electron-forge publish",
16+
"build-native": "bash scripts/build-native-modules.sh",
1617
"typecheck": "tsc -p tsconfig.node.json --noEmit && tsc -p tsconfig.web.json --noEmit",
1718
"lint": "biome check --write --unsafe",
1819
"format": "biome format --write",

scripts/build-native-modules.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# Build native modules for DMG maker on Node.js 22
4+
# This script compiles macos-alias and fs-xattr native modules
5+
6+
set -e
7+
8+
echo "Building native modules for DMG maker..."
9+
10+
# Compile macos-alias
11+
if [ -d "node_modules/macos-alias" ]; then
12+
echo "Compiling macos-alias..."
13+
cd node_modules/macos-alias
14+
npm install
15+
cd ../..
16+
echo "✓ macos-alias compiled"
17+
else
18+
echo "⚠ macos-alias not found, skipping"
19+
fi
20+
21+
# Compile fs-xattr
22+
if [ -d "node_modules/fs-xattr" ]; then
23+
echo "Compiling fs-xattr..."
24+
cd node_modules/fs-xattr
25+
npm install
26+
cd ../..
27+
echo "✓ fs-xattr compiled"
28+
else
29+
echo "⚠ fs-xattr not found, skipping"
30+
fi
31+
32+
echo "✓ Native modules built successfully"

0 commit comments

Comments
 (0)