@bxpb/protoc-plugin

1.0.1 • Public • Published

@bxpb/protoc-plugin

The compiler plugin for protoc which generates client and service TypeScript code for BXPB.

Usage

Start by installing protoc. You can use grpc_tools_node_protoc from grpc-tools if you want something installable from NPM.

Then run (replace protoc with grpc_tools_node_protoc if necessary):

protoc --plugin=protoc-gen-bxpb=node_modules/.bin/bxpb-protoc-plugin --bxpb_out=generated/ greeter.proto

This will compile greeter.proto in the current directory and generate TypeScript definitions for BXPB under the generated/ directory. This will output:

generated/greeter_bxpb_service.d.ts
generated/greeter_bxpb_service.js
generated/greeter_bxpb_client.d.ts
generated/greeter_bxpb_client.js

The first two files contain definitions to run the proto service, while the last two files contain definitions to call the service.

Local Development

Build and Run

To build this package, run from the repository root:

npm run -- lerna run build --stream --scope @bxpb/protoc-plugin --include-dependencies

Output files are in the dist/ directory, while the binary can be invoked with:

npm run -- lerna run start --stream --scope @bxpb/protoc-plugin

Test

Build and run unit tests with this command (run from the repository root):

npm run -- lerna run build --stream --scope @bxpb/protoc-plugin --include-dependencies &&
    npm run -- lerna run test --stream --scope @bxpb/protoc-plugin

You can debug tests in VSCode with the "@bxpb/protoc-plugin - Test Debug" launch configuration.

Sourcemaps seem to work fine, though breakpoints are finicky; sometimes they trigger and sometimes not. The debugger; statement is the most reliable way to break in the file.

You can also test with any other Node inspector by using:

npm run -- lerna run build --stream --scope @bxpb/protoc-plugin --include-dependencies &&
    npm run -- lerna run test:debug --stream --scope @bxpb/protoc-plugin

And then connecting to Node debug port exposed in your preferred debugger. For Chrome, this is done by visiting chrome://inspect and clicking "Open dedicated DevTools for Node".

Place a debugger; statement at the top of the file you are interested in, and then hit "continue" until you reach that file. You should then be able to place and use breakpoints as desired.

Package Sidebar

Install

npm i @bxpb/protoc-plugin

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

63.5 kB

Total Files

10

Last publish

Collaborators

  • dgp1130