https://www.viget.com/articles/how-to-use-local-unpublished-node-packages-as-project-dependencies/
yalc: no version upgrade, no publish etc.
Building an application using libraries – called packages or modules in Javascript – is a common practice since decades. We often use third-party libraries in our projects to not have to implement everything ourselves.
In this post I want to describe the less common situation where we are using a library we developed on our own and/or are actively maintaining. While working on the consuming application we need to change the library sometimes, too. This can lead to a cumbersome process:
- Need to implement a feature or fix in the application leads to changes in our library package.
- Make a release of the library and publish it.
- Make our application reference the new version of our library.
- Test everything and find out, that more changes are needed.
- Goto 1.
This roundtrip-cycle takes time, creates probably useless releases of our library and makes our development iterations visible to the public.
A faster and lighter alternative
Many may point to npm link or yarn link but there are numerous problems associated with these solutions, so I tried the tool yalc.
After installing the tool (globally) you can make changes to the library and publish them locally using yalc publish.
In the dependent project you add the local dependency using yalc add <dependency_name>. Now we can quickly iterate without creating public releases of our library and test everything locally until we are truly ready.
This approach worked nicely for me. yalc has a lot more features and there are nice guides and of course its documentation.
Conclusion
Developing several javascript modules locally in parallel is relatively easy provided the right tooling.
Do you have similar experiences? Do you use other tools you would recommend?