-
-
Notifications
You must be signed in to change notification settings - Fork 522
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
[Feature Request]: Migrate to using native ESM modules instead of CommonJS #3129
Comments
Per the upstream Electron issue about using ESM in apps --> electron/electron#21457 (comment) This isn't something that I would suggest people use let alone suggest we set it as a default. It's full of footguns even if you can make it work. Our guidance has always been and will remain:
|
Worth noting if you generate a forge app using the webpack typescript template you get |
Why? ESM is natively supported in browsers. You deliberately turn off the native feature? There are no commonjs modules in browsers. |
I think the reason for not supporting ESM is because it would be a MASSIVE undertaking to refactor the current electron / node codebase to support it. It would almost be easier to create electron from scratch than to support ESM modules in the current codebase. |
Like, executing "Find and Replace" using regexps? |
@paulmillr If you manage to find a trivial regexp solution that passes all our tests, PRs are always welcome into the main @MarshallOfSound's comments in the linked GitHub issue above describes the issue in more detail. There are more technical implications regarding the async nature of ESM entrypoints that breaks some guarantees from Electron's boot flow. If you want to read through the full text: electron/electron#21457 (comment)
electron/electron#21457 (comment)
|
@erickzhao Appreciate the clarification. It was hard to find something in the thread. |
No specific documentation available! When using the sveltekit, Forge.config.js cannot be loaded correctly and should not be an es module. If you close this issue, it's best to have an alternative solution |
I'm using the webpack-typescript template of electron-forge and I noticed it compiles both the renderer and main .ts code to commonjs, but as far as I know, if I'm not using node integration in the renderer process there should be not problem using ES modules there. Can anyone provide me with the correct configuration to make this happen while using webpack and typescript? In short, I want to use ES modules in the renderer and commonjs in the main process while using typescript |
Pre-flight checklist
Problem description
Right now when you create a new Electron app using Forge
npm init electron-app@latest my-app
it still uses the old CommonJS require statements. Node has had native ESM module support for a long time and it just makes sense to switch to it so it is more modern and the Javascript community has moved to it.Current app genereted with Forge:
Proposed solution
Use modern native ESM modules instead:
Alternatives considered
There are no alternatives.
Additional information
No response
The text was updated successfully, but these errors were encountered: