How to print ppx'ed code from .res source file?

Having .re file, I can do:

cat $SRC | bsrefmt --parse re --print binary | $PPX /dev/stdin /dev/stdout | bsrefmt --parse binary --interface false

But bsrefmt --parse accepts either re or ml, not res. So I can’t print ppx’ed source of rescript file using this method.

Is there any other way?

The ReScript compiler doesn’t expose a way to accept binary as input format.
Is this primarily used when developing a ppx?

Yeah, I usually explore generated code during development to figure out where did I go wrong.

It’s also a way how we test the graphql-ppx (snapshot testing). Would be great to have binary input/output added to the rescript compiler.

1 Like