https://github.com/be9/faster-pbts
A faster alternative for pbts from protobuf.js
https://github.com/be9/faster-pbts
Last synced: 7 months ago
JSON representation
A faster alternative for pbts from protobuf.js
- Host: GitHub
- URL: https://github.com/be9/faster-pbts
- Owner: be9
- Created: 2024-07-15T13:00:10.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-05-22T07:03:40.000Z (about 1 year ago)
- Last Synced: 2025-05-22T07:42:12.573Z (about 1 year ago)
- Language: JavaScript
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# faster-pbts
[pbts]: https://github.com/protobufjs/protobuf.js/
[](https://www.npmjs.com/package/faster-pbts)
[](./LICENSE)
A faster alternative to [pbts], the TypeScript typings generator from `protobuf.js`.
## 🚀 Motivation
For large Protobuf collections, `pbts` can be slow and memory-intensive. This is due to its reliance on [JSDoc](https://www.npmjs.com/package/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:
```bash
NODE_OPTIONS=--max_old_space_size=16384 pbts ...
```
## âš¡ How `faster-pbts` Works
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**.
## 📦 Installation & Usage
```bash
# Add the package to your project
npm install faster-pbts
# Generate typings
node_modules/.bin/faster-pbts -o output.d.ts input.js
```
* `input.js` should be the output file generated by `pbjs`.
* This tool is a drop-in replacement for `pbts` in most workflows.
Use `--help` to see other available options.