DePayFi / web3-mock

🤡 JavaScript library to mock web3 responses either by emulating web3 wallets or web3 RPC requests.
https://depay.com
MIT License
87 stars 20 forks source link

`depay-web3-blockchains` should be listed in package dependencies. #5

Closed a11rew closed 2 years ago

a11rew commented 2 years ago

depay-web3-blockchains is currently listed as a [peer & dev]-dependency. It is not installed along with depay-web3-mock and throws a missing module error on import.

Error repro:

    Cannot find module 'depay-web3-blockchains' from 'node_modules/depay-web3-mock/dist/cjs/index.js'

    Require stack:
      node_modules/depay-web3-mock/dist/cjs/index.js
      src/__test__/App.test.tsx

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
      at Object.<anonymous> (node_modules/depay-web3-mock/dist/cjs/index.js:6:28)

Save for me missing something, it should be listed in the package's dependencies

10xSebastian commented 2 years ago

Hi @a11rew.

At DePay we have long dependency chains for our npm packages. Having intermediates like depay-web3-mock enforcing it's own version in our final libraries causes problems down the road for us. A peer dependency still points out the immediate next step without enforcing anything:

yarn add depay-web3-blockchains

It should have given you a warning upon installation of depay-web3-mock that you're missing that dependency.

We rather live with an additional step at this point over having depay-web3-mock fix a version in final npm packages which would endup with e.g. 2 versions for depay-web3-blockchains otherwise.

The classic npm multiversion dilemma: https://nodejs.org/en/blog/npm/peer-dependencies/

Best Sebastian

a11rew commented 2 years ago

Fair, thanks @spape

a11rew commented 2 years ago

Absolutely love the library btw, would PRs adding Typescript type definitions be welcome? @spape

10xSebastian commented 2 years ago

Yes, we are open to add Typescript definitions - Thank you 🙏

10xSebastian commented 2 years ago

have added it to the installation instruction: https://github.com/DePayFi/web3-mock#quickstart

🙏 thanks again

a11rew commented 2 years ago

Awesome!