vscode-monorepo-workspace icon indicating copy to clipboard operation
vscode-monorepo-workspace copied to clipboard

Can’t recognise packages in a yarn workspace/nx monorepo

Open NatoNathan opened this issue 2 years ago • 4 comments

I work on a Monorepo using nx and yarn workspaces. we have our packages grouped in nested directories. I wanted to try Monorepo Workspace but it only recognises our apps.

like so

./apps/
  app-1/
  app-2/
./packages/
  common/
    pkg-1/
    pkg-2/
    data-access/
      pkg-1/
  app-1/
    pkg-1/

NatoNathan avatar Mar 30 '22 13:03 NatoNathan

@NatoNathan

I know that I all of my packages had to have at least minimal package.json files for Monorepo Workspaces to find them.

I recently converted to using NX/yarn workspaces from using merely yarn workspaces and the following worked just fine

apps/
   app1/
   app2/
libs/
    libA/
    libB/

however, less than an hour ago I added a layer of nesting

libs/
   libA/
   libB/
   subdirForContainingRelatedLibs/
       libC/
       libD/

and despite libC and libD having package.json files they aren't found.

I haven't looked at the src, but in vs code, on the extension's page, on the Feature Contributions tab lists (near the bottom)

Activation Events workspaceContains:**/package.json

I don't know if that the glob used to determine what is a "workspace" or not, as it seems to only search one directory down. I would expect it to search recursively (and merely ignore node_modules)

I thought perhaps it was stopping it's search when it finds a directory not containing a package.json, so I added a nonsensical

libs/subderForContainingRelatedLibs/package.json

{
  "name": "subdirForContainingRelatedLibs",
  "description": "simply a folder for containing related libs"
}

but that didn't seem have any affect.

@folke Does "sync folders" merely search the tree for directories containing package.json files and list each as a "workspace"? If so, is there some configuration which I'm not finding to tell it to search recursively, perhaps specifying that it should ignore node_modules (or some regexp/glob)?

sts125 avatar Jul 26 '22 20:07 sts125

+1

@sts125 did you find a solution

pyx900 avatar Jul 28 '22 01:07 pyx900

https://github.com/folke/vscode-monorepo-workspace/issues/58#issuecomment-726100699

This solved

pyx900 avatar Jul 28 '22 01:07 pyx900

@pyx900 nice catch! That solved my problem. Not sure if the this should get listed as a dup and closed or not. I'll leave that decision to someone else.

sts125 avatar Jul 28 '22 01:07 sts125