Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@bufbuild/protoc-gen-es) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@bufbuild/protoc-gen-es
This package provides the code generator plugin protoc-gen-es. The code it
generates depends on @bufbuild/protobuf.
Protocol Buffers for ECMAScript
A complete implementation of Protocol Buffers in TypeScript, suitable for web browsers and Node.js.
For example, the following definition:
message Person {
string name = 1;
int32 id = 2; // Unique ID number for this person.
string email = 3;
}Is compiled to an ECMAScript class that can be used like this:
let pete = new Person({
name: "pete",
id: 123
});
let bytes = pete.toBinary();
pete = Person.fromBinary(bytes);
pete = Person.fromJsonString('{"name": "pete", "id": 123}');Learn more at github.com/bufbuild/protobuf-es.
Installation
With npm
npm install @bufbuild/protoc-gen-esThis will install the code generator plugin in node_modules/.bin/protoc-gen-es.
Note that npm does not add the executable to your $PATH. You can do so with:
PATH=$PATH:$(pwd)/node_modules/.binWith yarn
yarn add @bufbuild/protoc-gen-esNote that yarn v2 does not use a node_modules directory anymore. To find the path
where yarn stores the executable, run yarn bin protoc-gen-es (it is "unplugged"
automatically).
You can always confirm successful installation with:
protoc-gen-es --versionPlugin options
target
This option controls whether the plugin generates JavaScript, TypeScript, or TypeScript declaration files.
Possible values:
target=js- generates a_pb.jsfile for every.protoinput file.target=ts- generates a_pb.tsfile for every.protoinput file.target=dts- generates a_pb.d.tsfile for every.protoinput file.
Multiple values can be given by separating them with +, for example
target=js+dts.
By default, we generate JavaScript and TypeScript declaration files, which
produces the smallest code size. If you prefer to generate TypeScript, use
target=ts.