Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support yarn workspaces #300

Closed
siegebell opened this issue Oct 16, 2018 · 11 comments · Fixed by #493
Closed

Support yarn workspaces #300

siegebell opened this issue Oct 16, 2018 · 11 comments · Fixed by #493
Assignees
Labels
feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded

Comments

@siegebell
Copy link

Feature request: support yarn workspaces.

vsce --yarn (as of 1.52.0) does not package any of the modules from the root's node_modules/.

@joaomoreno joaomoreno added the feature-request Request for new features or functionality label Oct 16, 2018
@joaomoreno joaomoreno added this to the Backlog milestone Oct 16, 2018
@kranthie
Copy link

kranthie commented Jul 2, 2019

Hi @joaomoreno: any idea if this support will be added soon?

@yuxuan
Copy link

yuxuan commented Jul 5, 2019

We have a multiple extensions with some common packages mono-repo structure. Each extension has dependencies on few of those common packages.

Currently we are using Lerna to manage the mono-repo, using webpack compile packages for each extension, and using vsce package individual extension and publish it.

It would be great if vsce support this natively

@bd82
Copy link

bd82 commented Apr 1, 2020

I've worked around this by:

  • Using nohoist to force all (transitive) deps of the VSCode ext to be present in its own node_modules directory.
  • Calculating the list of dependencies to be bundled myself.
  • Calling vsce package programmatically and injecting the previously computed list of dependencies using proxyquire

See here:

@phaumer
Copy link

phaumer commented Aug 7, 2020

Another requirement is that it should support webpack as well as exceptions specified in the .vscodeignore file such as

node_modules/**
../../node_modules/**
!../../node_modules/vscode-jsonrpc/**
!../../node_modules/vscode-languageclient/**
!../../node_modules/vscode-languageserver-protocol/**
!../../node_modules/vscode-languageserver-types/**
!../../node_modules/vscode-nls/**

@bd82
Copy link

bd82 commented Sep 23, 2020

Note that if you bundle your extension, e.g using webpack you won't need the contents of the node_modules inside your vsix.

@rbuckton
Copy link
Member

Is this still an issue? I'm using yarn workspaces and was able to successfully package a .vsix using vsce package --yarn and it collected the node_modules from the root just fine.

  • vsce 1.79.5
  • yarn 1.22.4

image

@rbuckton
Copy link
Member

Interestingly enough, running npx [email protected] ls --yarn in the same repo also lists node_modules in the root. I also checked the outputs of npx [email protected] list --prod (as well as some earlier versions back through [email protected]), and they also include the hoisted dependencies.

It could be that I'm running vsce from the root, rather than from within a workspace folder (since I'm planning on bundling the packages anyway in the future).

@rbuckton
Copy link
Member

You can safely ignore my last two comments. After looking at the PR code in #458 I can see that your goal was to run vsce publish from within a specific workspace folder, not the workspace root.

I just put up #480 to auto-detect --yarn, but that may need to be modified slightly if your PR goes in so that it also looks for a yarn workspace root (so you could just do vsce publish from within the workspace folder rather than vsce publish --yarn).

@joaomoreno joaomoreno changed the title yarn workspaces Support yarn workspaces Oct 27, 2021
@joaomoreno joaomoreno self-assigned this Nov 2, 2021
@thegecko
Copy link

I managed to get vsce package working perfectly with yarn in a monorepo with the following 3 changes:

  • Use vsce-yarn-patch instead of vsce which (I believe) is a published fork of this repo including feat: Support for yarn workspaces #493. Without this, all node_modules in the monorepo are included
  • Run vsce package with the --yarn switch (e.g. vsce package --yarn) to ensure the yarn algorithms are used (otherwise npm seems to be used)
  • Create an empty yarn.lock file in the project being packaged. This side-steps the check outlined here which shouldn't be done in a monorepo

HTH

Kummallinen added a commit to Kummallinen/cdt-gdb-vscode that referenced this issue Apr 21, 2022
Split cdt-gdb-vscode into 2 packages, 1 which contains the extendable
code the other is the VS code extension itself.

Use Yarn workspaces to allow building both with a single command

Use vsce-yarn-patch to workaround microsoft/vscode-vsce#300
Kummallinen added a commit to Kummallinen/cdt-gdb-vscode that referenced this issue Apr 22, 2022
Split cdt-gdb-vscode into 2 packages, 1 which contains the extendable
code the other is the VS code extension itself.

Use Yarn workspaces to allow building both with a single command

Use vsce-yarn-patch to workaround microsoft/vscode-vsce#300
Kummallinen added a commit to Kummallinen/cdt-gdb-vscode that referenced this issue Apr 25, 2022
Split cdt-gdb-vscode into 2 packages, 1 which contains the memory view
code the other is the VS code extension itself.

Use Yarn workspaces to allow building both with a single command

Use vsce-yarn-patch to workaround microsoft/vscode-vsce#300
@joaomoreno joaomoreno added this to the December / January 2024 milestone Dec 13, 2023
@joaomoreno joaomoreno added the verification-needed Verification of issue is requested label Jan 23, 2024
@connor4312
Copy link
Member

connor4312 commented Jan 24, 2024

This has been published in the latest prerelease version of @vscode/vsce. Is that version working for folks?

@TylerLeonhardt
Copy link
Member

This is verified. I created the following test:

  • download and unzip: yarn-workspaces.zip
  • run yarn at the root
  • cd ./packages/test-calculator into the vscode extension
  • npx @vscode/vsce@latest package --yarn

This folder contains:

  • A root package.json that uses workspaces
  • a folder under packages that is a "node library"
  • a folder under packages that is a VS Code extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
10 participants