Open gertcuykens opened 6 years ago
This is also a thing I would like to have!
AFAIK there is no way to access flags (configuration) for other protoc-plugins, in other words, ts-protoc-gen can only read flags present in the ts_out
parameter.
Your alternative suggestion should be possible however I'm not sure I see the use case; could this not be achieved with a post-build step?
https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
Please note that the compiler does not include files that can be possible outputs; e.g. if the input includes index.ts, then index.d.ts and index.js are excluded. In general, having files that differ only in extension next to each other is not recomended.
Sure it can be done post build, but for me that means ts-protoc-gen is the only cmd that need post processing in my generation chain.
Thanks for clarifying @gertcuykens; just to confirm, you want the ability to specify an alternative location to write the javascript files generated for the grpc-web service stubs? If so, my proposed flag syntax would be:
protoc -I=. grpc.proto \
--js_out=import_style=commonjs,binary:./pkg \
--plugin=protoc-gen-ts=/Users/gert/node/bin/protoc-gen-ts \
--ts_out=service=true,service_out=./pkg:./src
Where the JavaScript files generated for the grpc-web services will be written to ./pkg
and the .d.ts
files will be written to ./src
Please can you confirm this would fit your intended use case, or suggest alternatives? Thanks.
Yep that would be perfect. Maybe ommit service=true
when using service_out=./pkg
if possible, because service will always be true when using service out?
protoc -I=. grpc.proto \
--js_out=import_style=commonjs,binary:./pkg \
--plugin=protoc-gen-ts=/Users/gert/node/bin/protoc-gen-ts \
--ts_out=service_out=./pkg:./src
I believe this is now obsolete as services are always generated in the latest version. @gertcuykens could you confirm the latest version of ts-protoc-gen
resolves this problem?
Nope ts-protoc-gen@0.7.6 still can't separate typescript files form js files each in there own directory
Please consider when
service=true
to use thejs_out
path to store the generated service js file instead of using,ts_out
one. Alternatively if the previous isn't possibleservice=path/to/jsout
maybe, thanks.