Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@techteamer/browserify-protbuf

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@techteamer/browserify-protbuf

Browserify transform to directly require `.proto` files.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

browserify-protobuf

browserify-protobuf is a Browserify transform. With this tool you can require protocol buffer files directly in your code. You can and avoid additional HTTP requests when using protobufjs on the client side by replacing lines like these:

const protobuf = require('protobufjs')
const exampleProto = protobuf.load('protocol/example.proto')

with this:

const exampleProto = require('protocol/example.proto')

It is based on the pbjs cli command of protobufjs. And uses the json-module flag, but it loads each required protocol buffer into a separate protobuf Root object.

Installation

npm install --save-dev @techteamer/browserify-protobuf

Usage

example.proto

syntax = "proto2";

package test;

service TestService {
    rpc Echo (TextMessage) returns (TextMessage) {}
}

message TextMessage {
    required string text = 1;
}

example.js

const exampleProto = require('example.proto')
const TestService = exampleProto.lookupService('TestService')
// ...

Build

Run directly from CLI:

browserify example.js -t @techteamer/browserify-protobuf > dist.js

Or using the browserify API:

browserify(file, {
  // browserify options
  transform: ['@techteamer/browserify-protobuf']
})

Or add it to browserify config using package.json:

{
  "browserify": {
    "transform": [
      ["@techteamer/browserify-protobuf"]    
    ]  
  }
}

Keywords

FAQs

Package last updated on 30 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc