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

Does not work with Yarn Monorepos #102

Open
johanneskares opened this issue May 18, 2022 · 3 comments
Open

Does not work with Yarn Monorepos #102

johanneskares opened this issue May 18, 2022 · 3 comments

Comments

@johanneskares
Copy link

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.

@johanneskares
Copy link
Author

johanneskares commented May 18, 2022

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?

@johanneskares
Copy link
Author

#103

@krzkaczor
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants