@jtfmumm/automerge-deps
v0.1.6
Published
CLI tool to fetch automerge module dependencies at build time
Readme
automerge-deps
CLI tool that fetches automerge-based module dependencies from a sync server and writes them to node_modules/ for use in a normal build.
Install
pnpm add -D @jtfmumm/automerge-depsSetup
- Add an
automerge-deps.jsonto your project root:
{
"syncServers": [
"wss://your-sync-server.example.com",
"wss://fallback.example.com"
],
"dependencies": [
{
"name": "@patchwork/contact",
"url": "automerge:abc123"
}
]
}Usage
npx automerge-deps installThis connects to the first available sync server, fetches each dependency's folder document, and writes its files to node_modules/<name>/. Run it before pnpm build.
Sync servers are tried in order; if the first is unreachable, it falls back to the next.
Troubleshooting
If you see an error like Error: Document automerge:<url> is unavailable, try running the command again. The sync server may not have had time to deliver all sub-documents on the first attempt.
Preparing a dependency for publishing
Before pushing a dependency to a sync server, make sure it's ready to be consumed as a Node module. The fetched files are written directly to node_modules/<name>/, so the dependency must include:
- A
package.jsonwith amain(orexports) field pointing to the compiled entry point - Compiled JavaScript output (e.g. run
tscbefore pushing if the source is TypeScript)
If a dependency was pushed without compiled output, you can work around it locally after fetching:
cd node_modules/<name>
npx tscYou may also need to add a package.json with a main field pointing to the compiled entry point (e.g. dist/index.js).
Build from source
pnpm install
pnpm build
node dist/cli.js install