Open
Description
Hi wonderful team making the new electron start sooooo easy!
I've started a new project last week, and when importing 'electron-store' in the renderer, the following issue happen.
'electron-store' v10 is now pure ESM, which why adding 'electron-store': { type: 'cjs' },
did change the error but did not solve it (neither 'type: esm', : require is not defined
)
It seems there were already fixes for electron-store
ESM v10 but all the examples and docs are for the CJS v8 package and the default config changes don't seems to work for me.
Uncaught Error: Dynamic require of "process" is not supported
at chunk-UN725CXD.js?v=f7b7e0dc:15:9
at electron-store.js?v=f7b7e0dc:14821:11
--- electron-store.js
// node_modules/.vite-electron-renderer/process.mjs
var avoid_parse_require = __require;
var _M_ = avoid_parse_require("process");
--- chunk-UN725CXD.js
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
Related lib:
"electron": "^30.0.1",
"electron-builder": "^24.13.3",
"electron-rebuild": "^3.2.9",
"typescript": "^5.2.2",
"vite": "^5.1.6",
"vite-plugin-electron": "^0.28.6",
"vite-plugin-electron-renderer": "^0.14.5"
"better-sqlite3": "^11.7.0",
"electron-store": "^10.0.0",
vite.config.js
import { defineConfig } from 'vite'
import path from 'node:path'
import electron from 'vite-plugin-electron/simple'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
react(),
electron({
main: {
entry: 'electron/main.ts',
vite: {
build: {
rollupOptions: {
external: [
'better-sqlite3'
],
},
}
},
},
preload: {
input: path.join(__dirname, 'electron/preload.ts'),
},
renderer: process.env.NODE_ENV === 'test'
// https://github.com/electron-vite/vite-plugin-electron-renderer/issues/78#issuecomment-2053600808
? undefined
: {},
}),
],
})
Metadata
Metadata
Assignees
Labels
No labels