Open codec-xyz opened 1 month ago
@codec-xyz I have found the same inconsistent behavior and to be honest I just tried every which combination until something was working for us (but feels very fragile and certainly not ideal long term). For us we went with using forge.config.cts
and had to set module: commonjs
which is not what we want overall but works for us right now. As you can see by my comments in the screenshot below, we also could not get ESNext
to work which is what led us to settling on commonjs
.
I believe it is related to:
@codec-xyz I am just glad I am not crazy and that you came to the same conclusion as me! I spent way too many hours (days) trying to figure this out and the imposter syndrome was starting to become real strong for me! haha
I also encountered this problem. When I wanted to migrate to ESM according to the latest version of electron-store, I found that forge.config.ts did not support ESM.
Using the template shared in the issue below worked for me initially, But later I needed to change the preload script output to cjs and moduleResolution to Node because some issues started showing up, Not sure if it was a problem on my end but with those changes everything seem to work fine.
https://github.com/electron/forge/issues/3502#issuecomment-2211449451
Having the same issue.
Pre-flight checklist
Electron Forge version
7.4.0
Electron version
v31.3.1
Operating system
Windows 11
Last known working Electron Forge version
No response
Expected behavior
To not get an error when using a Typescript ESM forge.config.ts.
Actual behavior
Error are listed under the steps to reproduce section.
Steps to reproduce
Run
npm init electron-app@7.4.0 my-new-app -- --template=vite-typescript
Add
"type": "module",
topackage.json
Run
npm run start
This result in this error...
However changing
forge.config.ts
toforge.config.js
(and removing the type definitions) makes the error go away. So seemingly JS ES modules work but TS ES modules do not work.Another option is changing the
forge.config.ts
to aforge.config.cts
but it does not work with"module": "ESNext"
(or other ES module options) in thetsconfig.json
which gives the error...Additional information
No response