Skip to content
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

Electron support via a plugin #10341

Closed
4 tasks done
astoilkov opened this issue Oct 4, 2022 · 7 comments
Closed
4 tasks done

Electron support via a plugin #10341

astoilkov opened this issue Oct 4, 2022 · 7 comments

Comments

@astoilkov
Copy link

Description

For weeks now I've been struggling to move our Electron app to Vite.

When building for the Electron renderer process you need to handle: node imports, node: imports, node native modules, node globals, electron imports, electron imports in Web Workers. There are more, I just don't understand enough to list them.

If dev mode works, the build may not work (and vice-versa).

Suggested solution

I suggest Vite adds support for Electron via a plugin.

I realize that may be out of scope at least for now but at least people can find this issue and see a comment from the maintainers so they can decide on their next steps.

I will also share any significant progress I have in the comments.

Alternative

An open-source plugin/boilerplate by non-Vite maintainers could be a solution. There are currently some projects but I don't consider them mature — hard to work with, don't support a use case, and have bugs.

Additional context

I want to provide an overview of what I'm proposing:

Vite doesn't have any limitations for supporting Electron, it comes down to configuration. The Vite team is probably the most knowledgeable about what that configuration should be. I think it would be great for people to not spend a lot of time configuring Electron projects.

Validations

@bluwy
Copy link
Member

bluwy commented Oct 4, 2022

There's https://github.com/electron-vite/electron-vite-vue and I don't think it's immature. Electron support in Vite also isn't a configuration away, there are actual caveats Vite doesn't support due to Electron's nature of mixing both node and browser code. For example: #7821

@astoilkov
Copy link
Author

astoilkov commented Oct 4, 2022

Hey @bluwy. Thanks for answering so quickly.

I've been mainly experimenting with https://github.com/electron-vite boilerplates and the vite-plugin-electron-renderer plugin. I think they are close to being mature. I've logged three issues so far. One is resolved, the second needed additional configuration I couldn't figure out on my own, third is still pending.

Yep, you are right, it's not a configuration away. There needs to be a plugin for that. I realize it's not simple. I think I've oversimplified it in my initial explanation.

One of Vite's core values is simple configuration. Electron is hard to configure even with the already available plugin. We've struggled a lot with Webpack and I don't want to repeat the same mistakes.

Have you had any internal conversations about supporting Electron? It would be useful to know because I would be able to plan a little better. We will move to Vite regardless of this but I feel uncertainty on the other path. Also, I see an opportunity to make this easy for a lot of other people.

@astoilkov
Copy link
Author

I kept thinking about this.

What if you invite the people working on https://github.com/electron-vite to join Vite and move their repos here? They really might be close to being mature. If that's the case, this will be a win for the Electron community who will feel confident to rely on Vite. You will also be able to give them a little guidance on how the configuration can be simpler and the documentation a little clearer.

That's just a hypothetical that might spring new ideas. I hope I don't go overboard with these comments. 🙏

@bluwy
Copy link
Member

bluwy commented Oct 5, 2022

Have you had any internal conversations about supporting Electron? It would be useful to know because I would be able to plan a little better. We will move to Vite regardless of this but I feel uncertainty on the other path. Also, I see an opportunity to make this easy for a lot of other people.

We have a #native channel in the Vite discord server, but discussions among maintainers are rare since non of us use Electron, so we don't have any plans for first-class support (for now). Though we always encourage third-party support though and try to make APIs available to help the integration whenever possible.

What if you invite the people working on https://github.com/electron-vite to join Vite and move their repos here? They really might be close to being mature. If that's the case, this will be a win for the Electron community who will feel confident to rely on Vite. You will also be able to give them a little guidance on how the configuration can be simpler and the documentation a little clearer.

Following my previous point, we don't have experience with Electron so moving it into core is hard for us to maintain. It might even slow down the development as PRs and releases have to be done by us.

We currently do support ecosystem maintainers on discord though so there's direct communication with the core team. I think that's the best way forward. I'm not sure if @caoxiemeihao is in discord but we can definitely arrange an ecosystem role!

@caoxiemeihao
Copy link
Contributor

caoxiemeihao commented Oct 5, 2022

@astoilkov 👋

I've been mainly experimenting with https://github.com/electron-vite boilerplates and the vite-plugin-electron-renderer plugin. I think they are close to being mature. I've logged three issues so far. One is resolved, the second needed additional configuration I couldn't figure out on my own, third is still pending.

Regarding the last question you mentioned, I am Debugging on the Vite source code, and it should be found out by me soon. 🐥
The Electron + Vite solution has been explored, and what I can do is to devote my spare time to maintaining it until one day it becomes mature.


@bluwy 👋

We currently do support ecosystem maintainers on discord though so there's direct communication with the core team. I think that's the best way forward. I'm not sure if @caoxiemeihao is in discord but we can definitely arrange an ecosystem role!

I am honored to be in the role of ecosystem maintainer. 😄

@bluwy
Copy link
Member

bluwy commented Oct 6, 2022

Thanks for your efforts @caoxiemeihao on getting Electron support working! You can join http://chat.vitejs.dev (if you're not already in) and ping @patak in one of the channels, so we can add the role.

Closing this for now as we're not planning on first-class Vite plugin for Electron.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Oct 6, 2022
@astoilkov
Copy link
Author

Following my previous point, we don't have experience with Electron so moving it into core is hard for us to maintain. It might even slow down the development as PRs and releases have to be done by us.

Yep, this makes sense. If none of you use/understand Electron it's not viable. Please keep in mind this thread for the future. At some point, a new member can join that understands it. Electron isn't a small niche. Most people program on an Electron app (VSCode) and the GitHub repo has 104k stars.

Thanks for your efforts @caoxiemeihao on getting Electron support working! You can join http://chat.vitejs.dev (if you're not already in) and ping @patak in one of the channels, so we can add the role.

That is indeed great and will make it easier for Electron developers to choose https://github.com/electron-vite. @caoxiemeihao you can even mention your role in your repos readmes.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants