convergencelabs / monaco-collab-ext

Adds collaborative editing capabilities to the Monaco Editor
https://convergencelabs.com
MIT License
220 stars 25 forks source link

Use 'monaco-editor/esm/vs/editor/editor.api' in monaco import #26

Open Aayush04 opened 2 years ago

Aayush04 commented 2 years ago

Hello, I am facing issue in building react application having this dependency. I am getting error in with the unnecessary monaco files which II guess not required for collab extension.

Module parse failed: Unexpected token (156:11)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|     dispose() {
|       onLanguageListener.dispose();
>       mode?.dispose();
|       mode = void 0;
|     }

If I rebuild the monaco-collab-ext with replacing import * as monaco from "monaco-editor" with import * as monaco from "monaco-editor/esm/vs/editor/editor.api" Then the above issue is not coming and everything works fine. So, my suggestion is why not to just import monaco api's instead of whole heavy monaco editor installation. If other things not required. Also, on searching everywhere the above error could also be solved by changing webpack configuration. But my doubt is why to go into hassle of changing/overriding webpack config, if it could easliy solve by importing monaco api only.

What is the opinion about this issue?

CGNonofr commented 2 years ago

I think you're just lucky that there is no recent syntaxes in the monaco editor api only, it may change in the future

Monaco editor doesn't transpile the code into old es5 anymore, so you have to do it yourself, and that's a good thing: you can decide your level of browser compatibility

Btw I still think it could be a good idea to not force the user to import everything from monaco