Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds WebAssembly (WASM) support to Eliom, allowing client code to be compiled to WASM as an alternative to JavaScript. The feature is enabled by default but can be disabled via configuration.
Changes:
- Added WASM compilation support with automatic browser detection that loads WASM when supported, falling back to JavaScript
- Extended Eliom configuration system with
enable_wasmoption and related API functions - Updated build templates (app.lib, app.exe) to compile and deploy both JS and WASM versions with dune 3.17+
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/eliom_registration.server.ml | Added wasm_detection_script function that generates inline JavaScript to detect WebAssembly support and load the appropriate file |
| src/lib/eliom_common.server.ml/mli | Added enable_wasm field to sitedata record |
| src/lib/server/eliommod.ml/mli | Added default_enable_wasm configuration, XML parsing for wasm tag, and integration into parse_eliom_option(s) |
| src/lib/eliom_config.server.ml/mli | Added set_enable_wasm and get_enable_wasm API functions |
| src/lib/eliom.server.ml/mli | Added enable_wasm parameter to run function with documentation |
| pkg/distillery/templates/app.lib/dune | Added wasm mode to executables and wasm_of_ocaml configuration |
| pkg/distillery/templates/app.lib/dune-project | Bumped dune version from 3.14 to 3.17 for wasm support |
| pkg/distillery/templates/app.lib/Makefile.app | Added WASM build targets and installation steps with conditional ENABLE_WASM checks |
| pkg/distillery/templates/app.lib/Makefile.options | Added ENABLE_WASM configuration option |
| pkg/distillery/templates/app.exe/* | Similar changes as app.lib template |
| pkg/distillery/templates/basic.ppx/Makefile | Added note that WASM is not supported in this legacy template |
| pkg/distillery/templates/basic.ppx/Makefile.options | Added ENABLE_WASM option (though unused in this template) |
| dune-project, eliom.opam | Added wasm_of_ocaml-compiler dependency |
| src/ppx/ppx_eliom_utils.ml | Added optional loc parameter to type_of_out_type and related functions for better location tracking, plus OCaml 5.3.0 compatibility adjustments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c21923b to
d323fcd
Compare
vouillon
reviewed
Feb 10, 2026
src/lib/eliom_registration.server.ml
Outdated
| in | ||
| let script_content = | ||
| Printf.sprintf | ||
| "(function() {\n\ var script = document.createElement('script');\n\ script.defer = %s;\n\ script.async = %s;\n\ \n\ if (typeof WebAssembly === 'object' && \n\ typeof WebAssembly.instantiate === 'function') {\n\ script.src = '%s';\n\ } else {\n\ script.src = '%s';\n\ }\n\ \n\ document.head.appendChild(script);\n})();" |
Member
There was a problem hiding this comment.
if (window?.WebAssembly?.JSTag) { ... } else { ... }
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add wasm support.
It is activated by default, but there is an Eliom option to deactivate it.
If activated, eliom includes a small inline script that will detect if the browser is compatible and load the right file.
Templates have benn updated to compile the wasm version.
@vouillon This is ready to review but cannot be merged until ocsigen/js_of_ocaml#2151 is released
See also ocsigen/ocsigen-start#699