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

When using commonjs_strict option with protoc, ts-protoc-gen does not generate d.ts files correctly #237

Closed
DBosley opened this issue Jul 7, 2020 · 1 comment
Labels

Comments

@DBosley
Copy link

DBosley commented Jul 7, 2020

Versions of relevant software used

  • grpc-tools 1.9.0
  • google-protobuf 3.12.2
  • ts-protoc-gen 0.12.0

What happened
When using protoc to generate javascript files with the commonjs_strict flag, the exports are slightly different than when you use commonjs.
What you expected to happen
ts-protoc-gen needs an option to support this strict mode.

How to reproduce it (as minimally and precisely as possible):
use this script to generate js and ts from some proto files:

#!/usr/bin/env bash

PROTOC_PATH="./node_modules/.bin/grpc_tools_node_protoc"
PROTOC_GEN_TS_PLUGIN_PATH="./node_modules/.bin/protoc-gen-ts"
PROTOC_GEN_GRPC_PATH="./node_modules/.bin/grpc_tools_node_protoc_plugin"
PROTO_PATH="./proto"
OUT_DIR="."

${PROTOC_PATH} \
    --plugin="protoc-gen-ts=${PROTOC_GEN_TS_PLUGIN_PATH}" \
    --plugin=protoc-gen-grpc=${PROTOC_GEN_GRPC_PATH} \
    --js_out="import_style=commonjs_strict,binary:${OUT_DIR}" \
    --ts_out="service=grpc-node:${OUT_DIR}" \
    --grpc_out="${OUT_DIR}" \
    -I "${PROTO_PATH}" \
    $(find ${PROTO_PATH} -iname "*.proto")

Anything else we need to know
When using commonjs_strict, the JS exports the entire proto object from the file. When using commonjs the JS exports proto.ProtobufMyProtoName.

@stale
Copy link

stale bot commented Oct 12, 2020

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 Oct 12, 2020
@stale stale bot closed this as completed Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant