TypeFox / monaco-languageclient

Repo hosts npm packages for monaco-languageclient, vscode-ws-jsonrpc, monaco-editor-wrapper, @typefox/monaco-editor-react and monaco-languageclient-examples
https://www.npmjs.com/package/monaco-languageclient
MIT License
1.04k stars 178 forks source link

Monaco editor core compatibility #371

Closed BusinessDuck closed 1 year ago

BusinessDuck commented 2 years ago

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?

CGNonofr commented 2 years ago

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

kaisalmen commented 2 years ago

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.

BusinessDuck commented 2 years ago

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.

kaisalmen commented 2 years ago

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 commented 2 years ago

@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:

└─┬ monaco-languageclient@2.0.2 -> .\packages\client
  ├── @types/glob-to-regexp@0.4.1
  ├── @types/node@16.11.7
  ├── @types/vscode@1.68.0
  ├── glob-to-regexp@0.4.1
  ├── vscode-jsonrpc@8.0.1
  ├─┬ vscode-languageclient@8.0.1
  │ ├── minimatch@3.1.2
  │ ├── semver@7.3.7
  │ └── vscode-languageserver-protocol@3.17.1
  ├── vscode-languageserver-textdocument@1.0.5
  ├── vscode-uri@3.0.3
  └─┬ vscode@npm:@codingame/monaco-vscode-api@1.68.4
    └── monaco-editor@0.33.0

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 commented 1 year ago

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

amardeep911 commented 4 months ago

I tried changing tsconfig.json, still it showing error. Screenshot 2024-05-04 at 4 08 54 PM Screenshot 2024-05-04 at 4 09 40 PM

kaisalmen commented 4 months ago

Hi @amardeep911 this is outdated, please look here and take a look at the examples described here.