Back to results
dishuostec/rollup-plugin-proto(opens in a new tab)
Language: JavaScript
Rollup probobuf(.proto) files.
- stars
- 2
- watchers
- 1
- forks
- 0
- open issues
- 0
- Last updated
- 08/29/2019
Language: JavaScript
Rollup probobuf(.proto) files.
Convert .proto files into JavaScript module useing pbf.
npm install --save-dev @dishuostec/rollup-plugin-proto
// rollup.config.js import proto from '@dishuostec/rollup-plugin-proto'; export default { input: './src/index.js', plugins: [ proto() ], };
// demo.proto syntax = "proto3"; message SearchRequest { required string query = 1; optional int32 page_number = 2; optional int32 result_per_page = 3; }
// index.js import { SearchRequest } from './demo.proto'; import Pbf from 'pbf'; // read const pbf = new Pbf(buffer); const obj = SearchRequest.read(pbf); // write const pbf = new Pbf(); SearchRequest.write(obj, pbf); const buffer = pbf.finish();