Comments (21)
@hyrious
https://github.com/Cyberhan123/flat/blob/feature/render-vite/desktop/renderer-app/scripts/vite-plugin-electron.ts#L27
It's not enough,It still need to reslove events which in https://github.com/netless-io/flat/blob/main/desktop/renderer-app/src/api-middleware/smart-player.ts#L9
from flat.
This issue is representative.
As of electron@12, electron no longer recommends the use of nodejs(node / node library) and most electron api's in the renderer process.
So we now have a new task, which is to remove all the node(modules) api and some of the electron api from
renderer-app
We can use
IPC
orcontextBridge
instead.cc: @hyrious @Cyberhan123
I can write an new vite plugin to support fs-extra
, and next step we can remove all the node(modules) api and some of the electron api from renderer-app
, It may cost less
from flat.
good news render app has change to vite #1265, but I suggest to keep webpack, we may need reveal all the details
from flat.
Supporting BundleAnalyzerPlugin
is in low priority.
from flat.
what is vite electron plugin
?
from flat.
what is
vite electron plugin
?
vite not support electron-render target by default, we should transform electron package.
from flat.
okey
from flat.
vite not support electron-render target by default
That's true, but it's maybe not a big problem -- see my experimental repo.
The thing I didn't test is electron-builder -- I don't know if it requires some special code format like not using es modules. Having tracked this here: electron/electron#21457.
from flat.
Anyother task I missing?
from flat.
Anyother task I missing?
none
from flat.
vite not support electron-render target by default
That's true, but it's maybe not a big problem -- see my experimental repo.
The thing I didn't test is electron-builder -- I don't know if it requires some special code format like not using es modules. Having tracked this here: electron/electron#21457.
I found electron use require to get some file,the problem is more partial,If we use vite ,the building for development env
Spend time may not less than webpack
from flat.
If we only want fast bundling time, then we may choose esbuild.
Tree-shaking is even not a significant requirement, since in electron we always bundle all resources.
In fact, we are using vite because it brings really good dev experience.
from flat.
If we only want fast bundling time, then we may choose esbuild. Tree-shaking is even not a significant requirement, since in electron we always bundle all resources.
In fact, we are using vite because it brings really good dev experience.
As we all know, vite is esm bunlder,we have three way to reslove the commonjs model (electron,nodeBuildInModel,events), first is write commonjs
in code . It's easy but ugly.
second we can write vite plugin to transform the import
to require
,the last way is we can transform electron node to esm import.
And the last way is my choose, any comments? @hyrious @BlackHole1
from flat.
we can transform electron node to esm import
What's that mean? Can you provide some code examples?
from flat.
Wow, that sounds promising. I'm upvoting that.
Currently only the electron
module needs such hack. We can replace events
with eventemitter3
or emittery
or even the native EventTarget
, that's not a problem.
from flat.
Wow, that sounds promising. I'm upvoting that.
Currently only the
electron
module needs such hack. We can replaceevents
witheventemitter3
oremittery
or even the nativeEventTarget
, that's not a problem.
okkk
from flat.
fs-extra
is an tricky question,I have no idea to solve this problem. Can you guys give some inspiration?
from flat.
You can treat it as electron
, this is intended to write some node.js related logic at renderer side. In other words, we are violating the context isolation rule of electron. Let me tell you why:
-
The main reason of using electron, like other guys, is seemingly an easy way to write cross-platform desktop applications. Desktop applications can access the fs or do many other native things. Then why do we have to setup additional IPC to let another process doing some work? That should be a waste of code complexity.
-
The doc actually says:
prevent the website from accessing Electron internals
. You can see the purpose: some people are using electron to wrap websites into it. However, our app has different approaches in implementing native and web. -
Another main reason for using node modules at renderer side, is
agora-electron-sdk
currently work in this way.
from flat.
fs-extra
not same as electron .It's not build in model and if we exclude it vite will not handle the import.
from flat.
Then we may ask @BlackHole1 .
from flat.
This issue is representative.
As of electron@12, electron no longer recommends the use of nodejs(node / node library) and most electron api's in the renderer process.
So we now have a new task, which is to remove all the node(modules) api and some of the electron api from renderer-app
We can use IPC
or contextBridge
instead.
cc: @hyrious @Cyberhan123
from flat.
Related Issues (20)
- Can I install this app in HarmonyOS? HOT 2
- 如何自定义主题和UI? HOT 2
- 关于屏幕共享 HOT 2
- 回放页面无法监听到当前播放时间进度 HOT 4
- Ipad不支持屏幕共享吗 HOT 7
- 进入房间后开启录制,结束后回放的后半段是白屏。 HOT 6
- Run pnpm i failed. HOT 4
- Flat Desktop Client Now Available in Arch User Repository (AUR) HOT 4
- electron/js2c/renderer_init.js:93 Unable to load preload script: HOT 5
- Camera blank HOT 4
- [BUG](desktop/classroom-cloud): the subfiles and directories path do not match in classroom cloud setting of Desktop APP
- 开发环境一切正常-MAC打包后检测摄像头麦克风空白,权限提示没弹,MAC版本MACOS Monterey 12.6.7
- UPDATE_DOMAIN检查版本更新, 阿里云上怎么存放Windows 与 Mac 安装包格式 HOT 1
- Why phone number required? HOT 2
- 课堂开启录制报错,麻烦看一下 HOT 1
- Both chrome and edge browsers on Android don't work. HOT 5
- Is it possible to make hyperlinks in Word, PDF, PPT and Excel clickable? HOT 2
- Can I use it in the vue system built by npm? HOT 1
- error with Bluetooth HOT 3
- cannot resolve https://npmmirror.com/mirrors/electron/12.0.15/electron-v12.0.15-win32-x64.zip: status code 404 HOT 2
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 flat.