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 npm workspaces #580

Open
panayot-cankov opened this issue Jun 7, 2021 · 10 comments
Open

Support npm workspaces #580

panayot-cankov opened this issue Jun 7, 2021 · 10 comments
Assignees
Labels
feature-request Request for new features or functionality

Comments

@panayot-cankov
Copy link

I've just finished moving several VSCode extensions into single monorepo using npm v7 workspaces.

However when the vsce packages using npm (not yarn) it does internally:

npm list --production --depth=99999 --loglevel=error

And that command fails from the workspace to lookup common modules in the root.
I logged an issue at npm
Although I am not sure if this is npm list bug or feature, probably the npm list will have to be extended to look those modules and then maybe some additional work will be necessary in the vsce to package the files correctly.

@joaomoreno joaomoreno added the feature-request Request for new features or functionality label Jun 7, 2021
@panayot-cankov
Copy link
Author

panayot-cankov commented Jun 8, 2021

On the other hand that part of the RFC:

Make a recursive check that walks up the file system structure and validates if the current prefix is defined as the "workspaces" property of a package.json file of a parent directory.

In case that is so, we can then tweak the internal contexts/variables in such a way that runs the command in the context of the top-level workspace while defining the current working directory as the workspace configuration to be used.

makes perfect sense, and if the npm ls --workspace=myvscodeextension already works (with fixed --prod) it will require zero additional configurations, and will also be backward compatible, as in old repos the npm ls won't look up in the package's parent directories.

npm/rfcs#343

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

Jolg42 commented Apr 4, 2022

Got into this problem as well, the error was not obvious at all. See:

 ERROR  invalid relative path: extension/../../.eslintignore
npm ERR! Lifecycle script `package` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: package@31.0.3 
npm ERR!   at location: /home/runner/work/repo/repo/packages/vscode 

The error message here seems to be from the zipping library yazl, https://github.com/thejoshwolfe/yazl/blob/36b2a6a31a32637dca19b34e7b3295378e78a644/index.js#L368

The npm list call can be fount at https://github.com/microsoft/vscode-vsce/blob/main/src/npm.ts#L68

If there were more debug logs, it would have been easier to find out 😓

@51ngul4r1ty
Copy link

Any progress on this? I would also like to get VS Code Extensions working in a monorepo and it doesn't work for me. I'm assuming that there's still work needed to fully support npm workspaces?

@xt0rted
Copy link

xt0rted commented Jan 23, 2023

I just ran into this after a few hours of cryptic error messages. I haven't done extensive testing yet but my workaround so far is to bundle with @vercel/ncc just like I do on my GitHub Actions and then package with vsce package --no-dependencies. Since ncc bundles your code and your dependencies into a single file the --no-dependencies flag seems to be a sufficient hack.

@remcohaszing
Copy link

I ran into this issue too. But I figured out it's also possble to specify vsce options in package.json.

{
  // …
  "vsce": {
    "dependencies": false
  }
}

@vritant24
Copy link
Member

Just ran into this issue, it would great to have this documented.
@remcohaszing 's workaround fixed it for us

@qarlosalberto
Copy link

any example?

@qarlosalberto
Copy link

Thanks! But an example not using bundle. I cant use a webpack because I have external binaries.

@remcohaszing
Copy link

remcohaszing commented Mar 1, 2024

I found a workaround that allows you to partially include node_modules: mdx-js/mdx-analyzer@ccb7571.

This does break relative links in the readme, so make sure to use only absolute links.

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
Projects
None yet
Development

No branches or pull requests

8 participants