JSPM

gulp-protobuf

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q37801F
  • License MIT

Gulp task for the protobufjs pbjs and pbts tools

Package Exports

  • gulp-protobuf

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gulp-protobuf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Gulp Protobuf

Yet another gulp task for protobufs!

Circle CI npm Licence MIT

This gulp task wraps the protobufjs pbjs and pbts tools to allow generation of JavaScript code and TypeScript definitions without the need for the protoc binary.

Prerequisites

Node.js > v6.12.0, which includes npm.

Installation

$ npm install gulp-protobuf

Usage

Two tasks are exposed from this package, pbjs and pbts.

pbjs is used to translate between file formats and generate static code.

pbts is used to generate TypeScript definitions from annotated JavaScript files output from pbjs.

First, import this package into your gulpfile:

let protobuf = require("gulp-protobuf");

Then you can use either task in your gulp tasks individually:

gulp.task("protobuf-gen", () => {
    return gulp.src(protoFiles)
    .pipe(protobuf.pbjs({
        target: "static-module",
        wrap: "commonjs"
    }))
    .pipe(gulp.dest(distDir));
});
gulp.task("protobuf-types", ["protobuf-gen"], () => {
    return gulp.src(jsFiles)
    .pipe(protobuf.pbts())
    .pipe(gulp.dest(typesDir));
});

Alternatively, pipe both together to output just TypeScript definitions:

gulp.task("protobuf", () => {
    return gulp.src(protoFiles)
    .pipe(protobuf.pbjs({
        target: "static-module",
        wrap: "commonjs"
    }))
    .pipe(protobuf.pbts())
    .pipe(gulp.dest(typesDir));
});

Refer to the protobufjs documentation to see the options available for each command:

pbjs options pbts options