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

spike: Run maas-ui using Vite instead of CRA #4774

Closed
wants to merge 8 commits into from

Conversation

ndv99
Copy link
Contributor

@ndv99 ndv99 commented Feb 20, 2023

Note

This branch/PR is a spike - it is intended for the purposes of an experiment and is very buggy, and not to be merged.

Description

create-react-app is beginning to show its age - using webpack under the hood means that the entire application needs to be bundled before it can be served. You may have noticed how long maas-ui takes to spin up when you use dotrun or yarn start; this is a direct effect of this. As well as this, making changes to the source code requires this process to happen again, with changes being compiled first before being served.

Vite has a focus on speed and performance - using native ES modules, bundling before serving is no longer a required step. Source code is transformed and served by Vite on demand, based on browser requests. As well as this, Hot Module Replacement (HMR) to reflect code updates in the browser, which results in rapid reflection of changes made to the source code.

Although not an entirely trivial process, React applications created with CRA can be migrated to Vite without having to start over from scratch. This PR is a brief experiment to see how easy the process would be to migrate maas-ui over to Vite, and whether or not this would be a sensible change in our tooling for the future of maas-ui development.

Running this branch

To run this branch you'll first need to run yarn clean, followed by yarn to install changed dependencies. Once that's done, you should be able to just run yarn start and go to http://<your-ip>:8400.

@webteam-app
Copy link

Demo starting at https://maas-ui-4774.demos.haus

@ndv99 ndv99 marked this pull request as draft February 20, 2023 11:34
@petermakowski
Copy link
Contributor

This looks very promising! I opened a PR with a few fixes: ndv99#2

@petermakowski
Copy link
Contributor

One thing that we should look into is why the JS size seems to have increased with Vite and whether we could do anything about it.

CRA

build/static/js/main.d7bc04fd.js gzip: 595.71 kB
build/static/css/main.0cefe3c3.css gzip: 66.31 kB

Vite

build/assets/index-387abeac.css 518.78 kB │ gzip: 71.98 kB
build/assets/index-350c9bfb.js 2,177.33 kB │ gzip: 622.38 kB

CRA Vite
JS after gzip 595.71kB 622.38 kB

@ndv99
Copy link
Contributor Author

ndv99 commented Nov 10, 2023

Superseded by #5207

@ndv99 ndv99 closed this Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants