Yalc, a NPM link which works
sbegaudeau.comWow this is serendipitous. I was just wanting a solution to this issue yesterday (developing an app and its dependencies simultaneously without publishing to npm constantly).
I didn't know about `npm link`. Can you elaborate on the issues you've had with it? Because honestly it sounds better to me. When I modify a dependency I don't want to have to "publish" that modification before my app sees it. Am I right in thinking that with `npm link` there is no publish step?
`npm link` and symlinks often end up causing multiple copies of a transitive dependency to end up in the final build. This is especially bad if you're using something like React, which depends on singleton modules to do much of its work, and starts failing if multiple copies of React have been loaded in.
If you're working on a React-based library, you'd normally have React installed in the lib repo as a dev dependency. But, when you go to test out that lib in a sample app repo, you don't want to accidentally have both the app repo's copy of React _and_ the lib repo's copy of React - you want just the app repo's copy.
So yeah, using Yalc technically requires a couple of additional steps ( `yalc publish` in the lib repo, `yalc add my-lib && yarn` in the sample repo), but it's consistent and it _works_. It also correctly handles the fact that you are doing both a build step and only publishing certain folders. I've caught a couple bugs that I would have otherwise shipped to NPM as a result of using Yalc for local testing.
npm link creates symlinks, and this is not supported by the Metro bundled used in React Native, so this could be a way to help there for example.
s/the/a/ anti-grammatical editorialization in the title?