docs/solutions/developer-experience/2026-05-29-slate-yjs-package-local-yjs-aliases-hide-duplicate-installs.md
The Slate v2 site typecheck can pass for the wrong reason when site/tsconfig
aliases yjs to ../packages/slate-yjs/node_modules/yjs. That path depends on
whatever package-local install happens to exist, so changing the audited Yjs
version can leave the site and package compiling against different Y.Doc
types.
bun typecheck:site reports Y.Doc incompatibilities between
node_modules/.bun/[email protected] and packages/slate-yjs/node_modules
resolving to [email protected].bun install --lockfile-only updates bun.lock but does not remove stale
package-local installs.bun install can hang before repairing the package-local tree.../packages/slate-yjs/node_modules/yjs. It made
type resolution depend on install shape rather than the workspace dependency
graph.bun install --lockfile-only. That regenerated bun.lock, but
stale package-local node_modules/yjs still shadowed the root package.bun install. When it stalls, inspect the
actual installed versions instead of guessing.Make the dependency graph boring:
{
"dependencies": {
"yjs": "13.6.30"
},
"peerDependencies": {
"yjs": "13.6.30"
}
}
Remove the site paths.yjs alias entirely, then verify the installed graph:
node -p "require('./node_modules/yjs/package.json').version"
node -p "try{require('./packages/slate-yjs/node_modules/yjs/package.json').version}catch(e){'missing'}"
If the package-local copy is stale and the lockfile already pins the correct version, remove only that stale package-local dependency:
rm -rf packages/slate-yjs/node_modules/yjs
bun --filter @slate/yjs typecheck
bun typecheck:site
Add a contract test that fails if site/tsconfig.json reintroduces a
package-local yjs path or if package manifests loosen the audited Yjs version.
Yjs types are structurally deep enough that two patch versions can become
nominally incompatible through nested private-ish types. The root dependency and
the package dependency need to resolve to the same physical version for
TypeScript to see one Y.Doc type.
The site should resolve yjs through normal workspace dependency resolution.
Pointing at a package-local node_modules directory is a hidden environment
contract, not an architecture choice.
node_modules.site/tsconfig.json has no
package-local yjs alias.