Repository navigation
fix(packaging): prune non-target native binaries - #12174
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe packaging runtime now normalizes Electron architecture values, including numeric enums and 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR adds architecture-aware pruning of native binaries during Electron packaging to fix a Rosetta deprecation warning on Apple Silicon. Previously, the pruner kept all same-platform prebuilds (e.g., both
Confidence Score: 5/5Safe to merge. The pruning functions are additive restrictions on what survives packaging; at worst a misconfiguration would prune too aggressively, causing a startup crash caught at packaging time, rather than shipping wrong binaries silently. The two changed files contain tightly scoped build-time pruning logic with no runtime surface. The new normalizeElectronArchitecture helper handles all enum and string variants correctly. Both prebuilds/ and bin/ pruning use exact-prefix matching with clearly tested edge cases. The Linux libc suffix logic correctly preserves glibc/musl variants while dropping wrong-arch packages. Files Needing Attention: No files require special attention. Both files are well-tested and the changes are isolated to build-time packaging helpers.
|
| Filename | Overview |
|---|---|
| config/packaged-runtime-node-modules.cjs | Core pruning logic: adds architecture-aware filtering for node-pty prebuilds/bin and @parcel/watcher subpackages. Logic is correct, including Linux libc suffix handling and validation that rejects universal and unknown architectures. |
| config/scripts/electron-builder-config.test.mjs | Test coverage updated to pass numeric Arch enum values, verify bin/ directory pruning, assert universal arch rejection, and add arch: 1 to the afterPack fixture (required since prunePackagedRuntimeNodeModules now validates the arch before reading the filesystem). |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[afterPack context.arch] --> B[prunePackagedRuntimeNodeModules]
B --> C[normalizeElectronArchitecture]
C -- number enum --> D{ELECTRON_ARCHITECTURE_BY_ENUM lookup}
C -- armv7l string --> E[map to 'arm']
C -- other string --> F[pass through]
D --> G{in PACKAGED_NATIVE_ARCHITECTURES?}
E --> G
F --> G
G -- no: universal/unknown --> H[throw Unsupported packaged runtime architecture]
G -- yes: ia32/x64/arm/arm64 --> I[normalized architecture string]
I --> J[prunePackagedNodePty]
I --> K[prunePackagedParcelWatcher]
J --> L[pruneNodePtyNativeDirectories prebuilds/ exact match]
J --> M[pruneNodePtyNativeDirectories bin/ suffix match]
J --> N{win32?}
N -- yes --> O[ensurePackagedNodePtyConptyRuntime]
N -- no --> P[rmSync third_party/conpty + deps/winpty]
K --> Q[targetPrefix = keepPrefix + arch]
Q --> R{matches targetPrefix or targetPrefix- suffix?}
R -- no --> S[rmSync non-matching watcher- subpackage]
R -- yes --> T[keep]
Reviews (1): Last reviewed commit: "fix(packaging): prune non-target native ..." | Re-trigger Greptile
Summary
Problem
The Apple-silicon app bundled unused x86_64-only node-pty and Parcel watcher files. macOS detected those Intel components and displayed a Rosetta deprecation warning even though Orca and the native modules it actually loaded were arm64.
Validation