Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

monaco-treemending with Yarn package manager #21

Closed
jeremiah-blezing opened this issue May 21, 2023 · 6 comments
Closed

monaco-treemending with Yarn package manager #21

jeremiah-blezing opened this issue May 21, 2023 · 6 comments

Comments

@jeremiah-blezing
Copy link

jeremiah-blezing commented May 21, 2023

Description

When installing monaco-editor-wrapper@2.0.0-next.5 with yarn, a postinstall : monaco-treemending script is run and it shows the command is not found.
image

It seems the latest commit removed postinstall : monaco-treemending script in this repository, but the changes are not released yet.

Peer Dependency Issue

When I traced the Peer Dependencies of monaco-editor-wrapper@2.0.0-next.5 to the monaco-treemending script, it went like

monaco-editor-wrapper@2.0.0-next.5 👉 monaco-languageclient@6.0.1 👉 @codingame/monaco-vscode-api@~1.78.6

I could see the actual monaco-treemending js script is present only in the @codingame/monaco-vscode-api@~1.78.6 package, not in any of the other packages.

Now coming to the issue, when installing monaco-editor-wrapper, npm is somehow looking into the peer dependencies and executing the bin scripts from @codingame/monaco-vscode-api@~1.78.6 , but this is not the case for yarn. Yarn is only looking in that package and avoiding the peer dependencies(I guess).

Because of this, yarn becomes unusable with the latest monaco-languageclient packages.

To Reproduce

yarn create vite

Choose any Framework and try the below command

yarn add monaco-editor-wrapper@2.0.0-next.5

(or)

yarn add monaco-languageclient@6.0.1

Question

Do we need postinstall : monaco-treemending script in monaco-languageclient package? As it is already taken care of by @codingame/monaco-vscode-api and only that package has the js script to run...

Thanks.

@kaisalmen
Copy link
Collaborator

kaisalmen commented May 22, 2023

Hi @jeremiah-blezing I have released an new next version: monaco-editor-wrapper@2.0.0-next.6.
But the problem persists with yarn. I don't know why yarn behaves differently then npm with regard to binary execution. Is there a way to enforce peer dependency installation with yarn?

The only way I currently see is to add @codingame/monaco-vscode-api and monaco-editor first and add "postinstall": "monaco-treemending" and afterwards remove the script and use --ignore-scripts when you add the missing packages.

Btw, there is currently an issue when you run the treemeding script twice, see open PR

Is it possible for you to use npm instead of yarn as a workaround?

@jeremiah-blezing
Copy link
Author

jeremiah-blezing commented May 22, 2023

Hi @kaisalmen ,

The only way I currently see is to add @codingame/monaco-vscode-api and monaco-editor first and add "postinstall": "monaco-treemending" and afterwards remove the script and use --ignore-scripts when you add the missing packages.

Yes, this is working. I guess this won't work in CI build.

Is it possible for you to use npm instead of yarn as a workaround?

Our Codebase is a little big, will be difficult to switch the package manager. It's fine for now. We wrote a custom wrapper with monaco-languageclient@5.0.1 and used the appropriate versions of monaco-editor and vscode-ws-jsonrpc.

Is there a way to enforce peer dependency installation with yarn?

I guess (not sure) that this is not an issue with Peer Dependency Installation but with bin file resolution of Peer Dependency that has a package alias that is being used in monaco-languageclient ( here ) . That's my guess when playing around with multiple installation scenarios.

Btw, there is currently an issue when you run the treemeding script twice, see open CodinGame/monaco-vscode-api#115

Saw that, I think even after that, this issue will be still there.

@kaisalmen
Copy link
Collaborator

Our Codebase is a little big, will be difficult to switch the package manager.

@jeremiah-blezing I was expecting that. 🙂

I guess (not sure) that this is not an issue with Peer Dependency Installation but with bin file resolution of Peer Dependency that has a package alias that is being used in monaco-languageclient ( here ) That's my guess when playing around with multiple installation scenarios.

I have released a next version of monaco-languageclient that defines the dependencies as such:

  "dependencies": {
    "vscode": "npm:@codingame/monaco-vscode-api@~1.78.6",
    "vscode-jsonrpc": "~8.1.0",
    "vscode-languageclient": "~8.1.0"
  },
  "peerDependencies": {
    "vscode": "npm:@codingame/monaco-vscode-api@~1.78.6"
  },
  "peerDependenciesMeta": {
    "vscode": {
      "optional": false
    }
  }

In the past we defined monaco-vscode-api as regular and peer dependency. Defining it only as peerDependency works fine with npm 7+, but yarn seems to have problems with it.

If you add monaco-editor as additional dependency with the new next version it seems to work without needing the above workaround. Are you able to test that? I could also add monaco-editor@0.37.1 as direct dependency in an upcoming 6.0.2 release.

Saw that, I think even after that, this issue will be still there.

We need to discuss way forward regarding dependency/peerDependency declaration in monaco-vscode-api/monaco-languageclient together with the patch process improvement this should solve all install level problems.

@jeremiah-blezing
Copy link
Author

Hi @kaisalmen ,

  "dependencies": {
    "@codingame/monaco-vscode-api": "1.78.6",
    "monaco-editor": "0.37.1",
    "monaco-languageclient": "6.0.2-next.0"
  },

With the above, I am able to install it in yarn without any issues 👌

We will soon migrate to the latest once everything is stable. Love what you guys are doing. This issue can be closed.

Thank you 🙂

@kaisalmen
Copy link
Collaborator

Hi @jeremiah-blezing good to know. I will announce when the new monaco-languageclient version is available and then close this issue.

@kaisalmen
Copy link
Collaborator

The new version of monaco-languageclient is now available: https://www.npmjs.com/package/monaco-languageclient/v/6.0.2
It contains both monaco-vscode-api and monaco-editor as dependency.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants