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

Add _pb or .pb suffix to generated filenames #186

Closed
kriswuollett opened this issue Nov 15, 2021 · 4 comments
Closed

Add _pb or .pb suffix to generated filenames #186

kriswuollett opened this issue Nov 15, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@kriswuollett
Copy link

kriswuollett commented Nov 15, 2021

Currently the generated file with the messages cannot be recognized by filename alone unlike some of the standard generators like for C++ and Python. This can be considered an issue since developers may wish to exclude checkin of generated files like with a .gitignore file, or perform automatic analysis on the files. Also there is the issue of accidentally overwriting Typescript source code with the same filename if the protos are kept in separate source tree.

If it is not possible to evolve the default naming scheme, I'd highly recommend adding a plugin option to make the generated file names distinctive. For example, given kw/admin.proto, it should generate file names like kw/admin.pb.ts, kw/admin.pb_grpc_client.ts, and kw/admin.pb_grpc_server.ts.

The pb_ part informs us that it is generated with protoc and grpc_ for the transport. It's slightly unfortunate that most assume that gRPC always implies Protobuf, but FlatBuffers is also a supported message serialization type... so always having the pb_ part helps avoiding conflicts depending on the FlatBuffer generator implementation.

@kriswuollett kriswuollett changed the title [Feature] Generated filenames should be distinct and easily filterable Generated filenames should be distinct and easily filterable Nov 15, 2021
@timostamm
Copy link
Owner

I've always found it best to generate into a dedicated directory. But I see your point. It looks like every official code generator for languages that import based on file names to add a _pb or .pb suffix.

@timostamm timostamm added the enhancement New feature or request label Nov 20, 2021
@timostamm timostamm changed the title Generated filenames should be distinct and easily filterable Add _pb or .pb suffix to generated filenames Nov 20, 2021
@timostamm
Copy link
Owner

5e07925 adds a new plugin option:

  • "add_pb_suffix"
    Adds the suffix _pb to the names of all generated files. This will become the
    default behaviour in the next major release.

I'll close this issue when it is released.

@timostamm
Copy link
Owner

Released as v2.2.0-alpha.0 in the next channel.

@kkocdko
Copy link

kkocdko commented Mar 23, 2024

What about .pb.ts?

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

No branches or pull requests

3 participants