sh git clone https://github.com/bucklescript/bucklescript.git --recursive
sh cd ./ocaml git checkout master ./configure -prefix \`pwd\
make world.opt make install export PATH=$(cwd)/bin:$PATH`
This install patched binaries into ./bin
and adds them to your current
command path.
Make sure you have ocamlopt.opt
in your $PATH
from the previous
step, then do the following:
sh cd ./jscomp npm_package_name=bs-platform make world export PATH=$(cwd)/jscomp/bin:$PATH
This install the compiler bsc.exe
into ./jscomp/bin
and adds it to your
current command path.
Create a simple OCaml program bs-hello/hello.ml
in a directory
adjacent to the bucklescript
:
sh cd .. # if you are still in the bucklescript directory mkdir bs-hello cd bs-hello echo 'print_endline "hello world";;' > hello.ml
Next, compile it with bsc.exe
, making sure to include the BuckleScript
runtime
and stdlib
:
sh bsc.exe -I ../bucklescript/jscomp/runtime -I ../bucklescript/jscomp/stdlib -c hello.ml
You should now have a file bs-hello/hello.js
. You can run it with Node
or any other JavaScript engine:
sh node hello.js
If everything goes well, you will see hello world
on your screen.