Getting started
Install
Section titled “Install”dartea ships as an npm package with a native binary inside. You need Node.js 18 or newer.
npm install --save-dev @dartea/clinpm picks the binary for your machine. There are builds for:
- macOS on Apple silicon and Intel
- Linux on x64 and arm64, with glibc
Start a project
Section titled “Start a project”-
Create the project files.
Terminal window npx dartea initYou get two files:
- dartea.json
Directorysrc/
- Main.elm a small counter
-
Build a page with the program inside.
Terminal window npx dartea make src/Main.elm --output index.html -
Open
index.htmlin a browser. No server needed.
init refuses to run where a dartea.json or an elm.json already exists, so it never overwrites a project.
Choose an output
Section titled “Choose an output”The extension of --output decides what you get.
npx dartea make src/Main.elm --output index.htmlOne HTML file with the script inside. Good for trying things out and for small apps.
npx dartea make src/Main.elm --output app.jsOne JavaScript file. Start the program from your own page:
<div id="app"></div><script src="app.js"></script><script> const app = Dartea.Main.init({ node: document.getElementById("app"), flags: null, });</script>npx dartea make src --output buildOne .mjs file per Elm module, for bundlers and for setups that load modules natively.
npx dartea make src/Main.elm --output /dev/nullType checks everything and writes nothing. Handy in CI and in editors.
Ports and flags
Section titled “Ports and flags”They work as in Elm. The global object is called Dartea, not Elm:
const app = Dartea.Main.init({ flags: JSON.parse(localStorage.getItem("state")) });
app.ports.save.subscribe((state) => { localStorage.setItem("state", JSON.stringify(state));});Licences in the output
Section titled “Licences in the output”Some modules of the standard library come from elm/core, elm/html, elm/browser, elm/url and elm/http. When any of them ends up in your bundle, dartea writes dartea.LICENSE.txt next to it and adds a one line banner pointing there. Your own code stays yours to license.
- Packages: add a dependency, publish your own.
- Coming from Elm: what to change in an existing project.