Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Demo to showcase server-reason-react with Melange

NotificationsYou must be signed in to change notification settings

ml-in-barcelona/fullstack-reason-react-demo

Repository files navigation

WarningThis repo is in constant flux as I'm polishing the experience withserver-reason-react and related tooling.

A demo of a fullstack reason-react app using Melange and Dream. Code is written in Reason and compiled by bothMelange and OCaml.

Demoingserver-reason-react.


The app consist of 3 folders:shared,server andclient, which encapsulates each compilation target defined by dune.

client/

A folder that contains the code executed in the client only. It's defined in dune as amelange.emit to emit JavaScript from Reason via Melange. It uses all the ReScript goodies: Belt, Js, etc. Currently is tiny: client only renders theShared_js.App component:

switch (ReactDOM.querySelector("#root")) {|Some(el) => ReactDOM.render(<Shared_js.App />, el)| None => ()};

server/

An executable that expose a dream app with a home route which serves an HTML page. Written inserver-reason-react and send it as a string withReactDOM.renderToString

shared/

The folder contains the library for shared code betweenclient andserver. dune generates the two librariesShared_js andShared_native withcopy_files# and the dependencies that matter for each compilation:

; shared/js/dune(library (name shared_js) (modes melange) (flags:standard -bs-jsx3) (libraries reason_react bs_css bs_css_emotion))(copy_files#"../*.re")
; shared/native/dune(library (name shared_native) (modes best); best means native and byte (libraries  server-reason-react.react  server-reason-react.reactDom  server-reason-react.js  server-reason-react.css) (preprocess  (pps server-reason-react.ppx)))(copy_files#"../*.re")

Shared_js is compiled by Melange to JavaScript whileShared_native by OCaml to a native library.

The code of shared consist of an app to demostrate a few usages of server-reason-react implementations, such as server-reason-react.css or server-reason-react.js.

  • server-reason-react.css is the implementation of bs-css in the server. Maintains the same API and does the same functionality as emotion.js but in the server. All Css.* methods are available and generates the hash of the classnames. It also adds a fnCss.render_style_tag() to render the resultant CSS in the page, with the intention to be called in native.
  • server-reason-react.belt is the implementation ofBelt in pure OCaml.
  • server-reason-react.js is an incomplete implementation ofJs

About

Demo to showcase server-reason-react with Melange

Topics

Resources

Stars

Watchers

Forks

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp