-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Description
Spent some time trying to figure out how to fix broken typescript imports after switching to @grpc/grpc-js. And the doc is actually wrong. In order for generated js to keep having BookServiceClient export instead of exports['com.book.BookService'] and at the same time using new @grpc/grpc-js you have to change:
--grpc_out=generate_package_definition:$OUT_DIR
to
--grpc_out=grpc_js:$OUT_DIR
then the only difference of the generated js file would be the import from @grpc/grpc-js. All the exports would remain the same.
Here is the whole generation script that's using grpc-js:
PROTOC="$(yarn bin)/grpc_tools_node_protoc"
# path to proto files
PROTO_PATH=./proto/*.proto
# path to generated files
OUT_DIR=./generated
$PROTOC \
--js_out=import_style=commonjs,binary:$OUT_DIR \
--grpc_out=grpc_js:$OUT_DIR \
--ts_out=generate_package_definition:$OUT_DIR \
$PROTO_PATHMetadata
Metadata
Assignees
Labels
No labels