🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

grpc-loader

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-loader

gRPC loader module for webpack

2.0.1
latest
Source
npm
Version published
Weekly downloads
9
-60.87%
Maintainers
1
Weekly downloads
 
Created
Source

gRPC loader module for webpack

Converts .proto files into autogenerated js files for use with gRPC

Installation

yarn add --dev grpc-loader

Usage

static: true You can ignore protobufjs peer dependency if you use this option. P.S. I don't really like this api. It's too verbose. google-protobuf

const proto = require('./test.proto');
console.log(proto);

// {
//   services: {
//     GreeterService: {
//       sayHello: [Object]
//     },
//     GreeterClient: {
//       [Function: ServiceClient] super_: [Function: Client],
//       service: [Object]
//     }
//   },
//   messages: {
//     HelloReply: {
//       [Function]
//       superClass_: [Object],
//       base: [Function],
//       toObject: [Function],
//       deserializeBinary: [Function],
//       deserializeBinaryFromReader: [Function],
//       serializeBinaryToWriter: [Function]
//     },
//     HelloRequest: {
//       [Function]
//       superClass_: [Object],
//       base: [Function],
//       toObject: [Function],
//       deserializeBinary: [Function],
//       deserializeBinaryFromReader: [Function],
//       serializeBinaryToWriter: [Function]
//     }
//   }
// }

static: false You can ignore google-protobuf peer dependency if you use this option. same as grpc.load you can also pass any properties that grpc.load accepts

const proto = require('./test.proto');
console.log(proto);

// {
//   helloworld: {
//     Greeter: {
//       [
//         Function: ServiceClient
//       ]super_: [
//         Function: Client
//       ],
//       service: [
//         Object
//       ]
//     },
//     HelloRequest: {
//       
//     },
//     HelloReply: {
//       
//     }
//   }
// }

For usage checkout test folder

Test

npm run test

webpack config

module.exports = {
  module: {
    rules: [
      {
        test: /\.proto$/,
        loader: 'grpc-loader',
        options: {
          // both methods are static internally
          // but result api differs
          // https://github.com/grpc/grpc/tree/master/examples/node
          static: false,

          // grpc props
          // https://github.com/grpc/grpc-node/blob/master/packages/grpc-protobufjs/index.js#L37-L42
          //  convertFieldsToCamelCase,
          //  binaryAsBase64,
          //  longsAsStrings,
          //  enumsAsStrings,
        },
      }
    ]
  }
};

License

MIT (http://www.opensource.org/licenses/mit-license.php)

Keywords

webpack

FAQs

Package last updated on 07 Nov 2017

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