3

I'm trying to use vite

I've some JavaScript-generated files for GRPC communication; alongside each file, there is a declarative file because I'm using React with TypeScript. When running Vite, I get this error:

Uncaught SyntaxError: The requested module '/src/grpc-web/offboard/dashboard/web_vantage_server/proto/display_option_pb.js' does not provide an export named 'DisplayOption'

Anybody has encountered this issue and has a solution?

Thanks

bupt mzx
  • 31
  • 2
  • Please check if the file 'display_option_pb.js' exports the 'DisplayOption' like export function DisplayOption() { } – RRR Jul 12 '22 at 01:47
  • there is a file named display_option_pb.d.ts , and export the class like ``export namespace DisplayOption { export type AsObject = { " – bupt mzx Jul 12 '22 at 02:01
  • 1
    same here using ts-protoc-gen, migrating my code to Vite from Webpack, saw a recommendation to use: https://github.com/timostamm/protobuf-ts which does work great but needs complete code refactor since the output is _pb.ts file and the previous _pb.js and the _pb.d.ts – Alon Rosenfeld Oct 25 '22 at 08:09

1 Answers1

0

For those who encounter the same problem and find this page.

The only solution that I found is mentioned here:

https://github.com/grpc/grpc-web/issues/1242

One needs to use protobuf-ts instead of protoc-gen-grpc-web protoc plugin. Then you can use Vite with gRPC-web.

Trarbish
  • 363
  • 4
  • 16