A faster alternative to pbts, the TypeScript typings generator from protobuf.js.
For large Protobuf collections, pbts can be slow and memory-intensive. This is due to its reliance on JSDoc, which is not optimized for performance.
For example, with a collection of ca. 2000 .proto files, pbjs produces a 233MB JavaScript file. Generating TypeScript typings from it using pbts takes approximately 13 minutes and requires increasing memory limits:
NODE_OPTIONS=--max_old_space_size=16384 pbts ...Like pbts, faster-pbts extracts types from JSDoc annotations generated by pbjs.
The key difference is the implementation:
- Uses [tree-sitter-javascript] and [tree-sitter-jsdoc] for fast, incremental parsing.
- Processes input in streaming mode, significantly reducing memory usage.
As a result, generating typings for the same 233MB file takes under 1 minute.
# Add the package to your project
npm install faster-pbts
# Generate typings
node_modules/.bin/faster-pbts -o output.d.ts input.jsinput.jsshould be the output file generated bypbjs.- This tool is a drop-in replacement for
pbtsin most workflows.
Use --help to see other available options.