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

Switch from Webpack to Vite #2781

Merged
merged 77 commits into from
Apr 27, 2024
Merged

Switch from Webpack to Vite #2781

merged 77 commits into from
Apr 27, 2024

Conversation

joeyballentine
Copy link
Member

This was incredibly difficult to pull off and took 3 separate attempts (4 if you count me almost giving up during this attempt and basically starting over)

This required a bunch of prerequisite work to remove node-only code from the renderer and fixing a bunch of electron worst-practices. Not everything is currently perfect (we still need a bunch of polyfills for certain things and the way we do IPC is still technically not best-practice) but it is still better than it was before. This was necessary because unlike webpack, there was no option with Vite to just use the node libraries in the browser. This ultimately ended up being a good thing, because supposedly this all helps security.

The big win from switching to Vite though is the improved DX. Webpack + Babel is slow, Vite(esbuild) + SWC is really fast. Vite also has Hot Module Replacement which means the app doesn't have to reload everything when you make a change to a small component. Vite also allows hot-reloading the electron main process, so now we won't spend hours trying to figure out why our main process changes aren't working only to realize we never restarted the app.

There's still a few things left to complete on this before merging, but overall I'm super happy that we were able to pull this off as it will make chaiNNer development much better.

@RunDevelopment
Copy link
Member

Found a bug. If you make a new chain and press Ctrl+N, you'll get the "Are you sure?" alert twice. This bug doesn't happen on main.

@joeyballentine joeyballentine changed the title Switch from Webpack to Vite (WIP) Switch from Webpack to Vite Apr 12, 2024
@joeyballentine
Copy link
Member Author

And finally, this is finished.

@joeyballentine
Copy link
Member Author

Almost there. Last thing is to figure out what broke npm start...

@joeyballentine
Copy link
Member Author

joeyballentine commented Apr 26, 2024

You're just gonna have to be ok with index.html being in the root. There's probably some combination of configs that would allow us to easily have it in another folder, but i've wasted enough of my time trying to figure out what that is to justify it. It works fine like this.

@RunDevelopment RunDevelopment mentioned this pull request Apr 27, 2024
2 tasks
@joeyballentine joeyballentine merged commit 270ab74 into main Apr 27, 2024
20 checks passed
@joeyballentine joeyballentine deleted the vite-attempt-3 branch April 27, 2024 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants