timostamm / protobuf-ts

Protobuf and RPC for TypeScript
Apache License 2.0
1.07k stars 127 forks source link

Vite cannot found module #633

Closed kingsley8524267 closed 6 months ago

kingsley8524267 commented 6 months ago

generate command:

npx protoc --ts_out src/protos --ts_opt long_type_string --proto_path . grpc.proto

ts code:

import * as grpcWeb from 'grpc-web';
import {GatewayClient} from '@/protos/GrpcServiceClientPb';
import {LoginRequest} from "@/protos/grpc_pb";

  const grpc = new GatewayClient('http://localhost:50051');
    grpc.login(new LoginRequest(), {}, (err: grpcWeb.RpcError, response) => {
        if (err) {
            console.error('Error:', err.message);
            return;
        }
        console.log('success', response.getStatus(), response.getMessage(), response.getData())
        // Handle response
    });

image

kingsley8524267 commented 6 months ago

Files of generated image

jcready commented 6 months ago

This library/code-generator doesn't produce code that requires the consumer to use new, nor does it generate files with _pb.js unless explicitly told to do so, so I'm guessing you've filed an issue with the wrong repo.