Add `disable_servicetype` option?
See original GitHub issueI recently upgraded to the latest version of the @protobuf-ts/*
packages and updated the option names passed to protoc to their new ones, for instance disable_service_client
was renamed to force_client_none
; however, I am no longer able to prevent protobuf-ts from generating services in my typescript files.
I have tried to dig into the source code for this package and understand how options for service generation are used, but I can’t seem to find anything that is standing out. I have also tried to remove all other options I was using and only specified force_client_none
but to no avail. I have also tried using the client_none
option, but again, services are still generated.
I was wondering if anyone else was experiencing this issue, or if anyone else could try to reproduce this.
The full command I am running is:
npx protoc \
--proto_path="${MY_PATH}" \
--plugin="protoc-gen-ts=${PROTOC_PATH}" \
--ts_out="${PROTOC_OUT_DIR}" \
--ts_opt force_client_none \
--ts_opt generate_dependencies \
--ts_opt long_type_string \
--experimental_allow_proto3_optional \
${FILES}
While my protos are generated fine, again, the services are being generated and this is problematic for the project I am working on.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
That would be much appreciated.
I think the new option can simply disable the following line with an if-statement:
https://github.com/timostamm/protobuf-ts/blob/e231157836cd03df54d8c4a7a20217fd261fba0e/packages/plugin/src/protobufts-plugin.ts#L301
The new option should be added somewhere here: https://github.com/timostamm/protobuf-ts/blob/e231157836cd03df54d8c4a7a20217fd261fba0e/packages/plugin/src/protobufts-plugin.ts#L82
And then be parsed into the internal options object (which needs a new property) here: https://github.com/timostamm/protobuf-ts/blob/e231157836cd03df54d8c4a7a20217fd261fba0e/packages/plugin/src/our-options.ts#L205
Then it will be available via
options.xxx
for the if-statement.The new option probably belongs into the “misc” category (since it is independent of client and server). “disable_servicetype” seems like a fitting name.
Got it, that’s a good point. If we appended
Metadata
, it might break existing code for other users.I wonder if it would have been better to only generate the service metadata if the user opts in with a plugin option - and automatically enable it if the user sets an option that requires it. However, that too is a breaking change, so it would probably be best to do that in v3.
In the meantime, what do you think about an option to disable the generation explicitly? The downside is that it would really only be a temporary option, and be removed in v3.