Skip to content

common+dts and typescript output folder paths are incorrect #531

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

Open
gtalarico opened this issue Apr 10, 2019 · 3 comments
Open

common+dts and typescript output folder paths are incorrect #531

gtalarico opened this issue Apr 10, 2019 · 3 comments

Comments

@gtalarico
Copy link

gtalarico commented Apr 10, 2019

I am having an issue similar to #336 which appears to have been resolved.

common js - works as expected

protoc \
        --proto_path=. \
        --proto_path=./third_party \
        --js_out=import_style=commonjs:js-common \
        --grpc-web_out=import_style=commonjs,mode=grpcwebtext:js-common \
        $FILE_LIST

Output Dir

js-common/
└── service
    └── resource
        ├── address_pb.js
        └── shared_pb.js

service_grpc_web_pb.js includes correct imports and can be resolved:

var service_resource_address_pb = require('../../service/resource/address_pb.js')

commonjs+dts or typescript - generated files are placed in the incorrect folder

protoc \
        --proto_path=. \
        --proto_path=./third_party \
        --js_out=import_style=commonjs+dts:js-commonjs-dts \
        --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:js-commonjs-dts \
        $FILE_LIST \

Output Dir

js-commonjs-dts/
├── service
│   └── resource
│       ├── service_grpc_web_pb.d.ts
│       ├── service_grpc_web_pb.js
│       └── service_pb.d.ts
├── address_pb.js
└── shared_pb.js

In this case, the imports look the same:

var service_resource_address_pb = require('../../service/resource/address_pb.js')

But the relative path, in this case, is incorrect and cannot be resolved.

@stanley-cheung
Copy link
Collaborator

Can you share your .proto please?

@gtalarico
Copy link
Author

gtalarico commented Apr 10, 2019

Hi @stanley-cheung - Unfortunately I can't share the full set.
Does this help? Thanks!

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

package service.space;

import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "protoc-gen-swagger/options/annotations.proto";
import "service/resource/address.proto";
import "service/resource/shared.proto";
import "github.com/mwitkow/go-proto-validators/validator.proto";
// ...
// Services
// service/resource/shared.proto
syntax = "proto3";

package service.space;

import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";

message LatitudeLongitudeCoordinate {
// ...
}
// service/resource/address.proto
syntax = "proto3";

package service.space;

import "service/resource/shared.proto";

message Address {
// ...
}

@weilip1803
Copy link

This will work

protoc
--proto_path=./first/
--proto_path=./second/
--js_out=import_style=commonjs,binary:./generated_proto
--grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:./generated_proto
$FILE_LIST \

Not very sure about the import style binary do. Will go read up more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants