Add external dependencies
This is a short doc on how about to go along updating NX Workspace dependencies and the overall mono-repo root dependencies.
Disclaimer: This is not a guide on how to ensure security during a dependency upgrade routine.
Adding dependencies
Add the desired dependency to your app or lib:
yarn workspace {workspace-name} add {dependency}
Optionally you can
cd
into your workspace where package.json is located and useyarn add {dependency}
.
You can find your workspace-name in the root workspace.json.
Any dependencies added to root package.json will cause yarn to fail.
How to update the root dependencies
Responsibility
Changing and managing dependencies in the root level, along with NX Workspace dependencies, have to be coordinated with the Framework Core Team.
Get in touch in the open Slack channel.
Step by step
-
Follow the guides on how to update NX related dependencies first.
e.g.
nx migrate @nrwl/workspace@latest
-
Run the migration if required by the output from the previous command.
-
Update the remaining "repo root" dependencies by using your tool of choice.
E.g.
npx npm-check-updates "/gatsby/" --target minor -u
oryarn upgrade-interactive --latest
for all packages in the repo. -
Run
yarn
(yarn install) to ensure you commit a "synced"yarn.lock
file. -
Run
yarn audit
to check the state of vulnerabilities on the new dependencies. -
You also may run all tests before PR creation.
Edge cases
All root dependencies which not should get updated, have to be added in the file .ncurc.json
.