protobuf-es
约 1 分钟阅读
- bufbuild/protobuf-esGitHubbufbuild/protobuf-esbufbuild/protobuf-es · Apache-2.0, TS · protoc-gen-es · target - 默认为 js+dts · js - 生成 · ts - 生成 · dts - 生成 · importextension - import 的后缀笔记:protobuf-es
- Apache-2.0, TS
- protoc-gen-es
- target - 默认为 js+dts
- js - 生成
_pb.js - ts - 生成
_pb.d.ts - dts - 生成
_pb.d.ts
- js - 生成
- import_extension - import 的后缀
- js_import_style
- keep_empty_files
- ts_nocheck
- json_types
- target - 默认为 js+dts
- field 选项
- jstype = JS_STRING
- RPC -> connectrpc/connect-esGitHubconnectrpc/connect-es
- 支持 Connect笔记Connecthttps://connect.build/ · gRPC 竞品 · 兼容 gRPC, gRPC-Web 协议 · 支持 bi-streaming - 使用 gRPC 协议 · 支持 JSON- 和 binary-encoded Protobuf打开:/notes/service/api/grpc/connect, gRPC, gRPC-Web
# by pnpm/npm
pnpm add -D @bufbuild/protoc-gen-es
PATH=$(pnpm bin):$PATH protoc --es_out=. file.proto
# from source
go install github.com/bufbuild/protobuf-es/cmd/protoc-gen-es@latest依赖包@bufbuild/protoc-gen-esnpm 包@bufbuild/protoc-gen-esNPMgithub.com/bufbuild/protobuf-es/cmd/protoc-gen-esGo 包github.com/bufbuild/protobuf-es/cmd/protoc-gen-esGo
import { UserSchema } from "./gen/user_pb.js";
import { create, toBinary, toJson } from "@bufbuild/protobuf";
let user = create(UserSchema, {
firstName: "Homer",
lastName: "Simpson",
active: true,
locations: ["Springfield"],
projects: { SPP: "Springfield Power Plant" },
manager: {
firstName: "Montgomery",
lastName: "Burns",
},
});
const bytes = toBinary(UserSchema, user);
const json = toJson(UserSchema, user);关联信息
反向链接、本文链接的其他页面和外部资料。
站内链接
- Connect笔记 · Connect
https://connect.build/ · gRPC 竞品 · 兼容 gRPC, gRPC-Web 协议 · 支持 bi-streaming - 使用 gRPC 协议 · 支持 JSON- 和 binary-encoded Protobuf
参考资料
GitHub2 条
- bufbuild/protobuf-esgithub.com/bufbuild/protobuf-es
- connectrpc/connect-esgithub.com/connectrpc/connect-es