-
To add an other package from the mono-repo to your package (package names are specified in package.json files):
yarn lerna add --scope=<my-package> <package-to-add> yarn
-
To add an external dependency:
- Add it directly to the
package.jsonfile of the SharedComponents package - Run
yarnat the root of the SharedComponents.
- Add it directly to the
ℹ️
yarn add <dependency>oryarn upgrade <dependency>inside a SharedComponents package folder has known issues and shouldn't be used for now. The SharedComponents team is working towards correcting these issues.
Why should you care ? : You can read this article to understand why it is not a good thing to only use dependencies.
Let's assume there is a foo package in SharedComponents, and it needs some functions from the bar package (which is external).
- If your host project has
baras dependency, putbaras apeerDependencyoffoo. Test locally on your Host project with ayarn link. This will probably fail hard in case of a problem. - If your project does not have
bar, add it in thedependenciesoffoo.
-
If the dependency is only used for development (ex: flow, jest), don't forget to add it to the
devDependenciesinstead -
If the dependency is exposed as part of the package interface, such as React, then you need to add it as a
peerDependencies. To know when to add a package as a peer dependency, you can refer to this article. A warning will be printed if someone installs the SharedComponents package on a project on which the peer dependency is not installed.