connectrpc / connect-es

The TypeScript implementation of Connect: Protobuf RPC that works.
https://connectrpc.com/
Apache License 2.0
1.32k stars 75 forks source link

docs and generate code issue #492

Closed tsingson closed 1 year ago

tsingson commented 1 year ago

Describe the bug

in docs https://connect.build/docs/web/generating-code

Output
Let's take a peek at what was generated. There are two new files:

gen/buf/connect/demo/eliza/v1/eliza_connect.ts
gen/buf/connect/demo/eliza/v1/eliza_pb.ts
The first file was generated by protoc-gen-connect-es and contains the service:

import { SayRequest, SayResponse } from "./eliza_pb.js";
import { MethodKind } from "@bufbuild/protobuf";

import { SayRequest, SayResponse } from "./eliza_pb.js";

should be

import { SayRequest, SayResponse } from "./eliza_pb";

or

import { SayRequest, SayResponse } from "./eliza_pb.ts";

Environment (please complete the following information):

timostamm commented 1 year ago

If you want to write TypeScript with ECMAScript modules that works on Node.js and other environments, you have to use a .js extension in import paths to .ts files. See this lengthy explanation.

This is also reflected in the code we generate. You can change or remote the extension in generated import paths with this option if you prefer.