2026-04-21 16:06:51 +02:00
## Quickstart guide
2026-04-21 17:13:13 +02:00
2026-05-18 10:50:00 +02:00
Run:
2026-04-21 17:13:13 +02:00
2026-04-21 16:06:51 +02:00
```bash
./scripts/setup-linking.sh
```
2026-04-21 17:13:13 +02:00
2026-04-21 16:06:51 +02:00
Read the script output:
2026-04-21 17:13:13 +02:00
2026-04-21 16:06:51 +02:00
```
Setup complete.
Update: .links.cjs to your liking
Run: 'pnpm links:on' to test your .links.cjs
Run: 'git commit' with links enabled to test the git pre-commit hook.
Run: 'pnpm links:off' to be able to commit again
Run: 'git config --local core.hooksPath ""' to allow committing with linking (not recommended)
Run: 'rm links.cjs' & 'git config --local core.hooksPath ""' to fully revert what this script did
```
2025-03-14 02:17:26 -04:00
# Developing with linked packages
2026-04-21 16:06:51 +02:00
If you want to make changes to a package that Element Call depends on and see those changes applied in real time, you can create a link to a local copy of the package. `pnpm` has a command for this (`pnpm link` ), but it's not recommended to use it as it ends up modifying package.json with details specific to your development environment.
2025-03-14 02:17:26 -04:00
2026-04-21 16:06:51 +02:00
Instead, create a file named `.links.cjs` in the Element Call project directory (or run `./scripts/setup-linking.sh` to create a template), listing the names and paths of any dependencies you want to link. For example:
2025-03-14 02:17:26 -04:00
2026-04-20 16:59:34 +02:00
```cjs
// Packages to link to local checkouts
module . exports = {
"matrix-js-sdk" : "../your/path/matrix-js-sdk" ,
"matrix-widget-api" : "../your/path/matrix-widget-api" ,
};
2025-03-14 02:17:26 -04:00
```
2026-04-21 16:06:51 +02:00
Then run `pnpm links:on` . (this will activate the pnpm file + run `pnpm install` to setup the linking)
2025-03-25 20:12:36 +01:00
## Hooks
2026-04-21 16:06:51 +02:00
Changes in `.links.cjs` will also update `pnpm-lock.yaml` when `pnpm install` is executed. The lockfile will then contain the local
2025-03-25 20:12:36 +01:00
version of the package which would not work on others dev setups or the github CI.
2026-04-20 16:59:34 +02:00
2026-04-21 16:06:51 +02:00
One always needs to remove the pnpm `readPackage` script (the `.pnpmfile.cjs` ) and run:
2025-03-25 20:12:36 +01:00
```bash
2026-04-21 10:53:56 +02:00
pnpm install
2025-03-25 20:12:36 +01:00
```
before committing a change.
2026-04-21 16:06:51 +02:00
To make this less of a foot gun we added a git hook.
A `pre-commit` hook will check if linking is currently used. If it detects
a `.pnpmfile.cjs` file it will abort the commit with an explanatory message.
2026-05-18 10:50:00 +02:00
You will then need to run `pnpm links:off` and commit again.
2025-03-25 20:12:36 +01:00
2026-04-21 16:06:51 +02:00
To activate the hooks configure git with (when using the setup script (`./scripts/setup-linking.sh` ) this is already done):
2025-03-25 20:12:36 +01:00
```bash
2026-04-20 16:59:34 +02:00
git config --local core.hooksPath .githooks
2025-03-25 20:12:36 +01:00
```
2026-04-21 17:13:13 +02:00
2026-04-21 16:06:51 +02:00
This will add the hook path for this repository only to .gihooks. which is a tracked (by git) folder containing the pre-commit hook.
## Background
2026-04-21 17:13:13 +02:00
2026-04-21 16:06:51 +02:00
Information, why this approach is used can be found in the [linking concept reasoning ](./linking_concept_reasoning.md ) document.