Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hoist monorepo modules #730

Closed
evertonfraga opened this issue Apr 27, 2020 · 3 comments · Fixed by #778
Closed

Hoist monorepo modules #730

evertonfraga opened this issue Apr 27, 2020 · 3 comments · Fixed by #778

Comments

@evertonfraga
Copy link
Contributor

evertonfraga commented Apr 27, 2020

Lerna bootstrap has the --hoist option, that aims to install each common dependency only once, at the repository root level. This is useful for development as it provides faster installs, and super nice for CIs, as besides faster installs, it's easier to cache them.

Risks: if any module or script does not follow the default package resolution method — recursively up the directory tree (packages/vm/node_modules, packages/node_modules, ./node_modules, etc…), there might be misbehaviors.

Currently, the command lerna bootstrap --hoist gives the following warnings:

lerna notice cli v3.20.2
lerna info Bootstrapping 6 packages
lerna WARN EHOIST_PKG_VERSION "ethereumjs-account" package depends on @ethereumjs/config-nyc@^1.1.0, which differs from the hoisted @ethereumjs/config-nyc@^1.1.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-common" package depends on @ethereumjs/config-nyc@^1.1.0, which differs from the hoisted @ethereumjs/config-nyc@^1.1.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-account" package depends on @ethereumjs/config-prettier@^1.1.0, which differs from the hoisted @ethereumjs/config-prettier@^1.1.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-common" package depends on @ethereumjs/config-prettier@^1.1.0, which differs from the hoisted @ethereumjs/config-prettier@^1.1.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-account" package depends on @ethereumjs/config-tsc@^1.1.0, which differs from the hoisted @ethereumjs/config-tsc@^1.1.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-common" package depends on @ethereumjs/config-tsc@^1.1.0, which differs from the hoisted @ethereumjs/config-tsc@^1.1.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-account" package depends on @ethereumjs/config-tslint@^1.1.0, which differs from the hoisted @ethereumjs/config-tslint@^1.1.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-common" package depends on @ethereumjs/config-tslint@^1.1.0, which differs from the hoisted @ethereumjs/config-tslint@^1.1.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-account" package depends on @types/bn.js@^4.11.3, which differs from the hoisted @types/bn.js@^4.11.5.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-blockchain" package depends on @types/bn.js@^4.11.4, which differs from the hoisted @types/bn.js@^4.11.5.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-account" package depends on @types/node@^11.9.4, which differs from the hoisted @types/node@^11.13.4.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-blockchain" package depends on @types/node@^11.11.4, which differs from the hoisted @types/node@^11.13.4.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-common" package depends on @types/node@^10.12.2, which differs from the hoisted @types/node@^11.13.4.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-account" package depends on merkle-patricia-tree@^3.0.0, which differs from the hoisted merkle-patricia-tree@^2.3.2.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-block" package depends on merkle-patricia-tree@^2.1.2, which differs from the hoisted merkle-patricia-tree@^2.3.2.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-account" package depends on nyc@^13.2.0, which differs from the hoisted nyc@^12.0.2.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-blockchain" package depends on nyc@^13.0.1, which differs from the hoisted nyc@^12.0.2.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-common" package depends on nyc@^11.7.1, which differs from the hoisted nyc@^12.0.2.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-tx" package depends on nyc@^14.0.0, which differs from the hoisted nyc@^12.0.2.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-blockchain" package depends on prettier@^1.16.4, which differs from the hoisted prettier@^1.15.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-tx" package depends on prettier@^1.17.0, which differs from the hoisted prettier@^1.15.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-vm" package depends on prettier@^2.0.4, which differs from the hoisted prettier@^1.15.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-account" package depends on tape@^4.10.1, which differs from the hoisted tape@4.6.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-block" package depends on tape@^4.2.0, which differs from the hoisted tape@4.6.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-blockchain" package depends on tape@^4.9.1, which differs from the hoisted tape@4.6.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-common" package depends on tape@^4.9.2, which differs from the hoisted tape@4.6.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-tx" package depends on tape@^4.0.3, which differs from the hoisted tape@4.6.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-account" package depends on ts-node@^7.0.1, which differs from the hoisted ts-node@^8.0.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-common" package depends on ts-node@^7.0.1, which differs from the hoisted ts-node@^8.0.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-vm" package depends on ts-node@^8.8.2, which differs from the hoisted ts-node@^8.0.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-blockchain" package depends on tslint@^5.13.1, which differs from the hoisted tslint@^5.12.0.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-tx" package depends on tslint@^5.15.0, which differs from the hoisted tslint@^5.12.0.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-vm" package depends on tslint@^5.16.0, which differs from the hoisted tslint@^5.12.0.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-blockchain" package depends on typescript@^3.3.3333, which differs from the hoisted typescript@^3.2.2.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-tx" package depends on typescript@^3.4.3, which differs from the hoisted typescript@^3.2.2.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-vm" package depends on typescript@^3.8.2, which differs from the hoisted typescript@^3.2.2.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-block" package depends on ethereumjs-util@^5.0.0, which differs from the hoisted ethereumjs-util@^6.0.0.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-blockchain" package depends on ethereumjs-util@~6.1.0, which differs from the hoisted ethereumjs-util@^6.0.0.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-vm" package depends on ethereumjs-util@^6.2.0, which differs from the hoisted ethereumjs-util@^6.0.0.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-account" package depends on rlp@^2.2.1, which differs from the hoisted rlp@^2.2.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-blockchain" package depends on rlp@^2.2.2, which differs from the hoisted rlp@^2.2.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-block" package depends on browserify@^15.0.0, which differs from the hoisted browserify@^16.5.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-tx" package depends on browserify@^16.2.3, which differs from the hoisted browserify@^16.5.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-block" package depends on coveralls@^2.11.6, which differs from the hoisted coveralls@^2.11.4.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-blockchain" package depends on coveralls@^3.0.2, which differs from the hoisted coveralls@^2.11.4.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-common" package depends on coveralls@^3.0.1, which differs from the hoisted coveralls@^2.11.4.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-block" package depends on istanbul@^0.4.2, which differs from the hoisted istanbul@^0.4.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-block" package depends on karma@^2.0.0, which differs from the hoisted karma@^4.0.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-tx" package depends on karma@^4.1.0, which differs from the hoisted karma@^4.0.1.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-block" package depends on karma-browserify@^5.1.0, which differs from the hoisted karma-browserify@^6.0.0.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-block" package depends on karma-detect-browsers@^2.2.5, which differs from the hoisted karma-detect-browsers@^2.3.3.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-block" package depends on karma-tap@^4.0.0, which differs from the hoisted karma-tap@^4.1.4.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-block" package depends on standard@^8.4.0, which differs from the hoisted standard@^10.0.0.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-block" package depends on async@^2.0.1, which differs from the hoisted async@^3.2.0.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-blockchain" package depends on async@^2.6.1, which differs from the hoisted async@^3.2.0.
lerna WARN EHOIST_PKG_VERSION "ethereumjs-tx" package depends on minimist@^1.2.0, which differs from the hoisted minimist@^1.1.1.
lerna info Installing external dependencies
lerna info hoist Installing hoisted dependencies into root
lerna info hoist Pruning hoisted dependencies
lerna info hoist Finished pruning hoisted dependencies
@evertonfraga evertonfraga self-assigned this Apr 27, 2020
@evertonfraga evertonfraga changed the title Normalize dependency tree to better use Lerna's dependency hoisting Hoist monorepo modules Apr 27, 2020
@evertonfraga
Copy link
Contributor Author

Quick command to see all unique devDependencies and versions in all monorepo packages:

 cat packages/*/package.json | jq '.devDependencies' | sort | uniq

@evertonfraga
Copy link
Contributor Author

evertonfraga commented Jun 17, 2020

A more advanced command that comprises dependencies and devDependencies, with a much nicer output than before:

cat packages/*/package.json | \
    jq '.dependencies, .devDependencies' | \
    grep -Eo '".+"' | \
    sort | \
    sed -E 's/[":]//g' | \
    uniq -c

output:

   1 @ethereumjs/account ^3.0.0
   3 @ethereumjs/block ^3.0.0
   1 @ethereumjs/blockchain ^4.0.3
   4 @ethereumjs/common ^1.5.0
   7 @ethereumjs/config-nyc ^1.1.1
   7 @ethereumjs/config-prettier ^1.1.1
   7 @ethereumjs/config-tsc ^1.1.1
   7 @ethereumjs/config-tslint ^1.1.1
   1 @ethereumjs/ethash ^1.0.0
   2 @ethereumjs/tx ^2.1.2
   1 @types/async ^2.4.1
   5 @types/bn.js ^4.11.6
   1 @types/core-js ^2.5.0
   1 @types/levelup ^4.3.0
   3 @types/lru-cache ^5.1.0
   1 @types/minimist ^1.2.0
   6 @types/node ^11.13.4
   1 @types/semaphore ^1.1.0
   1 @types/tape ^4.13.0
   6 @types/tape ^4.2.33
   1 async ^2.1.2
   1 async ^2.6.1
   1 async ^3.2.0
   1 async-eventemitter ^0.2.4
   3 browserify ^16.5.1
   1 buffer-xor ^2.0.1
   1 contributor ^0.1.25
   1 core-js-pure ^3.0.1
   1 crc-32 ^1.2.0
   2 ethereumjs-testing git+https//github.com/ethereumjs/ethereumjs-testing.git#v1.3.1
   5 ethereumjs-util ^7.0.2
   1 ethereumjs-util ~6.1.0
   1 flow-stoplight ^1.0.0
   1 functional-red-black-tree ^1.0.1
   2 istanbul ^0.4.1
   3 karma ^4.1.0
   3 karma-browserify ^6.0.0
   2 karma-chrome-launcher ^2.2.0
   1 karma-detect-browsers ^2.3.3
   3 karma-firefox-launcher ^1.1.0
   3 karma-tap ^4.1.4
   1 level ^6.0.0
   2 level-mem ^3.0.1
   1 levelup ^1.3.0
   1 lru-cache ^5.1.1
   1 memdown ^1.1.0
   2 merkle-patricia-tree ^2.3.2
   1 merkle-patricia-tree ^3.0.0
   1 miller-rabin ^4.0.0
   2 minimist ^1.2.0
   7 nyc ^14.0.0
   7 prettier ^2.0.5
   3 rlp ^2.2.3
   1 rustbn.js ~0.2.0
   2 safe-buffer ^5.1.1
   1 semaphore ^1.1.0
   1 standard ^10.0.0
   1 tap-spec ^5.0.0
   7 tape ^4.10.1
   7 ts-node ^8.8.2
   7 tslint ^5.16.0
   6 typedoc next
   6 typedoc-plugin-markdown ^2.2.17
   7 typescript ^3.9.3
   6 typestrict ^1.0.2
   1 util-callbackify ^1.0.0
   1 util.promisify ^1.0.1

@evertonfraga
Copy link
Contributor Author

While using lerna bootstrap --hoist, the dependencies are generally installed in the root's node_modules, so I'll look for alternatives for direct calls to the tape bin.

@evertonfraga evertonfraga linked a pull request Jun 24, 2020 that will close this issue
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants