-
Notifications
You must be signed in to change notification settings - Fork 45
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
build: migrate to Vite for fast and smaller build #159
base: main
Are you sure you want to change the base?
Conversation
@MaikoTan Thanks for your contribution! 🌵🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I like the direction of this PR, and I'll do a more thorough review once you're done with changes and I can actually test it.
Things to test/verify:
- Changes to raidboss/oopsy data files (both timelines [.txt] and triggers [.ts]) properly trigger a reload when running with
npm run start
- Build artifact matches the same layout as the original build artifact (e.g. paths to HTML files are identical)
- Overlays work properly in both OverlayPlugin and normal browsers (edit:) both from local webserver and from disk
- raidemulator web worker for file import still functions properly
$ npm run tsc-no-emit
> [email protected] tsc-no-emit
> tsc --noEmit
Error: node_modules/vite/dist/node/index.d.ts(5,41): error TS2307: Cannot find module 'rollup/parseAst' or its corresponding type declarations.
Error: Process completed with exit code 2. To solve this problem, we'd have to set the |
I found that adding a simple |
Due to TS type resolution mechanism, I found that it is hard to maintain the original By the way, I found that the Build for GitHub Pages output
Is there any suggestion here? Ping @valarnin |
I don't think FCP is very important for overlays since the overlay is almost always served up locally and therefore there's not an issue with data transfer speed. Initial JS engine parsing takes a little bit longer for a single large file compared to smaller ~1mb bundles, but the performance hit is negligible. Using dynamic imports would cause potential delays when changing content and would require a lot of code changes and making stuff run as async that doesn't currently, that seems way out of scope for this PR. It might also cause really hard to diagnose issues if a user is pointing at the
The current release zip's I'm not sure if the |
Long story short: without source map:
with source map (which is used on github page)
|
In the past days it is not a bid deal as most players are running their overlays locally. But Their is iinact that is using our overlays from ghpages build causes some people sometimes hardly to load the overlay (which I heard mostly from China as they have politic network issues). I know this change is hard to made so it is just a "by-the-way", but you're right, it definitely causes delays if users met network issues no matter it is dynamic-imported or not. |
I know this is still WIP but figured I'd give a quick preliminary scan of the built artifact for potential problems. The generated artifact doesn't add the extra top-level
Running a diff of the list of files in the archive shows a couple points of concern: 165a168
> cactbot/cactbot/ui/common/vendor.bundle.js
183c190
< cactbot/cactbot/ui/oopsyraidsy/oopsy_live.bundle.js
---
> cactbot/cactbot/ui/oopsyraidsy/oopsy_common.css
184a192
> cactbot/cactbot/ui/oopsyraidsy/oopsyraidsy.bundle.js
186d193
< cactbot/cactbot/ui/oopsyraidsy/oopsy_summary.bundle.js
189d195
< cactbot/cactbot/ui/oopsyraidsy/oopsy_viewer.bundle.js
207d212
< cactbot/cactbot/ui/raidboss/raidemulator.worker.js
215d219
< cactbot/cactbot/ui/test/test.css
oopsyraidsy stuff seems to be completely rearranged. I think it's all there but it's hard to be sure without actually running/testing. It looks like all the typescript was rolled into a single
The raidemulator worker bundle seems to be MIA. Maybe it got bundled in with something else, but IIRC I had a lot of issues with getting it to run properly as a separate web worker thread in browsers if it wasn't isolated to its own source file. None of the overlays work when loaded from a <title>Cactbot Raidboss</title>
<script type="module" crossorigin src="/modulepreload-polyfill.bundle.js"></script> This is going to try and load This also holds true via an actual OverlayPlugin overlay:
Removing the |
Since we have already switched to chromium v95 for a long time, which has native support for ESM and modern JS syntaxes, and webpack is somehow discouraged these days as its slow-y and biggy code generation.
I did some research and then found that Vite (that uses rollup underhood) might be a great solution for us to switch to.
This preview PR shows how the Vite is faster and smaller comparing Webpack in the building.
Since Vite and Webpack are totally different tools, it is not able to copy the behaviours side by side. So what I am aiming is to create a result that functions as same as the user could expect.
Feel free to comment here if you have any thoughts