monaco-languageclient icon indicating copy to clipboard operation
monaco-languageclient copied to clipboard

Monaco editor core compatibility

Open BusinessDuck opened this issue 3 years ago • 5 comments

The problem:

import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; cause error in typescript project with monaco-editor-core package only.

Hack solution:

tsconfig.json

"paths": {
    "monaco-editor/*": ["../node_modules/monaco-editor-core/*"]
}

Would you like to use monaco-editor package as peer-dependency? Also monaco-editor depends from monaco-editor-core, may be make a sense change types import to core?

BusinessDuck avatar May 31 '22 08:05 BusinessDuck

import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; cause error in typescript project with monaco-editor-core package only.

That's weird because this code shouldn't be in the output javascript

Also monaco-editor depends from monaco-editor-core, may be make a sense change types import to core?

monaco-editor-core is not a dependency of monaco-editor, it's just there during the build and everything is duplicated/built from it, so it's not possible

CGNonofr avatar May 31 '22 08:05 CGNonofr

We changed the dependency from monaco-editor-core to monaco-editor in the examples, because "limiting" the dependency to monaco-editor-core prevents users the simply include other monaco-editor features without requiring hacks.

Our reasoning was simple. You can achieve the same by importing a sub-set of monaco-editor instead of relying to monaco-editor-core.

kaisalmen avatar May 31 '22 08:05 kaisalmen

That's weird because this code shouldn't be in the output javascript

It's error from typing d.ts files. monaco-editor-core or monaco-editor should be a devDependency, because typing files (for developing mode) have imports from that module.

BusinessDuck avatar May 31 '22 08:05 BusinessDuck

It's error from typing d.ts files. monaco-editor-core or monaco-editor should be a devDependency

Thank you, this devDependency was never stated in the package.json of the lib (core or not), so at least I wasn't aware there was an impact beyond the examples.

kaisalmen avatar May 31 '22 08:05 kaisalmen

@BusinessDuck due to the latest changes with v2.0.0+ we have a direct dependency to monaco-editor. See npm list output with depth 1:

└─┬ [email protected] -> .\packages\client
  ├── @types/[email protected]
  ├── @types/[email protected]
  ├── @types/[email protected]
  ├── [email protected]
  ├── [email protected]
  ├─┬ [email protected]
  │ ├── [email protected]
  │ ├── [email protected]
  │ └── [email protected]
  ├── [email protected]
  ├── [email protected]
  └─┬ vscode@npm:@codingame/[email protected]
    └── [email protected]

We will add a workaround section to the README to make the problem visible to people, but we recommend to use monaco-editor and selectively import what is required.

kaisalmen avatar Jun 24 '22 11:06 kaisalmen

We have added a new Troubleshooting section in the README that also provides help regarding monaco-editor-core.

kaisalmen avatar Oct 19 '22 06:10 kaisalmen