electron-vite / vite-plugin-electron

:electron: Electron⚡️Vite core repo
https://github.com/electron-vite
MIT License
665 stars 55 forks source link

Vite CJS Node API is deprecated #255

Open julien3 opened 6 days ago

julien3 commented 6 days ago

When I switched to Electron 28+, I followed the instructions here and added "type": "module" to package.json on my project.

Since then, my vite.config.ts is erroneous on VS Code due to the electron function call within the configuration:

This expression is not callable. Type 'typeof import("[...]/node_modules/vite-plugin-electron/dist/index")' has no call signatures.ts(2349)

When I build this project, I get a warning:

The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.

If I add "type": "module" to package.json on this project (plus minor import adjustments), my issue above gets fixed and VS Code doesn't complain anymore. Any reason both vite-plugin-electron and vite-plugin-electron-renderer don't include "type": "module" now Vite/Electron require it?

hifron commented 3 days ago

https://github.com/electron-vite/vite-plugin-electron/blob/v0.28.8/CHANGELOG.md