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

babel-plugin-import-proto

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-import-proto

Import your protobuf definitions directly in Javascript

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by120%
Maintainers
1
Weekly downloads
 
Created
Source

npm Version npm Downloads npm License

babel-plugin-import-proto

Babel plugin enabling import syntax for .proto files.

Prerequisites

npm install -D @babel/core @grpc/proto-loader
npm install @grpc/grpc-js

Install

npm install -D babel-plugin-import-proto

In .babelrc

{
  'plugins': ['import-proto']
}

Each time you modify a Protobuf file, the cache must be cleared for the changes to take effect.

Options

OptionTypeDefaultDescription
keepCaseBooleanfalsePreserve field names. The default is to change them to camel case.
longs`'String''Number''Long'`
enums`'String''Number'`'String'
bytes`'String''Array''Buffer'`
defaultsBooleanfalseSet default values on output objects.
arraysBooleanfalseSet empty arrays for missing array values even if defaults is false.
objectsBooleanfalseSet empty objects for missing object values even if defaults is false.
oneofsBooleanfalseSet virtual oneof properties to the present field's name.
includeDirsArray<String>[]A list of search paths for imported .proto files.

Examples

import { test } from './test/fixtures/example.proto'
import grpc from 'grpc'

// server.js
const server = new grpc.Server()
server.addProtoService(test.fixture.exampleService.service, new ExampleServiceServerImplem())
server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure())
server.start()

// client.js
const client = new test.fixture.exampleService('localhost:50051', grpc.credentials.createInsecure())
client.getExampleEntity({ id: 0 }, function (err, exampleEntity) {
  if (err) {
    // do something
  } else {
    // do something
  }
})

Keywords

FAQs

Package last updated on 20 Oct 2020

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