Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local code generation depending on remote module doesn't work right #688

Closed
coobeet opened this issue Jun 23, 2023 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@coobeet
Copy link

coobeet commented Jun 23, 2023

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
@coobeet coobeet added the bug Something isn't working label Jun 23, 2023
@timostamm
Copy link
Member

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.

@timostamm timostamm closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants