-
Notifications
You must be signed in to change notification settings - Fork 85
Description
Today, protoc --js_out generates JavaScript using CommonJS (require) or Closure-style imports. This works with Node.js and bundlers, but it does not produce native ES Modules (import/export) that browsers and modern toolchains expect.
Problem:
Generated *_pb.js files cannot be used directly as ES modules in browsers.
Projects like gRPC-Web are adding TypeScript and ESM-friendly stubs, but they cannot fully adopt ESM until the protobuf message code supports it.
Users must currently rely on bundlers (Webpack, Rollup, Vite, Closure Compiler, etc.) to convert CommonJS to ESM.
Request:
Add an option to --js_out to generate native ESM output (import/export), similar to how --import_style=commonjs or --import_style=typescript work today.
This would enable a full ESM workflow:
import { HelloRequest } from "./foo_pb.js";
import { FooClient } from "./foo_grpc_web_pb.js";
This aligns with the wider JavaScript ecosystem migration toward ESM as the standard module system.
Impact:
Allows protobuf users to consume generated code directly in browsers without bundlers.
Unlocks full ESM compatibility for downstream projects like gRPC-Web.