When having multiple packages in a Lerna workspace that depend on each other, Lerna does not run prepare scripts in the order of how they depend on each other. This becomes problematic when they're Typescript packages which need to be built first, so that the packages depending on them can find the type declaration files. Bug: lerna/lerna#2453
To solve this, I've created a script that outputs the packages in the workspace ordered by the dependency graph. You can then just loop over those and execute npm/yarn run prepare
.
package.json
puts all of these things together. Run the bootstrap
script on initial install. You can also use it when you update any packages, but it may be faster to run install-dependencies
if you just need to install new dependencies for any of the packages. Remeber that running yarn add
or npm install
in any of the workspace packages destroys the symlinks between the packages, so you need to edit package.json
dependencies by hand, then run `yarn i