https://github.com/chee/pnpm-plugin-patchwork
pnpm-resolver-patchwork
https://github.com/chee/pnpm-plugin-patchwork
Last synced: 11 days ago
JSON representation
pnpm-resolver-patchwork
- Host: GitHub
- URL: https://github.com/chee/pnpm-plugin-patchwork
- Owner: chee
- Created: 2026-02-26T22:43:59.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-04-29T13:29:14.000Z (about 1 month ago)
- Last Synced: 2026-04-29T15:34:23.144Z (about 1 month ago)
- Language: JavaScript
- Size: 2.01 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pnpm-plugin-patchwork
> **Warning**: chee has not read line 1 of this codebase. It was entirely written by the computer.
A pnpm custom resolver and fetcher for installing packages from a [patchwork](https://github.com/inkandswitch/patchwork) filesystem (automerge-repo).
Specify dependencies as `automerge:` in your `package.json` and pnpm will resolve and fetch them from the automerge sync server.
## Requirements
- pnpm v11 (beta.2+) — uses the top-level `resolvers`/`fetchers` plugin API
## Setup
1. Add `pnpm-plugin-patchwork` as a config dependency in your `pnpm-workspace.yaml`:
```yaml
configDependencies:
pnpm-plugin-patchwork: "0.1.0"
```
2. Add automerge dependencies to your `package.json`:
```json
{
"dependencies": {
"@patchwork/chat": "automerge:6iXwddwF9cwrjmM5yqp2xUENxUY"
}
}
```
3. Run `pnpm install`.
## How it works
- **Resolver**: Detects `automerge:` specifiers, connects to the automerge sync server, reads the folder document's `package.json` to get the package manifest, and returns a `custom:automerge` resolution.
- **Fetcher**: Connects to the sync server, recursively walks the automerge folder document tree to collect all files, packs them into a tarball, and delegates to pnpm's built-in `localTarball` fetcher.
- **Caching**: The document ID + heads hash is used as the resolution ID in the lockfile, so installs are cached until the document changes.
## Subpath resolution
You can resolve a subfolder of a folder document as the package root:
```json
{
"dependencies": {
"my-pkg": "automerge:6iXwddwF9cwrjmM5yqp2xUENxUY/dist"
}
}
```
## Configuration
The sync server defaults to `wss://sync3.automerge.org`. To use a different server, add a `patchwork.server` field to your `package.json`:
```json
{
"patchwork": {
"server": "wss://my-sync-server.example.com"
}
}
```
Or set the `PATCHWORK_SYNC_SERVER` environment variable (takes precedence):
```sh
PATCHWORK_SYNC_SERVER=wss://my-sync-server.example.com pnpm install
```
## Tests
```sh
pnpm test
```
Unit tests use a mocked automerge repo. The e2e test runs `pnpm install` in `test/fixture/` against the real sync server.