Registry / serialization / google-protocol-compiler

google-protocol-compiler

JSON →
library0.0.7jsnpmunverified

An experimental WebAssembly port of Google's protoc compiler, compiled from C++ protobuf source. Version 0.0.7 provides protoc functionality for Node.js and browser environments without native binaries. Distributed as an npm package, it supports generating code from .proto files for all standard languages (e.g., JavaScript, Python, C++, Java). The package exposes a command-line tool (when installed globally) and a programmable module. Current release cadence is low (last release 6+ years ago); it is not maintained by Google directly but is a community build. Key differentiator: runs entirely in-process/browser, no native protoc binary required.

npm install google-protocol-compiler
INSTALL
IMPORT
SIG · GOOGLE-PROTOCOL-CO
G
google-protocol-compiler
serializationjavascriptv0.0.7
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.

default (generateCode, onReady, etc.)
✓ const generator = require('google-protocol-compiler');
✗ import generator from 'google-protocol-compiler';
This package is CommonJS-only (experimental ESM not supported). No default ESM export.
onReady
✓ generator.onReady(() => { ... });
✗ generator.onReady().then(() => { ... });
onReady is callback-based, not Promise-based. It fires once when the WASM module is initialized.
generateCode
✓ const result = generator.generateCode(name, content, language, parameters);
✗ generator.generateCode({ name, content, language, parameters });
Takes four separate positional string arguments, not an options object. Returns an object with 'files' or 'error'.
languageList
✓ const langs = generator.languageList;
✗ generator.getLanguageList()
languageList is a synchronous property (array of strings), not a method.

Shows how to initialize the WASM compiler, generate JavaScript code from a .proto string, and log the output files.

const generator = require('google-protocol-compiler'); generator.onReady(() => { const name = 'test.proto'; const content = 'syntax = "proto3";\npackage test;\nmessage TestMsg { string name = 1; }'; const result = generator.generateCode(name, content, 'Javascript', 'import_style=commonjs'); if (result.error) { console.error('Error:', result.error); } else { result.files.forEach(f => console.log(f.name, ':', f.content.substring(0, 50))); } });
protoc --version
Debug
Known issues
deprecatedThis package is experimental and no longer maintained. Use the official native protoc binary or @bufbuild/protoc-gen-es for modern protobuf code generation.
fix
Switch to native protoc (https://github.com/protocolbuffers/protobuf/releases) or protobuf-es (https://github.com/bufbuild/protobuf-es).
affects: all
gotchaonReady callback may never fire if the WASM file fails to load (e.g., missing MIME type in browser).
fix
Ensure WASM is served with application/wasm MIME type, or set a timeout to detect failures.
affects: >=0.0.1
gotchagenerateCode language parameter is case-sensitive. 'Javascript' works, 'javascript' does not.
fix
Use 'Javascript' (capital J, rest lowercase) or refer to languageList.
affects: >=0.0.1
gotchaThe package bundles a large WASM binary (~5 MB). First use can be slow due to WASM compilation.
fix
Warm up the module early with onReady, or consider streaming compilation in browsers.
affects: >=0.0.1
Errors
Common errors & fixes
Cannot find module 'google-protocol-compiler'
Package not installed or missing from node_modules.
fix
Run 'npm install google-protocol-compiler' or add to package.json.
TypeError: generator.onReady is not a function
Module not loaded correctly (e.g., required before onReady is available or wrong import style).
fix
Ensure require('google-protocol-compiler') is used (not import) and that the variable is named 'generator'.
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'generateCode')
Trying to call generateCode before onReady has fired, or the module hasn't initialized.
fix
Always invoke generateCode inside the onReady callback or after a promise that waits for readiness.
Upgrade
Version history
0.0.7latest on npm
Audit
Dependencies
google-protobufoptionalRuntime dependency for generated JavaScript code when using js_out; the module itself depends on google-protobuf for jspb and protobuf runtime.
Agent activity
8 hits · last 30 days
node
8
Resources
google-protocol-compiler — npm install google-protocol-compiler · libregistry