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 plugin param to only generate gRPC types #292

Closed
wants to merge 1 commit into from

Conversation

tatemz
Copy link

@tatemz tatemz commented Nov 1, 2021

Changes

This change adds the grpcOnly parameter to the plugin in order to handle the cases where the user wants to exclusively generate the types for the grpc service only.

Prior to this change, users could not use grpc-tools, grpc-web, and ts-protoc-gen simultaneously.

After this change, it is possible to let grpc-web generate the .d.ts files (using the commonjs+dts or typescript options) for the non-gRPC generated files, while letting ts-protoc-gen singularly manage the generation of the .d.ts files for grpc-node

Verification

Tested it with the following buf.gen.yml configuration:

version: v1

plugins:
  - name: js
    out: ./__generated/proto/js
    opt:
      - import_style=commonjs,binary

  - name: grpc-node
    path: ./node_modules/.bin/grpc_tools_node_protoc_plugin
    out: ./__generated/proto/js

  - name: grpc-web
    path: ./node_modules/.bin/protoc-gen-grpc-web
    out: ./__generated/proto/js
    opt:
      - import_style=commonjs+dts
      - mode=grpcweb

  - name: ts-node
    path: ~/Development/ts-protoc-gen/bin/protoc-gen-ts
    out: ./__generated/proto/js
    opt:
      - service=grpc-node
      - grpcOnly=true

@improbable-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign marcuslongmuir
You can assign the PR to them by writing /assign @marcuslongmuir in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@improbable-prow-robot improbable-prow-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/M Denotes a PR that changes 40-149 lines, ignoring generated files. labels Nov 1, 2021
@tatemz
Copy link
Author

tatemz commented Nov 1, 2021

Dev Note: This feature may not be needed by most, but I found that it is helpful when wanting to generate for grpc-node and grpc-web simultaneously. Feel free to suggest any alternative methods for accomplishing this.

I was hoping that grpc-tools allowed for the commonjs+dts option, but it does not, and the proto-loader is not a protoc plugin - grpc/proposal#183 (comment)

This change adds the grpcOnly parameter to the plugin in order to
handle the cases where the user wants to exclusively generate the types
for the grpc service only.
@tatemz
Copy link
Author

tatemz commented Nov 6, 2021

/assign @MarcusLongmuir

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 16, 2022
@tatemz tatemz closed this Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/M Denotes a PR that changes 40-149 lines, ignoring generated files. wontfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants