dethcrypto/eth-sdk

Does not work with Yarn Monorepos

johanneskares opened this issue · 3 comments

The CLI always generates files in node_modules/.dethcrypto/eth-sdk-client relative to the package.json

But in a Monorepo the package where I use eth-sdk might be in packages/my-package. So when I run the CLI it generates packages/my-package/node_modules/.dethcrypto/eth-sdk-client but it's looking for the package in node_modules/.dethcrypto/eth-sdk-client. This means eth-sdk doesn't work in Monorepos.

Also, the new version of Yarn doesn't encourage the use of node_modules anymore (https://yarnpkg.com/features/pnp) Maybe eth-sdk should have the option to be run in a mode where it generates source files that should be included in source control instead of creating another package.

I've found a workaround by setting the outputPath in config.json like so:

export default defineConfig({
  outputPath: 'packages/eth-sdk',
  contracts: {
    rinkeby: {
      myContract: '0x779326b435dD48993B60b7D52CF99B6c2430B483',
    },
  },
})

Now I can include it as depdendency in my monorepo. Only problem is, I manually have to change the name of the generated package, because yarn doesn't like the name of the package .dethcrypto/eth-sdk-client in package.json. When I do

yarn workspace my-package add .dethcrypto/eth-sdk-client

I get Usage Error: The .dethcrypto/eth-sdk-client string didn't match the required format (package-name@range). Did you perhaps forget to explicitly reference the package name?

When I manually edit it to dethcrypto-eth-sdk-client-generated, everything works fine. Would it be possible to change to package name to something that matches the standard?

I think using outputPath is the best way forward. In fact I am thinking about dropping whole client package. It's very brittle and tsc can't refresh properly typings when updates happen.

I think in the next version of eth-sdk this will greatly change.