To start working on your example, create a new folder under examples
with the
next number in the sequence + identifying name, e.g. 8-tailwind
.
Each example should be self-contained, meaning users should be able to copy the folder and have everything needed to start working.
So all examples should contain at least these files:
.gitignore
- opam file
Makefile
README.md
dune-project
anddune
If the example uses JavaScript packages, include package.json
as well (plus
lockfile).
The best approach is probably to take one of the existing examples folders, copy it, and proceed from there.
The melange-examples
project is configured in a way that each project can be
built as if it was on its own. That's why dune-project
files are included on
each project.
As there is no dune-project
at the top level, the Dune root (more info in the
Dune "Finding the
root" docs)
is on each example folder, and so dune
has to be called from there.
To be able to orchestrate builds and tests across all examples, a series of Makefiles are included with some structure:
install
: commands needed to install deps. Generally it will beopam install
, plusnpm install
if the project requires any JavaScript packagesbuild
: commands needed to build the example. Generally it will be at leastdune build
plus any other scriptstest
: commands to test the project
It is recommended to include some tests for your example. See some inspiration
in the 1-node
example dune file, which includes
a rule with alias runtest
. For simple cases, the test can be just running the
application, or making sure all bundling works.
When adding an example, remember to:
- add it to the main
melange-examples.opam
- add it to the main
Makefile
'sinstall
,build
andtest
commands
so that it gets built and tested in CI.