Work with your dependencies locally and see the changes in your app live, like npm link
but better.
TODO
TODO
npm i live-deps --save-dev
-
You still need to publish your package to
npm
(or your own private register / by using a tool like yalc) at least once + everytime a change to your package dependencies is performed.The reason for this is that during a
npm i
the package will always try to reinstall from a real location. That means your symlink may be overwritte and any new dependencies you added to your symlinked version will not be detected. -
Symlinks needs to be resolved correctly by Webpack and TypeScript, for Webpack this means setting
resolve.symlinks
tofalse
and for TypeScript settingpreserveSymlinks: true
intsconfig.json
.
In your package.json
add the following:
"liveDependencies": {
"your-package-name": "..\\your-package-name"
},
If you package requires transpiling make sure to run it in watch mode:
For example:
tsc --watch
Then in your consuming project run the command:
npx live-deps link
This will symlink all the folders in the folder of your package except the node_modules
folder. Currently it will not symlink and files in the root of your project which means you should have your final source code end up in a dist
folder etc.
By avoiding symlinking your
node_modules
we simulate a real install in a better way and avoid problems like dual versions of React etc being loaded causing runtime errors.