The generated imports seem nice, they are using grpc-web:
import * as pb_1 from "google-protobuf";
import * as grpc_1 from "@grpc/grpc-js";
import * as grpc_web_1 from "grpc-web";
I went to look at the bundled source code and found this in @grpc/grpc-web:
var http2 = require_empty();
var os = require_browser();
var constants_1 = require_constants();
var metadata_1 = require_metadata();
var stream_decoder_1 = require_stream_decoder();
var logging = require_logging();
var constants_2 = require_constants();
var TRACER_NAME = "call_stream";
var { HTTP2_HEADER_STATUS, HTTP2_HEADER_CONTENT_TYPE, NGHTTP2_CANCEL } = http2.constants;
This is where the crash happens, as require_empty() basically just returns null:
// node_modules/node-stdlib-browser/cjs/mock/empty.js
var require_empty = __commonJS({
"node_modules/node-stdlib-browser/cjs/mock/empty.js"(exports, module) {
"use strict";
var import_dist = __toESM(require_dist());
var import_dist2 = __toESM(require_dist2());
var import_dist3 = __toESM(require_dist3());
var empty = null;
module.exports = empty;
}
});
I don't really know how to proceed from here, hope some of you could help me.
First, thanks for this generator. It looks awesome so far, way easier to use than others that I found. However, I am having one problem.
I installed it from npmjs
yarn add protoc-gen-ts
and generated a web client with:When I try to use the code in a React application (bundled with Vite), it crashes with:
The generated imports seem nice, they are using grpc-web:
I went to look at the bundled source code and found this in
@grpc/grpc-web
:This is where the crash happens, as
require_empty()
basically just returnsnull
:I don't really know how to proceed from here, hope some of you could help me.
Versions:
protoc-gen-ts
: 0.8.7grpc-web
: 1.5.0vite
: 5.0.0protoc --version
: libprotoc 25.3