Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Can't run examples #137

Open
tarasglek opened this issue Dec 3, 2024 · 7 comments
Open

[BUG] Can't run examples #137

tarasglek opened this issue Dec 3, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@tarasglek
Copy link

tarasglek commented Dec 3, 2024

Describe the bug

  1. Ran all the build commands from https://github.com/ocaml-wasm/wasm_of_ocaml/tree/main/examples
    • dune build @examples/default
    • dune build @examples/boulderdash/default --profile wasm
  2. Saw some errors
dune build @examples/default
File "lib/lwt/dune", line 4, characters 24-27:
4 |  (libraries js_of_ocaml lwt)
                            ^^^
Error: Library "lwt" not found.
-> required by library "js_of_ocaml-lwt" in _build/default/lib/lwt
-> required by executable boulderdash in examples/boulderdash/dune:2
-> required by _build/default/examples/boulderdash/boulderdash.bc.js
-> required by alias examples/boulderdash/default in
   examples/boulderdash/dune:18
File "examples/graphics/dune", line 4, characters 12-36:
4 |  (libraries js_of_ocaml-lwt.graphics)
                ^^^^^^^^^^^^^^^^^^^^^^^^
Error: Library "js_of_ocaml-lwt.graphics" in _build/default/lib/lwt/graphics
is hidden (optional with unavailable dependencies).
-> required by _build/default/examples/graphics/main.bc.js
-> required by alias examples/graphics/default in examples/graphics/dune:14
  1. Ran python3 -m http.server in _build/default/examples
  2. Every example that I navigate to is missing .bc.js files.
  • eg GET http://b550:8000/graph_viewer/viewer_js.bc.js net::ERR_ABORTED 404 (File not found)

Why aren't .bc.js files being generate? Is there some instruction missing?

 wasm_of_ocaml/_build/default/examples$ find -name \*.bc.js
./test_wheel/test_wheel.bc.js

Expected behavior
Demos should work
Versions
Testing with git sha e6ca2d3214908d4c3300d33efcbccec359d8eaf2 of wasm_of_ocaml

@tarasglek tarasglek added the bug Something isn't working label Dec 3, 2024
@hhugo
Copy link
Contributor

hhugo commented Dec 3, 2024

You need to install a bunch of dependencies.
opam install ./ --deps-only -t at the root of the repo should do it.

@tarasglek
Copy link
Author

Thank you. Would be great to have that in the examples README.md

@tarasglek
Copy link
Author

Really cool to see how small the compiled artifacts are. Is there a blog or some design docs for this? I think these might be the smallest working wasm binaries I've seen. Curious why stuff is packaged inline in .js instead of .wasm, etc

@vouillon
Copy link
Collaborator

vouillon commented Dec 3, 2024

The Wasm code is not inline but in the .bc.wasm.assets directory.

@tarasglek
Copy link
Author

tarasglek commented Dec 3, 2024

i was looking at browser network console, only bc.js was downloaded. Thus assumed it was inlined there

@vouillon
Copy link
Collaborator

vouillon commented Dec 3, 2024

Oh, are you sure you compiled the examples with the --profile wasm option? By default, we are only generating some JavaScript code.

@tarasglek
Copy link
Author

tarasglek commented Dec 3, 2024

Looked at commands above, realizedI just built one example with --profile wasm..Now it works as expected, very cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants