Grpc-web: goog is not defined

Created on 16 Oct 2019  路  1Comment  路  Source: grpc/grpc-web

hello, i common is : protoc -I/home/tusimple/dewei/go/src/googleapis -I. \
--js_out=library=closure:./fe/src/api \
--grpc-web_out=import_style=closure,mode=grpcwebtext:./fe/src/api test.proto

i use import "google/api/annotations.proto"; in my test.proto. but goog is not defined when i use test_bp.js

i use common :
protoc -I/home/tusimple/dewei/go/src/googleapis -I. \
--js_out=import_style=commonjs:./fe/src/api \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:./fe/src/api test.proto

npm run dev found error:

  • ./google/api/annotations_pb.js in ./src/api/t
    est_grpc_web_pb.js, ./src/api/test_pb.js

how can i use it? thanks.

>All comments

I am not sure if I follow your example. But usually for this type of error, you are probably missing a step to "compile" your generated code, together with the grpc-web library code (from npm), into a browser-consumable form.

In the repo you should be able to find some examples on how to do that.

For example, for closure-style import, import_style=closure, you need the closure compiler, something like this

For CommonJS style import, import_style=commonjs, you need some sort of tools like webpack, something like this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

henpanta picture henpanta  路  5Comments

pumano picture pumano  路  6Comments

TBoshoven picture TBoshoven  路  4Comments

joaomlneto picture joaomlneto  路  4Comments

aberasarte picture aberasarte  路  6Comments