Registry / devops / grpc-loader

grpc-loader

JSON →
library2.0.1jsnpmunverified

Webpack loader that converts .proto files into autogenerated JavaScript files for use with gRPC. Version 2.0.1 is the latest stable release; appears to be a maintenance-only project with no recent updates. Supports both static codegen (via google-protobuf) and dynamic codegen (via grpc.load). Requires peer dependencies: google-protobuf, grpc, protobufjs, and webpack 3.x. Differentiates by providing a straightforward webpack integration for gRPC proto files, though the API is considered verbose by the author.

npm install grpc-loader
INSTALL
IMPORT
SIG · GRPC-LOADER
G
grpc-loader
devopsjavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

grpc-loader
rules: [{ test: /\.proto$/, loader: 'grpc-loader' }]
import grpc from 'grpc-loader'
This is a webpack loader, not a regular module; it cannot be imported directly.
proxyquire or manual require
const proto = require('./test.proto');
import proto from './test.proto';
Webpack loaders are invoked on require() calls; ESM import may not trigger the loader depending on configuration.
grpc
const grpc = require('grpc');
import grpc from 'grpc';
The grpc package is a peer dependency; use CommonJS require to avoid issues with ESM interop.

Configures webpack to load .proto files with grpc-loader and demonstrates usage with static code generation.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.proto$/, loader: 'grpc-loader', options: { static: true, // or false for dynamic // convertFieldsToCamelCase: true, // binaryAsBase64: false, // longsAsStrings: true, // enumsAsStrings: true, }, }, ], }, }; // In your code (when using static codegen) const proto = require('./path/to/your.proto'); console.log(proto.services); // { MyService: { ... } } console.log(proto.messages); // { MyMessage: { ... } }
Debug
Known issues
breakingRequires webpack 3.x - not compatible with webpack 4 or 5
fix
Use a different loader or upgrade webpack and migrate to @grpc/proto-loader or grpc-tools.
affects: 2.0.1
deprecatedThe grpc npm package is deprecated in favor of @grpc/grpc-js
fix
Switch to @grpc/proto-loader and @grpc/grpc-js instead of using grpc-loader.
affects: >=2.0.0
gotchaPeer dependencies google-protobuf and protobufjs are optional but may cause unresolved version conflicts
fix
Ensure you have exactly one version of each peer dep installed. Use --legacy-peer-deps if needed.
affects: <=2.0.1
gotchaThe loader must be specified in webpack rules, not as a direct import
fix
Do not attempt to import 'grpc-loader' in your source code; only reference it in webpack config.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'grpc-loader'
grpc-loader is not installed or webpack cannot find it in node_modules.
fix
Run npm install --save-dev grpc-loader (or yarn add --dev grpc-loader).
Error: Cannot find module 'google-protobuf'
Static code generation is enabled but google-protobuf peer dependency is missing.
fix
Install google-protobuf: npm install google-protobuf or yarn add google-protobuf.
Error: Cannot find module 'grpc'
Dynamic code generation is enabled but grpc peer dependency is missing or not installed.
fix
Install grpc: npm install grpc or yarn add grpc. Note: grpc is deprecated; consider switching to @grpc/grpc-js.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
google-protobufoptionalpeer dependency for static code generation
grpcrequiredpeer dependency for dynamic code generation
protobufjsoptionalpeer dependency used by grpc dynamic loading
webpackrequiredpeer dependency as a webpack loader; v3.x required
Agent activity
4 hits · last 30 days
node
4
Resources
grpc-loader — npm install grpc-loader · libregistry