using `electron/universal`, some modules do not rebuild according to `arch`
- Dominant language
- TypeScript
- Stars
- 7.1k
- Forks
- 641
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 30
Description
### Pre-flight checklist
- [x] I have read the [contribution documentation](https://github.com/electron/forge/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) 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.4.0
### Electron version
v24.1.1
### Operating system
macOS 11.3.1
### Last known working Electron Forge version
--
### Expected behavior
Using `electron/universal` configured with `osxUniversal` in forge config, we expect all dependent modules will receive the correct `arch` and build themselves accordingly.
### Actual behavior
We are using `ffmpeg-static` in our Electron app, but when the universal build is created, only the arm64 ffmpeg binary exists. I have confirmed that the `ffmpeg-static` module can be rebuilt in CLI with an `arch` param (`npm rebuild --arch=x64 -f ffmpeg-static` and confirmed with `file node_modules/ffmpeg-static/ffmpeg`). In this case the correct binary is build/fetched. But when running the universal build with forge, only `os.arch()` seems to be respected, which in this case is an M1 machine.
It seems electron-forge isn't passing the correct arch to dependencies. If there were hooks in the universal build process, or some env vars set, I could manually rebuild this one ffmpeg module according to an arch. For example `ffmpeg-static` does obey `process.env.npm_config_arch`, so if I were able to set that in between the x64 and arm64 builds (or electron/universal did), the module would build the correct ffmpeg binary.
I have attempted using hooks in electron-forge to try and switch based on `arch`, but that value is always `universal`. Also, building the app on separate Intel and M1 machines does produce the appropriate ffmpeg binary.
### Steps to reproduce
Set up a project with `electron-forge` and `ffmpeg-static`, then attempt a universal Mac build.
### Additional information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.