janestreet / bonsai

A library for building dynamic webapps, using Js_of_ocaml
MIT License
367 stars 39 forks source link

Examples raise exception #7

Closed neojski closed 4 years ago

neojski commented 4 years ago

I tried running hello world example from v0.14 tag but it raises an exception:

dune run main.exe
Entering directory '/home/neo/repos/bonsai'
Error: Don't know about directory web/examples/hello_world/main.exe specified
on the command line!
Done: 0/0 (jobs: 0)

When I run run it from the correct path it raises a different exception:

./_build/default/web/examples/hello_world/main.exe 
Unimplemented Javascript primitive caml_pure_js_expr!
hhugo commented 4 years ago

Bonsai is supposed to be used in a JavaScript environment (web browser). You probably want to build main.bc.js instead of main.exe

neojski commented 4 years ago

Oh, indeed, thanks Hugo. After modifying the path in index.html to ../../../../_build/default/web/examples/counters/bin/main.bc.js it works.

I wish I could just type "dune build" with no arguments.

neojski commented 4 years ago

@TyOverby, the examples still need updating to point to the right path.

TyOverby commented 4 years ago

instead of modifying the path inside index.html, you should ask dune to "build" index.html, which will cause it to be moved into the _build/default/web/examples/etc... path next to the js file. Then the link will work!

neojski commented 4 years ago

Ah, great, thanks!