CodinGame / monaco-vscode-api

VSCode public API plugged on the monaco editor
MIT License
208 stars 29 forks source link

Bundle size too big #383

Closed Lemour-sudo closed 1 month ago

Lemour-sudo commented 3 months ago

I have been trying to add the monaco-editor to my application through the 'monaco-languageclient' and '@typefox/monaco-editor-react' but I realized a huge bump in the built bundle sizes -> an increase in about 10mb.

When running vite-bundle-visualizer in my project, it shows that 'vscode/src/vs' which corresponds to this library makes up 66% of the final bundle size.

Is there a way to avoid adding code that is not needed in order to just run the editor and a langium language worker?

CGNonofr commented 3 months ago

Is there a way to avoid adding code that is not needed in order to just run the editor and a langium language worker?

A lot of efforts have be done to keep that library as modular as possible, allowing to only use what is needed (that's why there are 50+ optional services overrides)

Using LSP requires the VSCode api, and it's not possible to make it as modular as the services (you can't easily just remove mainThread/extHost protocol handlers)

I'm open to any contribution to improve it

The 10mb you're talking about are minified?

Lemour-sudo commented 3 months ago

Got that. Yes the final 10mb is with the bundles minified.

Lemour-sudo commented 3 months ago

@CGNonofr is this library itself minifying? I can see that the minify is set to false in the rollup options but I am not sure what that means.

CGNonofr commented 2 months ago

Of course it's not, there's no point of minifying a library, it would just prevent the final minifier from doing an optimal job while making the debugging harder

CGNonofr commented 2 months ago

https://github.com/CodinGame/monaco-vscode-api/pull/416 may help

Lemour-sudo commented 2 months ago

Thanks! I am looking forward to the changes.

CGNonofr commented 2 months ago

and https://github.com/CodinGame/monaco-vscode-api/pull/417 as well

everything is released as part of the v5

Lemour-sudo commented 1 month ago

Thanks! Just saw about a 1mb drop in the final bundle size. I hope this helps in our overall application. So far, it looks like it will be worth breaking the language serve logic into its own compute platform from the Monaco editor UI itself.