Yarn workspaces?


#1

I’m just getting started with shadow-cljs on a project that is using yarn’s workspaces for multiple module dependency management. I am running into some trouble with getting shadow to compile. shadow starts up, but then can’t find itself:

yarn shadow-cljs compile lib
yarn run v1.7.0
$ /Users/mbishop/OCTO/atlantis/nautilus-dsl/node_modules/.bin/shadow-cljs compile lib
shadow-cljs - config: /Users/mbishop/OCTO/atlantis/nautilus-dsl/shadow-cljs.edn  cli version: 2.3.36  node: v8.11.2
shadow-cljs - starting ...
[2018-06-08 07:45:23 - WARNING] can't find node_modules/shadow-cljs/cli/dist/shadow.cljs.npm.transform.js, please run "npm install --save-dev shadow-cljs" or "yarn add --dev shadow-cljs" to install it.

#2

I have not used workspaces before but can’t you just put dependencies at the top level?

{
  "private": true,
  "workspaces": ["workspace-a", "workspace-b"],
  "devDependencies": {
    "shadow-cljs": ...
  }
}

#3

The shadow-cljs module lives in root’s node_modules which is where all the deps live. Otherwise shadow-cljs wouldn’t run at all. The actual dependency, though, is declared in the submodule that uses it. This is the best practice for workspaces.

It seems like shadow, after it has started, gets confused about where it should be looking for it’s files. I’m running from the submodule, not the root.


#4

If I add shadow-cljs to the workspaces nohoist list, then shadow-cljs starts working as expected in a submodule. My guess is because nohoist installs the module in-place, rather than in the root.


#5

I just release [email protected] which fixes this and no longer hardcodes the <project>/node_modules/shadow-cljs location.


#6

Thanks Thomas. I tested the new version and now it works without hoisting.