Working with mono repos

Once the mono repo is configured, we can install dependencies and build applications from the top level using the filter.

Install all dependencies
pnpm -r install
Remove duplicate dependencies

No -r option is necessary

pnpm dedupe

To remove the duplicates of a specific dependency

pnpm dedupe @emotion/react

To list all references of a dependency

pnpm ls @emotion/react
Typecheck all packages and applications
pnpm -r typecheck
Build all apps and packages
pnpm -r build
Build a specific app from the root
pnpm --filter MY_APP build
Run a specific application from the root
pnpm --filter MY_APP dev

Working with apps and packages that are not part of the workspace apps and packages

If the mono repo contains other apps, like Figma Make downloads that are applications, but not part of the released products, the –filter option does not work. We can still interact with them, but we need to start the commands in their subdirectory and reference them with the dot.

To install the dependencies of an app that is not part of the release
cd MY_DESIGN_APP_FOLDER
pnpm install .
To build the app that is not part of the release
pnpm build .
To run the app that is not part of the release
pnpm dev .

Refresh stale references

If you make configuration changes, old references and caches stay in the file system. To force the refresh, delete the ephemeral directories, so the next dependency install, application build, and run will recreate them.

cd apps/MY_APP
rm -rf node_modules/.vite-temp # just to delete the vite temp directory
rm -rf node_modules            # all node modules and the vite temp dir
rm -rf .vite                   # vite cache
pnpm install                   # reinstall all dependencies

Leave a comment

Your email address will not be published. Required fields are marked *