Fails to Generate .pb.ts Files With Custom Root Defined
Closed this issue · 0 comments
yarn twirpscript
fails to generate .pb.ts
files when a custom root is defined in a .twirp.json
file.
Configuration
Node: 14.17.0
Twirpscript: 0.0.38
A .twirp.json
file with the following configuration:
{
"root": "./protos"
}
A project of the following folder structure
The Problem
In cli.ts
protosBeforeCompile
and protosAfterCompile
map over the list of file paths to make them relative before passing them to a checksum function which reads them from disk. This relative mapping produces invalid filepaths.
For example, the path exampleservice/haberdasher/v1/exampleservice.haberdasher.v1.pb.ts
becomes ../exampleservice/haberdasher/v1/exampleservice.haberdasher.v1.pb.ts
.
The Solution
It appears removing this mapping works for both my use case with a custom root defined as well as generation without a custom root defined.