Skip to content

feat(proto): ts_proto_closure generates a proto graph as one library - #380

Merged
mikn merged 1 commit into
mainfrom
mikn/ts-proto-closure
Nov 2, 2026
Merged

mikn merged 1 commit into
mainfrom
mikn/ts-proto-closure

Conversation

@mikn

@mikn mikn commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Since 2026-10-29, a caller that generates a whole schema tree with ts_proto_library copies the proto import graph into deps by hand. The Lovable monorepo keeps a generated per-proto deps map and a hand-kept googleapis import list for its six TypeScript trees, and a missed entry breaks that tree's build.

  • What changes: ts_proto_closure takes protos, finds every proto_library they reach (through deps, exports and aliases), generates each one with the same protoc action ts_proto_library uses, and compiles the result as one source-mode ts_compile.
  • Goal: the Bazel proto graph is the only copy of the import graph; deps names only the protobuf runtime.
  • Evidence: //tests/proto:closure_files_test builds a closure over a source-less root (which exports message_proto) and service_proto, and asserts it generates exactly common_pb.ts, message_pb.ts and service_pb.ts: no descriptor_pb.ts, a well-known type protobuf-es imports from @bufbuild/protobuf/wkt; the closure's own type check fails if an imported file is missing.
  • Risk and rollback: additive. ts_proto_library keeps its API, rule shape and output; both rules share one protoc helper. Revert the commit to roll back.
  • Next: the monorepo bumps its pin and replaces its per-proto wiring and the hand-kept import map with ts_proto_closure; its six committed trees stay byte-identical.

Scope

The well-known types are skipped by repository: every proto_library in the protobuf module. That matches protobuf-es 2.12.0's runtime list (wktPublicImportPaths) for every target the module exports; a schema that imports a non-WKT test proto from that module would fail to compile, loudly. bootstrap_wkt=true is refused in a closure. Gazelle's generated per-proto ts_proto_library wrappers are unchanged, and Gazelle neither writes nor indexes ts_proto_closure.

🤖 Generated with Claude Code

ts_proto_library generates one proto_library's direct sources, so a caller
that wants a whole schema tree mirrors the proto import graph in deps by hand.
ts_proto_closure takes protos, walks deps, exports and aliases with an aspect,
runs the same per-library protoc action for every proto_library it reaches but
the protobuf module's own (protobuf-es imports those from its runtime), and
compiles the result as one source-mode ts_compile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mikn
mikn merged commit 023128c into main Nov 2, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant