yalc
yalc copied to clipboard
In monorepo, "yarn install" removes "yalc link", and "yalc add --pure" does nothing
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.
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.
yalc add --pure just copies code to .yalc, when using workspaces I add ".yalc/*", ".yalc/@*/*" and yarn creates symlinks itself.
Can you allow --pure to work even when workspaces is not specified in package.json if it's explicitly used in yalc add?
@promethyttrium yes I believe) done
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 You should describe your setup and the issue, you may create a new one.