Back
Close

Introduction to Reason Compilation

[CG]Nick
2,734 views
Previous: Step 6

7 - Compile to JavaScript

Would you like some sweet, sweet interop with the JS ecosystem?

We're gonna use BuckleScript, an OCaml-to-JS compiler that emits really, really clean output.

The other option is js_of_ocaml, a mature and battle-tested compiler.

We're gonna use real third-party dependencies this time around. Check the new package.json's dependencies field (a reason binding to JS functions) and devDependencies field (BuckleScript compiler). npm install in the current directory to get them.

Making this work is surprisingly simple. See the updated run.sh. We've also made modifications to .gitignore and .merlin.

Make sure you read the compiled output. Yes, read it. Trust us on this one!

"Run"
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
print_endline MyDep.secret;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants