I'm learning about using yarn link
to work on a package and have changes reflected in a host app and I either don't get something or somethings not working.
It is all built in angular5..
I have an app MyApp that contains, among others, @org/my-package
in node_modules
.
I need to make changes to my-package and in order to serve the changes I use yarn link
to create symlink and test the package in MyApp.
This is what I do...
In my-package, I run a build. It creates the distribution files. I then cli into dist package and run yarn link
.. This is success.. I get the instruction to use yarn link @org/my-package
in MyApp cli..
Then I go to MyApp, and I run yarn link @org/my-package
. This is success as well..
However when I make changes in my-package and run a build again, they don't get reflected in MyApp.
What am I not understanding?
I get no errors.
Is @org/my-package
that is in node_modules
in MyApp supposed to be there or not? Isn't yarn link
on the dist in my-package meant to override that one?
No matter how much I search it looks like yarn documentation is a bit light on this topic.
I faced similar kind of a issue. But what I did was edit the package.json in the project that depends on the component library to for example "@org/my-package": "link:../packages/dist/my-package" (edit the path) This only works with yarn, if you use npm this is not an option, but you could use npm link.
I had to do a yarn install after that in the project. So, when you re-build my-package, the @org/my-package that is in node_modules in MyApp supposed to be updated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With