Regression Issue with Universal Build Target in @electron-forge/plugin-webpack Since Version 7.3.0
Pre-flight checklist
- [X] I have read the contribution documentation for this project.
- [X] I agree to follow the code of conduct that this project uses.
- [X] I have searched the issue tracker for a bug that matches the one I want to file, without success.
Electron Forge version
7.3.0 to 7.5.0
Electron version
29
Operating system
MacOS 14.6.1
Last known working Electron Forge version
7.2.0
Expected behavior
The expected behavior is that electron-forge should correctly handle and combine the x64 and arm64 versions of native modules like electron-native-auth into a single universal binary, as it did in version 7.2.0.
Actual behavior
In electron-forge version 7.3.0 and later, the build process fails with an error stating that the "main/native_modules/build/Release/electron_native_auth.node" maps to multiple modules (x64 and arm64), but the modules do not map to the same native code after the rebuild.
By comparing the behavior between 7.2.0 and 7.3.0, I observed the following:
- In version
7.2.0, theelectron-forgepackaging process correctly combines thex64andarm64versions of the native module (electron-native-auth.node) into a single universal binary within the final.appbundle. The resulting.nodefile in the.appis over 200KB, indicating that it's properly combined, even though innode_modules/electron-native-auth/bin, there are only separatex64andarm64binaries (each around 60-90KB). - In version
7.3.0and later, the mapping code within the task responsible for handling native dependencies fails to combine these binaries, leading to a build error.
Steps to reproduce
- Have an Electron app that uses
electron-native-authas a native dependency. - Attempt to package the app using
electron-forgewith the@electron-forge/plugin-webpackand the--arch=universaltarget:
electron-forge package --arch=universal --platform=darwin
- Observe that the build fails with version
7.3.0and later, but works correctly with7.2.0.
Additional information
It seems that the regression is specifically tied to a change in the mapping logic introduced in version 7.3.0. The failure appears to be related to how the plugin manages the combining of x64 and arm64 native modules during the universal build process.
The exact error I'm getting is as follows:
Error: The "main/native_modules/build/Release/electron_native_auth.node" mapped to multiple modules "/Users/filemail/Desktop/FilemailDesktop/Filemail-Desktop-Electron/node_modules/electron-native-auth/bin/darwin-arm64-121/electron-native-auth.node, /Users/filemail/Desktop/FilemailDesktop/Filemail-Desktop-Electron/node_modules/electron-native-auth/build/Release/electron_native_auth.node" but the same modules post rebuild did not map to the same native code.
In the code it is located here: https://github.com/electron/forge/blob/1193d150b81e3b7867152e14d624621836969741/packages/plugin/webpack/src/WebpackPlugin.ts#L290
I think this might be a duplicate of #3526. 🤔
Closing as a duplicate