Skip to content

Commit

Permalink
Update example/r-fullstack-melange
Browse files Browse the repository at this point in the history
- Use opam instead of esy, following Melange.
- Use new Dune build integration.

Fixes #293.
  • Loading branch information
aantron committed Nov 30, 2023
1 parent 090b622 commit e570114
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 64 deletions.
10 changes: 2 additions & 8 deletions example/r-fullstack-melange/.gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# npm.
node_modules/

# Melange, Dune.
# Dune.
_build/
_esy/
.melange.eobjs/
dune.bsb
/dune

# esbuild.
node_modules/
static/
13 changes: 9 additions & 4 deletions example/r-fullstack-melange/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ let () = {

To run, do

<pre><code><b>npm install
npm start
<pre><code><b>$ cd example/w-fullstack-melange
$ opam install --deps-only --yes .
$ npm install esbuild --no-save
$ dune build --root . @melange
$ mkdir -p static
$ npx esbuild _build/default/client/client/client/client.js --bundle --outfile=static/client.js
$ dune exec server/server.exe
</b></code></pre>

Then visit [http://localhost:8080](http://localhost:8080), and you will see...
Expand All @@ -82,13 +87,13 @@ example in OCaml syntax.

**See also:**

- [**`w-esy`**](../w-esy#files) details the server's [esy](https://esy.sh/)
packaging.
- [**`w-watch`**](../w-fswatch#files) sets up a development watcher.
- [**`w-one-binary`**](../w-one-binary#files) bundles assets into a
self-contained binary.
- [**`7-template`**](../7-template#files) discusses the templater, including
security. The example is in OCaml syntax.
- [**`r-template`**](../r-template#files) the code of the template example in
Reason syntax.

<br>

Expand Down
10 changes: 0 additions & 10 deletions example/r-fullstack-melange/bsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion example/r-fullstack-melange/client/client.re
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let () = {
let text = Common.greet(`Client);

let p = document |> Document.createElement("p");
p->Element.setInnerText(text);
Element.setInnerText(p, text);
body |> Element.appendChild(p);
}
};
4 changes: 4 additions & 0 deletions example/r-fullstack-melange/client/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(melange.emit
(target client)
(preprocess (pps melange.ppx))
(libraries common melange-webapi))
3 changes: 2 additions & 1 deletion example/r-fullstack-melange/common/dune
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
(library
(name common))
(name common)
(modes best melange))
4 changes: 2 additions & 2 deletions example/r-fullstack-melange/dune-project
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(lang dune 2.7)
(using action-plugin 0.1)
(lang dune 3.8)
(using melange 0.1)
24 changes: 0 additions & 24 deletions example/r-fullstack-melange/esy.json

This file was deleted.

14 changes: 0 additions & 14 deletions example/r-fullstack-melange/package.json

This file was deleted.

10 changes: 10 additions & 0 deletions example/r-fullstack-melange/r-fullstack-melange.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
opam-version: "2.0"

depends: [
"ocaml"
"dream"
"dune" {>= "3.8.0"}
"melange" {>= "2.0.0"}
"melange-webapi"
"reason" {>= "3.10.0"}
]

0 comments on commit e570114

Please sign in to comment.