Use protobufjs as a protoc plugin
masterIf you use protoc, you can use protoc-gen-pbjs as an aggregate generator. Each invocation writes one JavaScript module and (if dts is specified) one matching declaration file.
By default, it emits index.js with target=static-module and wrap=esm. You can customize this using --pbjs_opt.
Customization via --pbjs_opt:
file=PATH: Choose the aggregate output file.target=json-module: Use JSON module.wrap=commonjs: Use CommonJS output.keep-case: Preserve descriptor field names.
protoc \
--plugin=protoc-gen-pbjs=./node_modules/.bin/protoc-gen-pbjs \
--pbjs_out=gen \
--pbjs_opt=dts \
proto/awesome.proto