Local code generation depending on remote module doesn't work right
coobeet opened this issue · 1 comments
Describe the bug
I'm working with a local proto directory that depends on googleapis/googleapis
remote module. When I import the remote type, the local generated code doesn't use remote deps. The generated code is as follows:
import { proto3 } from "@bufbuild/protobuf";
import { Operation } from "../../../google/longrunning/operations_pb.js";
The Operation
type should be imported from remote deps, but instead it's importing from local files which doesn't exsit.
My buf.yaml
is as follows:
version: v1
deps:
- buf.build/googleapis/googleapis
breaking:
use:
- FILE
lint:
use:
- DEFAULT
My buf.gen.yaml
is:
# buf.gen.yaml
version: v1
managed:
enabled: true
go_package_prefix:
except:
- buf.build/googleapis/googleapis
plugins:
# Go
- plugin: buf.build/protocolbuffers/go
out: gen/go
opt:
- paths=source_relative
- plugin: buf.build/bufbuild/connect-go
out: gen/go
opt:
- paths=source_relative
# JS
- plugin: buf.build/bufbuild/es
out: gen/js
- plugin: buf.build/bufbuild/connect-es
out: gen/js
- plugin: buf.build/bufbuild/connect-query
out: gen/js
Hey @coobeet, buf
does not generate code for dependencies, unless you specify the --include-imports
flag. For Go, you don't notice because the googleapis/googleapis proto files set a go_package option that points to pregenerated code.
The workaround is to use two buf.gen.yaml
files, and run the JS one with buf generate --template buf.gen.js.yaml --include-imports
.
For more context, see #262 and bufbuild/protobuf-es#457.