{"library":"protobufjs-loader","title":"protobufjs-loader","description":"Webpack loader for translating .proto definitions into protobuf.js modules, equivalent to running the pbjs CLI at build time. Current stable version is 3.1.1, released January 2025 with async/await refactor and custom TypeScript output locations. Requires webpack ^5.0.0 (breaking change from v2 to v3 dropped webpack 4 support). Supports both static-module and json-module targets, and optional pbts TypeScript declaration generation. Alternatives: grpc-tools or manual pbjs invocation. Release cadence irregular, maintained by kmontag.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install protobufjs-loader"],"cli":null},"imports":["import Root from './my.proto';","module: { rules: [ { test: /\\.proto$/, use: 'protobufjs-loader' } ] }","const Root = require('./my.proto');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.proto$/,\n        use: {\n          loader: 'protobufjs-loader',\n          options: {\n            target: 'static-module',\n            pbts: true\n          }\n        }\n      }\n    ]\n  }\n};\n\n// myModule.js\nimport Root from './my.proto';\n// Root is a protobuf.js Root instance, ready to use\nconst MyMessage = Root.lookupType('MyMessage');\nconst message = MyMessage.create({ field1: 'value' });\nconst buffer = MyMessage.encode(message).finish();\nconsole.log('Encoded message:', buffer);","lang":"javascript","description":"Configure webpack to load .proto files via protobufjs-loader, then import them as Root objects in your code.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}