forge icon indicating copy to clipboard operation
forge copied to clipboard

support top-level await in the main process when using the vite plugin

Open hab25 opened this issue 7 months 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 feature request that matches the one I want to file, without success.

Problem description

When I run my electron app that has some top-level await code and is bundled using the vite plugin, I get the following message in my console:

✓ 493 modules transformed.
Module format "cjs" does not support top-level await. Use the "es" or "system" output formats rather.
file: /home/hab25/my/work/react-electron-poc/src/main.ts

Proposed solution

Implementing this probably means implementing the following TODO:

https://github.com/electron/forge/blob/daa19d66333413f8a2ac44fabfb7dbee1eee6a50/packages/plugin/vite/src/VitePlugin.ts#L1

Alternatives considered

None

Additional information

No response

hab25 avatar May 21 '25 15:05 hab25

Hey @hab25, thanks for the report. As you mentioned in the issue, this is currently blocked on us upgrading our build system to type: module and upgrading to Vite 6. There's a bit of a chicken-and-egg issue right now with making breaking changes for Electron Forge 8 so there's some pending work that needs to be done beforehand. 🙇

erickzhao avatar May 21 '25 16:05 erickzhao