-
Notifications
You must be signed in to change notification settings - Fork 153
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
ESM not working with new electron #294
Comments
check out https://electron-vite.org/guide/troubleshooting.html#error-err-require-esm-require-of-es-module for more details |
I used fix-esm before, but it no longer works after v1.0.28. The official approach works fine. |
Hi, create a new project with "type": ""module" (in package.json) electron 28 fails on start with an error, because the whole project is esm based, but the bundle is common js. Overwriting the electron-vite config parts with "target": "module" also fails, because the outputformat of electron-vite was fixed to node* / commonjs This only happens, if a package.json with "target": "module" is within the parent path of the builded files. please enhance ecltron-vite allowto config the output format to output real esm files |
@ChrisKuBa |
Why in library mode? It also needs an entry prop or it's invalid. |
This does not work for me. import { resolve } from 'path';
import { defineConfig, externalizeDepsPlugin } from 'electron-vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
main: {
plugins: [ externalizeDepsPlugin() ],
build: {
lib: {
entry: './src/main/main.ts',
formats: ['es']
},
},
},
preload: {
plugins: [ externalizeDepsPlugin() ],
build: {
lib: {
entry: './src/preload/index.ts',
formats: ['es']
},
},
},
renderer: {
resolve: {
alias: {
'@utils': resolve('src/utils'),
'@globalTypes': resolve('src/types'),
'@api': resolve('src/api'),
'renderer': resolve('src/renderer/src'),
'types': resolve('src/renderer/src/types'),
'utils': resolve('src/renderer/src/utils'),
'components': resolve('src/renderer/src/components'),
'hooks': resolve('src/renderer/src/hooks'),
'features': resolve('src/renderer/src/features'),
},
},
plugins: [ react() ],
},
});
|
@Konglomneshued Enabled ESM support. For more details see the ESM limitations document. Note that preoload script will ignore |
Describe the bug
Electron now has esm builtin and when I tried it with that I get:
Electron-Vite Version
^1.0.28
Electron Version
^28.0.0-nightly.20230926
Vite Version
^4.4.9
Validations
The text was updated successfully, but these errors were encountered: