flat icon indicating copy to clipboard operation
flat copied to clipboard

why is this js file so big?

Open shunyue1320 opened this issue 3 years ago • 3 comments

why is this js file so big? image

shunyue1320 avatar Jun 20 '22 09:06 shunyue1320

@hyrious

BlackHole1 avatar Jun 21 '22 03:06 BlackHole1

Because we didn't configure the manualChunks option in vite.config.ts. By default vite leaves it as empty (i.e. the same as rollup's default behavior). You can treat that as bundled all dependencies in node_modules. You can turn on the visualizer plugin to know what modules it includes.

Manually configuring chunks can be hard because you don't know which dependencies are not going to update. It could easily become a false-optimization.

Below are some important libraries that Flat is depending on, which should give you the reason about the vendors size:

package bundled size
agora-rtc-sdk-ng + agora-rtm-sdk 1.1 MB + 0.5 MB
white-web-sdk 2.3 MB
@netless/window-manager (video-js) 1 MB
@netless/app-slide (pixi-js) 1.6 MB
@netless/app-monaco (monaco-editor) 0.3 MB
antd + @ant-design/icons 1.2 MB + 0.7 MB

hyrious avatar Jun 21 '22 03:06 hyrious

Flat was created initially as an electron application which is filesize insensitive. We were focusing on product POC and tried to launch a workable product as fast as possible. After months of evolving we finally gained enough feedbacks from realworld tutors. The fundamental shap of Flat project I think has come to a level of stability.

Optimization is on the way and for a start, the giant refactoring PR that is merged yesterday splits the different functionalities into on-demand dynamic modules. This should improve the initial page load.

crimx avatar Aug 23 '22 02:08 crimx