ts-proto
ts-proto copied to clipboard
Feature: Importmap option
Currently, a proto import such as import google/protobuf/empty.proto generates an import statement like:
import { Empty } from "../../../../../google/protobuf/empty";
This assumes the file layout has ../../../../../google/protobuf/empty.ts in the correct place. However, it is desirable to map this to a different location such as ../../../../../external/com_google_protobuf/google/protobuf/empty.ts, or even some node_module like @google/wellknowntypes...
protoc-gen-go has a similar need for mapping imports and supports the M option, used like --go_opt=Mtest.proto=github.com/example.com/test.
emitImportedFiles=true is a possible workaround, but has other drawbacks and cannot be used in our case.
I propose a similar option, for example --ts_opt=M./google/protobuf/empty=./external/com_google_protobuf/google/protobuf/empty that would generate:
import { Empty } from "../../../../../external/com_google_protobuf/google/protobuf/empty";
This would involve PRs to both ts-proto and ts-poet.
Would you be amenable to such PRs?
I also need this option, particularly because I import files from vendor/ and want to map the vendor/ path to the repo root.
:tada: This issue has been resolved in version 1.126.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: