Compiling incr_dom examples?

I can’t figure out how to compile the incr_dom examples. I’ve figured out build issues with web searches in the past, but none of the advice I’ve come across has helped.

Steps to reproduce:

Using dune.3.19.1
Using opam.2.2.1

  1. opam sw create incr_dom 5.1.0; eval $(opam env); opam install incr_dom
  2. Clone the incr_dom repo
  3. git switch v0.17 (following the advice (discuss.ocaml.or g/t/need-help-compiling-incr-dom-examples/2772/5))
  4. cd to examples/text_input
  5. dune build yields error 1.
  6. Copy text_input out to my home directory as recommended by Leonidas here
  7. dune build yields error 2
  8. dune init project text_input . yields error 3
  9. dune init project text_input
  10. mv text_input/{dune-project,text-input.opam} .; rm -rf text_input
  11. dune build yields error 4
  12. dune build bin/main.bc.js yields error 5
  13. add “js” to the modes in bin/dune (following advice here)

… Well I’ll be darned, dune build bin/main.bc.js works. And so does dune build bin/index.html.

How do I get these to build using just dune build? And am I missing anything?

I’ll follow the tutorial now but I want to post this in case anyone in the future wants a fuller answer/walkthrough.

error 1
File "src/dune", line 10, characters 3-33:
10 |    bonsai_concrete.ui_time_source))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Library "bonsai_concrete.ui_time_source" not found.
-> required by library "incr_dom" in _build/default/src
-> required by executable main in example/text_input/bin/dune:3
-> required by _build/default/example/text_input/bin/main.bc
-> required by alias example/text_input/bin/all
-> required by alias example/text_input/default

error 2
Error: I cannot find the root of the current workspace/project.
If you would like to create a new dune project, you can type:

    dune init project NAME

error 3
Error: The current project defines some public elements, but no opam packages
are defined.
Please add a <package>.opam file at the project root so that these elements
are installed into it.

error 4
Error: The package text_input does not have any user defined stanzas attached
to it. If this is intentional, add (allow_empty) to the package definition in
the dune-project file
-> required by _build/default/text_input.install
-> required by alias all
-> required by alias default
File "test/dune", line 3, characters 30-46:   
3 |  (libraries async_kernel core incr_dom_testing
                                  ^^^^^^^^^^^^^^^^
Error: Library "incr_dom_testing" not found.
-> required by library "incr_dom_text_input_example_test" in
   _build/default/test
-> required by
   _build/default/test/.incr_dom_text_input_example_test.objs/native/incr_dom_text_input_example_test.cmx
-> required by _build/default/test/incr_dom_text_input_example_test.a
-> required by alias test/all
-> required by alias default

error 5
Error: Don't know how to build bin/main.bc.js