npm/yarn/pnpm workspaces
When you install, will try to look for local version that satisfies, and falls back to npm
yarn supports link: but npm removed support for it, can only do file:
yarn supports nohoist, which results in more duplicate packages and no global sharing, but prevents certain dependency version hoisting issues
Issues: phantom dependencies, doppelgangers - good write-up on rushjs
Which version gets hoisted? TODO
Is version resolution greedy? TODO
yarn-deduplicate has several strategies: highest, fewer
Issues
You can have deps as shown, but in effect something different gets hoisted to root node_modules. Build actually uses the version in root
npm list @types/socket.io-client
plasmic-monorepo@ /Users/yang/proj/tmp/fullws
├─┬ @plasmicapp/[email protected] -> ./packages/watcher
│ └── @types/[email protected]
├─┬ [email protected] -> ./packages/create-plasmic-app
│ └─┬ @plasmicapp/[email protected]
│ └── @types/[email protected] deduped
└─┬ [email protected] -> ./platform/wab
└── @types/[email protected]
# working
rg version packages/watcher/node_modules/@types/socket.io-client/package.json
packages/watcher/node_modules/@types/socket.io-client/package.json: No such file or directory (os error 2)
rg version node_modules/@types/socket.io-client/package.json
3: "version": "3.0.0",
# (builds)
# not working
rg version packages/watcher/node_modules/@types/socket.io-client/package.json
3: "version": "3.0.0",
rg version node_modules/@types/socket.io-client/package.json # I think this is what gets used
3: "version": "1.4.36",
✖ nx run @plasmicapp/watcher:build
$ yarn build:types && yarn build:index
$ yarn tsc
$ /Users/yang/proj/tmp/fullws/node_modules/.bin/tsc
src/watcher.ts(1,1): error TS6133: 'Socket' is declared but its value is never read.
src/watcher.ts(12,19): error TS2749: 'Socket' refers to a value, but is being used as a type here. Did you mean 'typeof Socket'?
src/watcher.ts(81,25): error TS7006: Parameter 'data' implicitly has an 'any' type.
error Command failed with exit code 2.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
error Command failed with exit code 2.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
error Command failed with exit code 2.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
Misc gotchas
@plasmicpkgs/foo
that has devDep/peerDep on host will be deduped fine though.) yarn-deduplicate has no effect.NX
Lerna
lerna publish
also increments the versions in dependent packages’ package.json’s.Open questions