Comments (4)
May be neet remove the following options.
electron-vite-react/vite.config.ts
Line 48 in 63cef88
This options will cause Rollup to build code in
cjs
format. 👉 Config presets (Opinionated)After removing this option, Rollup will use the
esm
format to build the code by default, which can avoid the require
in the bundle code.from electron-vite-react.
Unfortunately, some of Electrons scripts use path
and those (specifically, node_modules/electron/index.js
) get included into the app.<hash>.js
bundle, causing an error because path is not available with node integration turned off.
Edit: I am using nativeImage
, which according to the Electron docs can be used in the renderer process (so even with nodeIntegration turned off, as I currently do with webpack) but with Vite, that fails with the "path" error:
Uncaught Error: Module "path" has been externalized for browser compatibility. Cannot access "path.join" in client code.
at Object.get (browser-external:path:9:13)
at node_modules/electron/index.js (index.js:4:23)
at __require (chunk-CYSXIT7F.js?v=b28474e4:8:50)
at dep:electron:1:16
Edit2: Seems I can work around this by making nativeImage
available in the preload script and using it from there.
Bottom line: It would be nice if multiple entry points also worked with the electron-vite-renderer module.
from electron-vite-react.
In fact, if nodeIntegration
is not enabled, even the require
function cannot be used, although we can use the following to avoid Vite Pre-Bundling node_modules/electron/index.js
, but in the where the require
function is not available Down. We still can't use any exported members of electron
.
// e.g. renderer.js
const { nativeTheme } = require('electron')
// Uncaught ReferenceError: require is not defined
from electron-vite-react.
Now [email protected]
is based on the vite-electron-plugin
, This is broke!
from electron-vite-react.
Related Issues (20)
- Running multiple instances on the background HOT 4
- BrowserWindow.loadfile not seeing route HOT 1
- [dev] `tailwindcss --watch && vite` will block running on Windows HOT 1
- [BUG] Some WASMs are failed to obtain HOT 1
- [BUG] No response after running, application does not pop up
- in linux unbuntu 20: equestError: socket hang up │ at ClientRequest. HOT 1
- How to use `utilityProcess` in this template? HOT 3
- 编译better-sqlite3不成功 HOT 3
- pakage.json 中 react 置于 devDependencies 的疑问
- 当 contextIsolation: true, nodeIntegration: false 时,控制台报错 HOT 1
- 如何引入sqlite3 HOT 1
- 麻烦 升级下 package.json 里的包 , 谢谢 HOT 1
- 我有2个屏幕, 屏幕1 写代码, 屏幕2 放 app预览窗口,每次修改 主进程代码 后, 新生成的app 都会出现在屏幕1,并且会把焦点给切过去 HOT 2
- 提交到 awesome-electrion HOT 1
- Unable to use koa packages HOT 5
- Run npm run dev under wayland with wayland flags HOT 2
- 构建Windows客户端后打开wouter显示空白,且没有任何报错,但在开发环境下运行正常,wouter是一个类似react-router的路由框架 HOT 1
- Unable to build HOT 4
- [Help] @react-pdf_renderer bug HOT 2
- [Help] Failed preload + window.ipcRenderer is undefined HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-vite-react.