-
Notifications
You must be signed in to change notification settings - Fork 353
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
Anything imported by generated code should be a peerDependency #147
Comments
Yeah, I guess that makes sense. I'm a little concerned that this might be a breaking change, or at least mean downstream users get peer dependency warnings, but we can try it and see how it goes. A wrinkle is that, as mentioned in the commit message, ts-proto itself probably shouldn't have any dependencies for the generated code at all, b/c its very conditional (based on the flags users pass to ts-proto) which packages will/will not be needed at runtime. I.e. if you're not using the dataloader option, it doesn't make sense for that to be a dependency. Or if you're using the only types option, you don't really need/want any dependencies at all, other than just ts-proto itself as a devDependency for the code generator and that's it. I'll defer this wrinkle to another issue / until someone complains about it / patches it. :-) |
Ah yeah, I should have done a pull request, but this change even broken ts-proto's test suite, b/c the peer dependencies, specifically protobufjs, weren't installed automatically. So I've reverted this change and will re-consider when ts-proto is doing a major release when we can sneak it in as a breaking change. I also filed #159 to think about the setup in general. |
I'm tempted to remove these dependencies all together because at this point ts-proto has many different flags that can change whether the generated code actually does/does not use certain dependencies. I.e. users using the "only types" output probably don't want ts-proto to bring in any dependencies. I guess in that case, they could be using ts-proto as a devDependency. Fixes stephenh#147.
I'm tempted to remove these dependencies all together because at this point ts-proto has many different flags that can change whether the generated code actually does/does not use certain dependencies. I.e. users using the "only types" output probably don't want ts-proto to bring in any dependencies. I guess in that case, they could be using ts-proto as a devDependency. Fixes stephenh#147.
I am guessing this is why it is not possible to use yarn 2 with ts-proto? I am getting the following error:
|
I just ran into this with Yarn PnP which does not resolve packages that aren't explicitly listed as dependencies, i.e., I had to manually install both |
@psalz isn't ...fwiw I think personally in downstream projects, I would mark ts-proto as a devDependency (it's a code generator that is only used at build time) and then add explicit dependencies to Or @psalz is this what you're saying, in that to get Yarn PnP to like the generated code, your own project needed explicit dependencies on the If so, that makes sense. If you want to add a note in the readme somewhere that makes sense, that'd be great. |
Yes this is what I have done, maybe worth mentioning it in the README? |
Exactly. Even though
You're right, that is probably the best way of doing it. Although adding the peer-dependencioes to
I can, although I'm not very clear on the specifics: |
Even if dependencies of ts-proto usually can be transitively reached from generated code, it's not in strict adherence with the node resolution algorithm.
For example the above assumption can be broken when there are version conflicts and npm/yarn decides to install a dependency local to ts-proto. It's also broken by other package managers that don't use a flat/hoisted node_modules structure like pnpm.
This can be fixed by declaring every package imported by generated code, as a peer dependency to ts-proto.
The text was updated successfully, but these errors were encountered: