rescript-lang / rescript-compiler

The compiler for ReScript.
https://rescript-lang.org
Other
6.6k stars 440 forks source link

Possibility of emitting binary AST and accepting binary AST #5360

Open jfrolich opened 2 years ago

jfrolich commented 2 years ago

Currently, it's not possible to emit a binary AST or accept a binary AST using the rescript format command line tool. I am working on a more tightly integrated version of graphql-ppx and it is now dependent on refmt for this (and thus is in ReasonML instead of ReScript). This is necessary for snapshot testing. To properly test the ppx I need to go from source code -> binary AST -> ppx -> binary AST -> source code. An example on how this can be achieved with refmt is the following command:

refmt --parse re --print binary operations/customDecoder.re | ppx.exe /dev/stdin /dev/stdout | refmt --parse binary --print re

Other solutions are also welcome, but without snapshot testing, it's really hard to know if a ppx is behaving correctly.

Are you open for a PR to achieve this? (even if it's undocumented that would be fine)

amiralies commented 2 years ago

you probably can use syntax repo. it emits an executable that prints/parses binary ast.

jfrolich commented 2 years ago

Nice. I'll probably do that, but I would need to vendor it because I want to have 0 (OCaml) dependencies. So I still would rather have this functionality as part of the rescript compiler.

stale[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.