Skip to content

Ot_picture_uploader: fix build with js_of_ocaml >= 6.4.0#267

Merged
hhugo merged 2 commits into
ocsigen:masterfrom
hhugo:fix-inputElement-files-opt
Jul 2, 2026
Merged

Ot_picture_uploader: fix build with js_of_ocaml >= 6.4.0#267
hhugo merged 2 commits into
ocsigen:masterfrom
hhugo:fix-inputElement-files-opt

Conversation

@hhugo

@hhugo hhugo commented Jul 2, 2026

Copy link
Copy Markdown
Member

Since js_of_ocaml 6.4.0, Dom_html.inputElement's files field is typed File.fileList Js.t Js.opt (nullable) instead of a plain File.fileList Js.t.

Ot_picture_uploader.process_file and bind_input call ##item directly on input##.files without unwrapping the Js.opt, so the module no longer compiles against js_of_ocaml ≥ 6.4.0:

File "src/widgets/ot_picture_uploader.eliom", line 476, characters 26-31:
Error: This expression has type File.fileList Js.t Js.opt
       but an expression was expected of type < .. > Js.t
       Types for method get are incompatible

This fixes both call sites by unwrapping the nullable files with an extra Js.Opt.case before calling item. Behaviour is unchanged for the non-null case; a null files now takes the same empty/onerror branch as an empty file list.

Verified the exact expression type-checks against js_of_ocaml 6.x (inputElement.files : File.fileList t opt readonly_prop).

🤖 Generated with Claude Code

hhugo added a commit to hhugo/opam-repository that referenced this pull request Jul 2, 2026
ocsigen-toolkit 4.2.0 does not build against js_of_ocaml >= 6.4.0:
since 6.4.0, Dom_html.inputElement##.files is typed
File.fileList Js.t Js.opt (nullable) and Ot_picture_uploader calls
##item on it without unwrapping the opt.

Fixed upstream in ocsigen/ocsigen-toolkit#267; cap the existing
release in the meantime.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hhugo added a commit that referenced this pull request Jul 2, 2026
js_of_ocaml 6.4.0 changed the Dom_html API (inputElement), which breaks
the build of src/widgets/ot_picture_uploader.eliom
("The value input has type Dom_html.inputElement Js.t ..."). Rather than
depend on the not-yet-released source fix (#267), cap js_of_ocaml below
6.4 so CI stays on the 6.3.x line until we adopt 6.4 deliberately.

The dune < 3.24 pin is still required: the 6.3.x wasm_of_ocaml runtime
derives its wat-module names from dune-variable paths the same way 6.4.0
does, so it also breaks under dune 3.24's leading-"./" path form.

Also replace the hardcoded binaryen download in the Build workflow with
the Aandreba/setup-binaryen action already used by the docs workflow (and
by js_of_ocaml's own CI), so binaryen is provisioned on macOS too and the
version is no longer pinned by hand.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hhugo added a commit that referenced this pull request Jul 2, 2026
* ci: pin dune < 3.24 to fix wasm_of_ocaml build

dune 3.24 changed dune-variable paths to a leading-"./" form
(ocaml/dune#15156). wasm_of_ocaml-compiler 6.4.0 (pulled in by eliom)
derives its wat-module names from those paths, so the "module:path"
lines it feeds to wasmoo_link_wasm become malformed and the build fails
with "The runtime contains unknown imports", breaking both the Build and
Documentation workflows at the `opam install . --deps-only` step.

Pin dune to 3.23.1 before the dependency install until js_of_ocaml 6.4.1
(which fixes this upstream, ocsigen/js_of_ocaml#2371) reaches the opam
repository, at which point the pin can be dropped. A bare `dune<3.24`
constraint on `opam install --deps-only` does not bind the transitive
version, so an explicit pin is required.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Add missing lwt_ppx dependency

src/widgets/dune uses lwt_ppx as a preprocessor (both the server and
client libraries), but it was never declared in the package depends --
it used to be pulled in transitively. With the current eliom that
transitive path is gone, so the build fails with
`Error: Library "lwt_ppx" not found` at `dune build @install`.

Declare lwt_ppx explicitly and regenerate ocsigen-toolkit.opam.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Cap js_of_ocaml < 6.4 and use setup-binaryen action

js_of_ocaml 6.4.0 changed the Dom_html API (inputElement), which breaks
the build of src/widgets/ot_picture_uploader.eliom
("The value input has type Dom_html.inputElement Js.t ..."). Rather than
depend on the not-yet-released source fix (#267), cap js_of_ocaml below
6.4 so CI stays on the 6.3.x line until we adopt 6.4 deliberately.

The dune < 3.24 pin is still required: the 6.3.x wasm_of_ocaml runtime
derives its wat-module names from dune-variable paths the same way 6.4.0
does, so it also breaks under dune 3.24's leading-"./" path form.

Also replace the hardcoded binaryen download in the Build workflow with
the Aandreba/setup-binaryen action already used by the docs workflow (and
by js_of_ocaml's own CI), so binaryen is provisioned on macOS too and the
version is no longer pinned by hand.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Since js_of_ocaml 6.4.0, `Dom_html.inputElement`'s `files` field is
typed `File.fileList Js.t Js.opt` (nullable) instead of a plain
`File.fileList Js.t`. `process_file` and `bind_input` called `##item`
directly on `input##.files` without unwrapping the `Js.opt`, which no
longer type-checks:

  Error: This expression has type File.fileList Js.t Js.opt
         but an expression was expected of type < .. > Js.t

Unwrap the nullable `files` with an extra `Js.Opt.case` before calling
`item`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hhugo hhugo force-pushed the fix-inputElement-files-opt branch from e4d8cb0 to bbc3e3d Compare July 2, 2026 13:55
The Ot_picture_uploader fix in this PR relies on the js_of_ocaml 6.4.0
Dom_html inputElement API, so the toolkit no longer builds against
older js_of_ocaml. Bump the lower bound to 6.4.0 (this also drops the
temporary < 6.4 cap ocsigen#268 added while the source was incompatible).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hhugo hhugo force-pushed the fix-inputElement-files-opt branch from 7dc291b to 3125321 Compare July 2, 2026 14:09
@hhugo hhugo merged commit 9f46ed0 into ocsigen:master Jul 2, 2026
3 checks passed
@balat balat mentioned this pull request Jul 2, 2026
mseri pushed a commit to paurkedal/opam-repository that referenced this pull request Jul 3, 2026
ocsigen-toolkit 4.2.0 does not build against js_of_ocaml >= 6.4.0:
since 6.4.0, Dom_html.inputElement##.files is typed
File.fileList Js.t Js.opt (nullable) and Ot_picture_uploader calls
##item on it without unwrapping the opt.

Fixed upstream in ocsigen/ocsigen-toolkit#267; cap the existing
release in the meantime.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Kakadu pushed a commit to Kakadu/opam-repository that referenced this pull request Jul 4, 2026
ocsigen-toolkit 4.2.0 does not build against js_of_ocaml >= 6.4.0:
since 6.4.0, Dom_html.inputElement##.files is typed
File.fileList Js.t Js.opt (nullable) and Ot_picture_uploader calls
##item on it without unwrapping the opt.

Fixed upstream in ocsigen/ocsigen-toolkit#267; cap the existing
release in the meantime.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant