rescript-relay
is made up of these parts:
First thing's first - there's a suite of integration tests inside of /packages/rescript-relay/__tests__
. The ambition is that these tests should cover everything needed to ensure RescriptRelay is working as intended. This includes the bindings, the language plugin and the PPX - everything. You run them by doing yarn test
in /packages/rescript-relay
.
Any feature added or fix done should consider whether that case is covered in the integration tests, and add tests for it if possible.
Please note that testing your local changes with the integration tests requires some recompiling. There's information on how to do that for each individual part below.
/packages/rescript-relay/src
contains all the ReScript code shipped in the package. You build it by running yarn build
in /packages/rescript-relay
.
bsconfig.json
is only used for development, the actual bsconfig.json
that'll be copied to the published package is located in bsconfig.release.json
. This setup isn't great and it's likely that we'll move to using the same bsconfig.json
for dev and release, with a script stripping unwanted things from the config before copying it to the release bundle.
The PPX is located in /packages/rescript-relay/rescript-relay-ppx
and is built with esy
. There are a few tests for the PPX located in /packages/rescript-relay/rescript-relay-ppx/test/TestFile.re
.
Ensure you have esy
installed by running npm install -g esy
. Go to /packages/rescript-relay/rescript-relay-ppx
and run esy
. This will take some time as it bootstraps and compiles the project. After this finishes, the PPX will be built, and the relevant file will be located at /packages/rescript-relay/rescript-relay-ppx/_esy/default/build/default/bin/RescriptRelayPpxApp.exe
.
If you want to test your changes to the PPX using the integration tests, run esy
in the PPX folder to build the PPX, and then run yarn rescript clean && yarn build && yarn test
in /packages/rescript-relay
. This will clean and rebuild the tests before running them, ensuring that your changes to the PPX is picked up.
This a huge part of what RescriptRelay actually is. The language plugin takes the Flow types generated by the Relay compiler, and translates them to ReScript types + does a number of other things like generate helpers and what not.
It's made up of a TypeScript part that's the actual plugin that plugs into the Relay JS compiler, and a ReasonML/OCaml native binary in the folder packages/rescript-relay-bin
which takes raw Flow types from the Relay compiler, generates ReScript, and sends that back. The TypeScript part calls out to this binary to get the generated ReScript types.
The TypeScript part is located in /packages/rescript-relay/language-plugin
, and you build it by doing yarn build
in that folder. However, the bulk of things you'll want to look at is in rescript-relay-bin
, which is a native ReasonML/OCaml binary that you build using esy
. Please refer to the section above on using esy
for the PPX for instructions on how to get esy
set up.
Whenever you want to test changes you've made to the type generation, you need to run ./copyIntoPlace.sh
inside of packages/rescript-relay-bin
. This will copy the built binary into the place the language plugin expects it to be in.
The language plugin has a fairly comprehensive test suite that can be run by doing yarn test
. The tests are sadly mostly snapshot tests, which can make them a bit hard to decipher, but as of now that's the way I felt has given the most "bang for the buck".
You can build the language plugin in full by running yarn build
in the root folder of the language plugin. This will build and bundle the plugin. Remember that you need to build rescript-relay-bin
first though so there's a type gen binary available.
It's a good idea to run the full integration tests after changing the language plugin. You can do that by first building the language plugin as described above, and then run yarn build:test
in /packages/rescript-relay
. It'll show an error message, but that's fine (and expectd).
Running yarn build:test
will rerun the Relay compiler for the integration test suite using the newly built plugin. After that runs, you can run yarn test
in /packages/rescript-relay/
again to run the integration tests with the changes you made.
The docs are located in /rescript-relay-documentation
. It's built with Docosaurus, and to develop locally you simply do yarn && yarn start
in that folder. Currently only @zth can do the prod release of this as it's tied to his now.sh
account, but this may change in the future.
Releases are done automatically via an on-demand workflow in GitHub Actions.