Builds a CommonJS pnpmfile (no bundling) that forces demos to resolve @powersync/* packages from the parent workspace during local development.
- Compiles
src/pnpmfile.tstodist/pnpmfile.js(CJS) viatsconly. scripts/demos-inject-local.tscopies the builtpnpmfileinto each demo as.pnpmfile.cjs.- The
pnpmfilerewrites dependencies tofile:paths pointing at the workspace packages and their peer deps. - The
pnpmfilereplacescatalog:versions with concrete versions from the workspace manifest so demos work outside the main repo.
pnpm -C tools/local-linking install
pnpm -C tools/local-linking buildpnpm demos:injectSelect demos (or use flags) and the script will build local-linking if needed, then copy dist/pnpmfile.js into each selected demo.
The pnpmfile imports @pnpm/workspace.find-packages and @pnpm/workspace.read-manifest. These are not installed in demos. They resolve from the parent repo’s node_modules when the injected .pnpmfile.cjs runs. This works because pnpm loads the pnpmfile in the workspace context even though the file is located inside the demo.
If this ever causes issues, we can switch to bundling those two dependencies into the emitted pnpmfile.