-
Notifications
You must be signed in to change notification settings - Fork 169
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
How to use pure ESM packages in Electron #35
Comments
@king514jy 随着 As update to 1.0.11, use import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin({ exclude: ['lowdb'] })],
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('lowdb')) {
return 'lowdb'
}
}
}
}
}
},
preload: {
plugins: [externalizeDepsPlugin()]
},
// ...
}) |
@alex8088 可以了 |
Describe the bug
Lowdb does not support CommonJS
Error [ERR_REQUIRE_ESM]: require() of ES Module E:\js\editor-client\node_modules.pnpm\registry.npmmirror.com+lowdb@3.0.0\node_modules\lowdb\lib\index.js from E:\js\editor-client\out\main\index.js not supported.
Instead change the require of E:\js\editor-client\node_modules.pnpm\registry.npmmirror.com+lowdb@3.0.0\node_modules\lowdb\lib\index.js in E:\js\editor-client\out\main\index.js to a dynamic import() which is available in all CommonJS modules.
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Object. (E:\js\editor-client\out\main\index.js:6:15)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at loadApplicationPackage (E:\js\editor-client\node_modules.pnpm\registry.npmmirror.com+electron@20.3.1\node_modules\electron\dist\resources\default_app.asar\main.js:110:16)
at Object. (E:\js\editor-client\node_modules.pnpm\registry.npmmirror.com+electron@20.3.1\node_modules\electron\dist\resources\default_app.asar\main.js:222:9)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Object. (node:electron/js2c/browser_init:185:3104)
at ./lib/browser/init.ts (node:electron/js2c/browser_init:185:3308)
at webpack_require (node:electron/js2c/browser_init:1:128)
at node:electron/js2c/browser_init:1:1200
at node:electron/js2c/browser_init:1:1267
at c._load (node:electron/js2c/asar_bundle:5:13343)
Electron-Vite Version
1.0.9
Electron Version
20.2.0
Vite Version
3.0.9
Validations
The text was updated successfully, but these errors were encountered: