forge icon indicating copy to clipboard operation
forge copied to clipboard

Regression Issue with Universal Build Target in @electron-forge/plugin-webpack Since Version 7.3.0

Open Rychu-Pawel opened this issue 1 year ago • 1 comments

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, the electron-forge packaging process correctly combines the x64 and arm64 versions of the native module (electron-native-auth.node) into a single universal binary within the final .app bundle. The resulting .node file in the .app is over 200KB, indicating that it's properly combined, even though in node_modules/electron-native-auth/bin, there are only separate x64 and arm64 binaries (each around 60-90KB).
  • In version 7.3.0 and 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

  1. Have an Electron app that uses electron-native-auth as a native dependency.
  2. Attempt to package the app using electron-forge with the @electron-forge/plugin-webpack and the --arch=universal target:
electron-forge package --arch=universal --platform=darwin
  1. Observe that the build fails with version 7.3.0 and later, but works correctly with 7.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

Rychu-Pawel avatar Sep 25 '24 12:09 Rychu-Pawel

I think this might be a duplicate of #3526. 🤔

tofumatt avatar Oct 15 '24 20:10 tofumatt

Closing as a duplicate

VerteDinde avatar Nov 20 '24 22:11 VerteDinde