{"id":25648,"library":"google-protocol-compiler","title":"protoc (Protocol Buffers Compiler) - WebAssembly","description":"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.","status":"deprecated","version":"0.0.7","language":"javascript","source_language":"en","source_url":"https://github.com/google/protobuf","tags":["javascript"],"install":[{"cmd":"npm install google-protocol-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add google-protocol-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add google-protocol-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for generated JavaScript code when using js_out; the module itself depends on google-protobuf for jspb and protobuf runtime.","package":"google-protobuf","optional":true}],"imports":[{"note":"This package is CommonJS-only (experimental ESM not supported). No default ESM export.","wrong":"import generator from 'google-protocol-compiler';","symbol":"default (generateCode, onReady, etc.)","correct":"const generator = require('google-protocol-compiler');"},{"note":"onReady is callback-based, not Promise-based. It fires once when the WASM module is initialized.","wrong":"generator.onReady().then(() => { ... });","symbol":"onReady","correct":"generator.onReady(() => { ... });"},{"note":"Takes four separate positional string arguments, not an options object. Returns an object with 'files' or 'error'.","wrong":"generator.generateCode({ name, content, language, parameters });","symbol":"generateCode","correct":"const result = generator.generateCode(name, content, language, parameters);"},{"note":"languageList is a synchronous property (array of strings), not a method.","wrong":"generator.getLanguageList()","symbol":"languageList","correct":"const langs = generator.languageList;"}],"quickstart":{"code":"const generator = require('google-protocol-compiler');\ngenerator.onReady(() => {\n  const name = 'test.proto';\n  const content = 'syntax = \"proto3\";\\npackage test;\\nmessage TestMsg { string name = 1; }';\n  const result = generator.generateCode(name, content, 'Javascript', 'import_style=commonjs');\n  if (result.error) {\n    console.error('Error:', result.error);\n  } else {\n    result.files.forEach(f => console.log(f.name, ':', f.content.substring(0, 50)));\n  }\n});","lang":"javascript","description":"Shows how to initialize the WASM compiler, generate JavaScript code from a .proto string, and log the output files."},"warnings":[{"fix":"Switch to native protoc (https://github.com/protocolbuffers/protobuf/releases) or protobuf-es (https://github.com/bufbuild/protobuf-es).","message":"This package is experimental and no longer maintained. Use the official native protoc binary or @bufbuild/protoc-gen-es for modern protobuf code generation.","severity":"deprecated","affected_versions":"all"},{"fix":"Ensure WASM is served with application/wasm MIME type, or set a timeout to detect failures.","message":"onReady callback may never fire if the WASM file fails to load (e.g., missing MIME type in browser).","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use 'Javascript' (capital J, rest lowercase) or refer to languageList.","message":"generateCode language parameter is case-sensitive. 'Javascript' works, 'javascript' does not.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Warm up the module early with onReady, or consider streaming compilation in browsers.","message":"The package bundles a large WASM binary (~5 MB). First use can be slow due to WASM compilation.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install google-protocol-compiler' or add to package.json.","cause":"Package not installed or missing from node_modules.","error":"Cannot find module 'google-protocol-compiler'"},{"fix":"Ensure require('google-protocol-compiler') is used (not import) and that the variable is named 'generator'.","cause":"Module not loaded correctly (e.g., required before onReady is available or wrong import style).","error":"TypeError: generator.onReady is not a function"},{"fix":"Always invoke generateCode inside the onReady callback or after a promise that waits for readiness.","cause":"Trying to call generateCode before onReady has fired, or the module hasn't initialized.","error":"Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'generateCode')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}