yalc icon indicating copy to clipboard operation
yalc copied to clipboard

In monorepo, "yarn install" removes "yalc link", and "yalc add --pure" does nothing

Open garyo opened this issue 5 years ago • 6 comments

I have a monorepo with common/ and app/ workspaces. If I use yalc link @garyo-test/common in my app workspace, it copies common into .yalc and symlinks that into node_modules/@garyo-test. So far so good. But if I run "yarn install" any time after that, it removes the symlink and creates a top-level node_modules. So it seems like every time I run "yarn" I have to re-run "yalc link".

Also I tried "yalc add --pure" in my app workspace but it seems to do nothing. Seems like a bug?

I created a test repo to try various options; it's at https://github.com/garyo/yalc-test. The RUNME.sh has instructions. In that repo, I build the common code and publish it, then build the app locally, and then simulate building in Docker by copying the app dir (only) to /tmp and attempting a build there.

# no args (yalc add): works OK
# USE_ADDLINK=1: works OK
# USE_LINK=1: works OK
# USE_PURE=1: fails, because --pure makes yalc do nothing

# RUN_YARN=1: (yalc add) works OK
# RUN_YARN=1 USE_ADDLINK=1: works OK
# RUN_YARN=1 USE_LINK=1: fails because prod node_modules is empty
# RUN_YARN=1 USE_PURE=1: fails because prod node_modules doesn't exist

# "add --pure" and "link" don't change package.json, the others do.
# Only the ones that change package.json work.

garyo avatar May 25 '20 14:05 garyo

Also, using that test repo, I'm not sure what to commit to git. Seems like I really don't want to commit the .yalc dir because that's just needless churn every time the common module is updated. But maybe I do want to commit the changes yalc makes to the app package.json?

Of course if I don't commit the .yalc dir then on each new clone of the repo I have to yalc publish and yalc add before doing anything else, to set up the dirs and symlinks. So I'm not sure what the expectation is.

garyo avatar May 25 '20 15:05 garyo

yalc add --pure just copies code to .yalc, when using workspaces I add ".yalc/*", ".yalc/@*/*" and yarn creates symlinks itself.

wclr avatar Jun 13 '20 15:06 wclr

Can you allow --pure to work even when workspaces is not specified in package.json if it's explicitly used in yalc add?

promethyttrium avatar Jul 04 '20 14:07 promethyttrium

@promethyttrium yes I believe) done

wclr avatar Jul 05 '20 03:07 wclr

In my project, when I add the yalc directory to the workspace I start having issues with babel plugins not resolving. yalc add works fine, but I would prefer not to change the package.json if I can help it.

cdbelyeu avatar Jan 27 '21 18:01 cdbelyeu

@cdbelyeu You should describe your setup and the issue, you may create a new one.

wclr avatar Jan 27 '21 21:01 wclr