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

Proposal: Optional Generated File Suffix #383

Closed
sallustfire opened this issue Nov 10, 2021 · 2 comments
Closed

Proposal: Optional Generated File Suffix #383

sallustfire opened this issue Nov 10, 2021 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@sallustfire
Copy link
Contributor

ts-proto is great and we've been using it for a while in production. However, having the generated typescript files matching the name of the protobuf file with just the .ts extension is increasingly becoming a maintenance problem. For instance, there is no convenient way to gitignore these generated file with a glob if they are adjacent to non-generated sources.

Other widely used protoc plugins seem introduce suffixes as a matter of convention. For a helloworld.proto

  1. grpc-go => helloworld.pb.go
  2. protoc js_out=import_style=commonjs => helloworld_pb.js
  3. protoc python_out => helloworld_pb2.py
    etc

Unless there is already a mechanism for appending proto suffixes to the generated TS files which are also correctly used in the imports, we'd like to see a mechanism like --ts_proto_opt=suffix=_pb which would produce helloworld_pb.ts. Since it can default to empty, it should be backwards compatible.

Hopefully with a little direction, we'd be willing to work on a PR to introduce this functionality.

@stephenh
Copy link
Owner

Hey @sallustfire , glad to hear it's working well for you!

Yeah, I think a fileSuffix-type option would be nice; probably around in this part of the code:

https://github.com/stephenh/ts-proto/blob/main/src/plugin.ts#L30

A PR would be great!

@sallustfire
Copy link
Contributor Author

@stephenh Great! I'm working on a commit when I have free time. Might have a few questions before I open a PR.

@stephenh stephenh added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Nov 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants