Socket
Book a DemoInstallSign in
Socket

proto-pbjs-loader

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proto-pbjs-loader

The only webpack loader you need to translate .proto files to ecma modules.

1.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Ci Status

proto-pbjs-loader

Webpack loader that parses .proto files and converts them to a protobuf.js modules. It build on top of protobuf.js CLI and could be handy integrate into your current build flow.

Install

npm install --save-dev proto-pbjs-loader

Usage

// webpack.config.js

module.exports = {
    ...
    module: {
        rules: [{
            test: /\.proto$/,
            use: {
              loader: 'proto-pbjs-loader',
              /*
               * Config is optional.
               */
              options: {
                /*
                 * controls the "target" flag to pbjs - true for
                 * json-module, false for static-module.
                 * default: false
                 */
                json: false,

                /*
                 * import paths provided to pbjs.
                 * default: webpack import paths (i.e. config.resolve.modules)
                 */
                paths: ['/path/to/definitions'],

                /*
                 * additional command line arguments passed to
                 * pbjs, see https://github.com/dcodeIO/ProtoBuf.js/#pbjs-for-javascript
                 * for a list of what's available.
                 * default: []
                 */
                pbjsArgs: ['--no-encode'],

                /*
                 * Additional build targets, wich will bundled in root object.
                 * Some times it helpful if pb.js throws error
                 * when try to resolve type
                 * default: []
                 */
                additionalTargets: ['/path/to/additional/definitions']
              }
            }
        }]
    }
};
// myModule.js

/*
 * replaces e.g.:
 *
 * const protobuf = require('protobufjs/light');
 * const jsonDescriptor = require('json!my/compiled/protobuf.js');
 * const Root = protobuf.Root.fromJSON(jsonDescriptor);
 */
const Root = require('my/protobuf.proto');

Development

npm run lint # linting
npm run test # testing

Fresh up and fully refactored version of protobufjs-loader. Compatable with webpack 3 and 4.

Active maintenance with care and ❤️.

Feel free to send a PR.

Keywords

webpack

FAQs

Package last updated on 04 Nov 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.