protocolbuffers / protocolbuffers/protobuf-javascript

Support for ES Modules (import/export) in protoc --js_out

Open
#248 1 comment 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
471
Forks
91
Avg merge
3h 57m
Merged PRs (30d)
2

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how protoc --js_out handles the existing --import_style=commonjs and --import_style=typescript options, then inspect the generated *_pb.js output paths. Done means a new option produces native ESM import/export output that works directly in browsers, with coverage for the generated module behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.