monaco-collab-ext icon indicating copy to clipboard operation
monaco-collab-ext copied to clipboard

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

Open Aayush04 opened this issue 3 years ago • 1 comments

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?

Aayush04 avatar Nov 21 '22 17:11 Aayush04

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

CGNonofr avatar Nov 21 '22 17:11 CGNonofr