grpc / grpc/grpc-web

Request: Separate libraries per proto file (even though one imports the other)

Open
#776 0 comments 4 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
9.3k
Forks
802
Avg merge
1d 7h
Merged PRs (30d)
5

Description

How do I properly generate JS stubs for A.proto that imports B.proto, where there is already a client library generated for B.proto? What I would basically want is that both .proto files have their own generated JS library and I can just install both in a JS project separately.

I have two projects with a .proto file, and one imports the other. Both projects are maintained and compiled separately. The setup is as follows:

```
domain project:
|-- company
`-- domain
`-- domain.proto

service project:
|-- company
`-- service
`-- service.proto
```

```
// domain.proto
syntax = "proto3";

message User {
string name = 1;
}
```

```
// service.proto
syntax = "proto3";

import company/domain/domain.proto

message Ping {
domain.User user = 1;
}
```
I can compile `company/service/service.proto` using `protoc /company/service/service.proto` but the resulting .js file tries to import from a folder in the same (npm) project:

```
var company_domain_domain_pb = require('../../company/domain/domain_pb.js');
```
But `domain` is installed as a separate npm package. Somehow it seems that I have to compile both `.proto` files at once for grpc-web to set the path correctly. This differs from the Python grpc compiler which generates separate libraries that I can `pip install` separately. I just have to make sure to import both libraries in the Python case. I would expect something similar with the JavaScript compiler.

As can be read [here](https://groups.google.com/forum/#!topic/grpc-io/GzKW3KZTnV4) this is not yet supported, that's why I'm posting this request here (as requested).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.