ts-protoc-gen icon indicating copy to clipboard operation
ts-protoc-gen copied to clipboard

added import_style parameter to generate import statements for browser that support es6

Open safanaj opened this issue 2 years ago • 2 comments

Changes

  • added a import_style parameter with the only meaningful value es6, it affect only service=grpc-web generation code. The purpose of this is generate import/export code that doesn't need browserify,webpack or similar bundler to work in browser that supports es6.
  • in the test/helpers/fakeGrpcTransport.ts I just changed new Buffer to Buffer.from due this depracation warning.

I need this to use protoc-gen-ts to generate service js file usable in sveltejs + vitejs (rollup bundler).

Passing the import_style param like --ts_out=service=grpc-web,import_style=es6 the require(...) statements are replaced by import * as ... from ... statements, and exports. .... = ... by export {...} statements.

Verification

I checked it with a tiny sveltjs+vitejs application.

safanaj avatar Jul 19 '22 07:07 safanaj

[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 avatar Jul 19 '22 07:07 improbable-prow-robot

/assign @marcuslongmuir

safanaj avatar Jul 19 '22 07:07 safanaj