The extension will heavily rely on monorepo packages. Soon, we will need to apply changes to these packages as part of the work on the extension repository, thus necessitating a way to test changes made to the monorepo within the extension.
One method to achieve this is through hard linking. Here is a step-by-step guide to help you set it up correctly:
-
Clone the repositories:
git clone https://github.com/leather-io/mono git clone https://github.com/leather-io/extension
For simplicity, do this in the same folder so that
mono
andextension
are sibling directories. -
In the extension's
package.json
, update the version of a dependency from the semver version (e.g.,1.0.0
) to afile:
protocol like this:"dependencies": { ... "@leather.io/query": "file:../mono/packages/query" ... }
This change will copy all files from
../mono/packages/query
into the extension'snode_modules
and automatically runpnpm i
. -
When
pnpm i
runs, it will attempt to find the package's dependencies that are set with theworkspace:
protocol. This will fail because theextension
repository is not part of the monorepo. To fix this, override all of the dependency versions at the end of the extension'spackage.json
like this:... "pnpm": { "overrides": { "@leather.io/bitcoin": "file:../mono/packages/bitcoin", "@leather.io/constants": "file:../mono/packages/constants", "@leather.io/models": "file:../mono/packages/models", "@leather.io/utils": "file:../mono/packages/utils", "@leather.io/types": "file:../mono/packages/types" } }
-
Now that the setup is complete, let's install the packages:
- In the monorepo:
- Run
pnpm i
. - Run
pnpm build
to build all of the packages. - Run
pnpm dev
to watch for changes in the repository.
- Run
- In the extension, just run
pnpm i
, and it should install everything else.
- In the monorepo:
That's it; the setup should now be fully functional.
Now, when we update a package in the mono
repo, it doesn't automatically move the changes to the extension
's node_modules
. To do this, run the following command in the extension each time you update a package in the monorepo:
pnpm i
BEWARE: Always check if the pnpm dev
watcher in the mono
repo throws errors before running pnpm i
in the extension. Currently, the watcher does not compile TypeScript files when there are errors, so all issues with TypeScript must be resolved before running pnpm i
in the extension.