Skip to content
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

Using ESM in Webpack-TypeScript Template #3780

Open
3 tasks done
fras2560 opened this issue Dec 10, 2024 · 1 comment
Open
3 tasks done

Using ESM in Webpack-TypeScript Template #3780

fras2560 opened this issue Dec 10, 2024 · 1 comment

Comments

@fras2560
Copy link
Contributor

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

7.6.0

Electron version

33.2.1

Operating system

macOS Sequoia 15.1

Last known working Electron Forge version

No response

Expected behavior

Able to start the template

Actual behavior

npm run start

fresh@1.0.0 start
electron-forge start

✔ Checking your system
✔ Locating application
✖ Loading configuration

1. Must use import to load ES Module: /fresh/forge.config.ts
require() of ES modules is not supported.
require() of /resh/forge.config.ts from
/fresh/node_modules/@electron-forge/core/helper/dynamic-import.js is an ES module file as
it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES
modules.
Instead change the requiring code to use import(), or remove "type": "module" from
/Users/dallas/Documents/Github/electron-test/fresh/package.json.
2. Unknown file extension ".ts" for /fresh/forge.config.ts
◼ Preparing native dependencies
◼ Running generateAssets hook
◼ Running preStart hook

Failed to load: fresh/forge.config.ts

An unhandled rejection has occurred inside Forge:
Error:

  1. Must use import to load ES Module: /fresh/forge.config.ts
    require() of ES modules is not supported.
    require() of /fresh/forge.config.ts from /fresh/node_modules/@electron-forge/core/helper/dynamic-import.js is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
    Instead change the requiring code to use import(), or remove "type": "module" from /fresh/package.json.

  2. Unknown file extension ".ts" for /fresh/forge.config.ts

Steps to reproduce

Run npm init electron-app@7.4.0 my-new-app -- --template=vite-typescript

Add "type": "module", to package.json

Now run npm start

Additional information

I am investigating a project and the work required to update to ESM. Since electron-store is a native ESM now and using an older version of the store. I was running into some issue with the project when following

https://www.electronjs.org/docs/latest/tutorial/esm
https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

I tried implementing the various suggestions seen in

#3671
#3684

@fras2560
Copy link
Contributor Author

Opening this issue since I cannot find a way to use ESM with the Webpack-Typescript template. Just looking for the steps to make the template work before trying on a larger project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant