%%raw special ReScript call takes your code string and pastes it as-is into the output. You've now technically written your first ReScript file!
%%raw lets you embed top-level raw JS code,
%raw lets you embed expression-level JS code:
The above code:
declared a ReScript variable
then called that function in ReScript.
You can also drop a
%debugger expression in a body:
Embedding raw JS snippets isn't the best way to experience ReScript, though it's also highly useful if you're just starting out. As a matter of fact, the first few ReScript projects were converted through:
pasting raw JS snippets inside a file
examining the JS output (identical to the old hand-written JS)
gradually extract a few values and functions and making sure the output still looks OK
At the end, we get a fully safe, converted ReScript file whose JS output is clean enough that we can confidently assert that no new bug has been introduced during the conversion process.
We have a small guide on this iteration here. Feel free to peruse it later.