[experimental] Material for funocaml workshop 2025 about mlx / Melange / RSC
  • OCaml 60.1%
  • JavaScript 19.1%
  • Makefile 18%
  • Dune 2.6%
  • CSS 0.2%
Find a file
2025-09-16 15:44:11 +02:00
lib Add fat_client 2025-09-16 15:17:45 +02:00
src Make styles dep of output.css 2025-09-16 15:24:31 +02:00
vendor Create repository 2025-09-16 14:58:23 +02:00
.gitattributes Create repository 2025-09-16 14:58:23 +02:00
.gitignore Create repository 2025-09-16 14:58:23 +02:00
.ocamlformat Create repository 2025-09-16 14:58:23 +02:00
dune Create repository 2025-09-16 14:58:23 +02:00
dune-project Make styles dep of output.css 2025-09-16 15:24:31 +02:00
Makefile Pin ordering 2025-09-16 15:44:11 +02:00
package-lock.json Create repository 2025-09-16 14:58:23 +02:00
package.json Create repository 2025-09-16 14:58:23 +02:00
README.md Add fat_client 2025-09-16 15:17:45 +02:00
workshop.opam Force dream 2025-09-16 15:42:15 +02:00

mlx, Melange, React and Server Components

Requirements

################

EXPERIMENTAL

################

Introduction

At Ahrefs we shaped a tech-stack that's focused at the web using OCaml, Melange and react.

Melange allows us to compile module-by-module, readable and smaller in bundle-size. While allowing to FFI with JavaScript nicely.

Knowledge

  1. mlx

An OCaml syntax dialect which adds JSX expressions to the language.

https://github.com/ocaml-mlx/mlx

(dialect
 (name mlx)
 (implementation
  (extension mlx)
  (merlin_reader mlx)
  (preprocess
   (run mlx-pp %{input-file}))))

Install VSCode or nvim extension

  1. melange

https://melange.re/v5.0.0 https://dune.readthedocs.io/en/stable/melange.html

  • melange.emit
  • how dune works with melange libs
  1. Shared libraries
  • Single name, separate compilation
  • copy_files

copy_files example library: https://github.com/ml-in-barcelona/server-reason-react/tree/main/demo/universal

  1. single-context libraries
  • Show RFC
  • how it works
  1. reason-react
  • idea of melange FFI
  • Showcase reason-react + reason-react-ppx
  1. server-reason-react
  • renderToString / renderToStream

https://ml-in-barcelona.github.io/server-reason-react/server-reason-react/index.html https://github.com/ml-in-barcelona/server-reason-react https://server-reason-react.fly.dev

  1. Server components
  • Versus traditional SSR

  • React Server components

  • Async components

  • Suspense

  • client components

  • serialisation (primitives, promises, and components)