-
-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@electron-forge/plugin-vite can no longer build main module as ESM (breaking config change) #3715
Comments
Hi @ioV9x! Thanks for the report. From my initial read, I think this is a valid bug and we should take a look. |
After many hours, I have managed to get ESM compilation working based on electron-vite-samples found in #3572. Im not entirely sure what did it, however I am using version 7.5.0. https://gist.github.com/Denyol/ff9f1800f1c0d953a2eb69f47c143fd5 |
@Denyol please double check your logs. In my case the ESM and CJS builds race and I suspect that you just were lucky that the ESM build won the race. |
That is strange, I was experiencing some builds failing due to compiling as CJS, trying again and it works seemingly randomly. Please point me in the direction of where I could find build logs. |
We did not make any changes to the build format. 7.4.0 7.5.0 |
@caoxiemeihao as I stated in the opening post: I started with a template from 0.7.4 and I reconfigured vite to output ESM instead of CJS. The issue is not that a default or the template has changed, but that I can no longer override the default. Btw. GitHub shows a code preview for referenced code if (and only if) you reference it via the commit hash (this is what the -https://github.com/electron/forge/blob/v7.4.0/packages/template/vite/tmpl/vite.main.config.mjs#L17-L21
+https://github.com/electron/forge/blob/d3d47b2bc53be13609b5ff4d858275ce74bff819/packages/template/vite/tmpl/vite.main.config.mjs#L17-L21 |
forge/packages/plugin/vite/src/Config.ts Lines 3 to 17 in 7574b36
@caoxiemeihao Whether to make the |
Any updates? |
Pre-flight checklist
Electron Forge version
0.7.5
Electron version
32.1.1
Operating system
Windows 11
Last known working Electron Forge version
0.7.4
Expected behavior
I started with a template from 0.7.4 and I configured vite to output ESM like so (
I don't remember whether it was the default back then or not, it wasn't):I expect ESM only output and a working build.
Actual behavior
vite outputs both ESM and CJS to the same file whereas they sometimes contain artifacts of each other due to differing file lengths.
The build console output of
electron-forge start
points in this direction, too:However, final proof can be obtained by
and indeed I my build directory contains:
Steps to reproduce
See expected behaviour.
Additional information
I use a few vite ESM-only APIs (like
import.meta.glob()
) and therefore cannot switch to CJS.I noted that you dropped compatibility guarantees, but I thought that this would qualify as a breaking config change.
I highly suspect that other vite array-options can't be overwritten as well.
The text was updated successfully, but these errors were encountered: