2

After reading the documentation of grpc I see proto files can generate Node (Javascript), Typescript with plugin grpc_tools_node_protoc_ts and grpc-web. Since performance is not critical in my case I can load the .proto files with proto-loader. What are the advantages of using each of the 3 approaches for my case and what would you recommend?

I tried using the Javascript Node default generator but I got trouble making it work with Vue.Js, I get the error: "ReferenceError: process is not defined" when I load the package resources with grpc-js latest version ("@grpc/grpc-js": "^1.8.4"). Then I started wondering if I chose the right approach in the first place.

barrelful
  • 23
  • 4
  • 1
    The TypeScript code and the JavaScript code are going to be identical, only differing in optional type annotations which will be compiled away. Therefore you may want to rethink the source of your problems. You talk of generating TypeScript, but TypeScript itself generates JavaScript. – Aluan Haddad Jan 15 '23 at 16:41

1 Answers1

1

For web environment you should not use proto-loader instead use directly either grpc-web or protobuf-ts/plugin, both support web browser calls. I would actually today recommend protobuf-ts/plugin since I had a known issue with grpc-web lib.

staticdev
  • 2,950
  • 8
  • 42
  • 66