Targets · JavaScript · Project setup

Project setup

Everything around the rendered code that makes a working, runnable project.

Contents

How a Program becomes JavaScript, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.

The files

The browser target is the lightest of all: no manifest, no package manager, no build step. A working project is one HTML page that loads the runtime bundle and the rendered program.

my-app/
  index.html            <!-- loads the two scripts and holds the root element -->
  program-runtime.js    // the bundled runtime (Reactive + Context + drivers)
  app.js                // the rendered program
<!doctype html>
<html>
  <body>
    <div id="app"></div>
    <script src="program-runtime.js"></script>
    <script src="app.js"></script>
    <script>Program.Application(() => Main(), [ Ui.Dom.Driver('app') ]);</script>
  </body>
</html>

Build and run

There is nothing to compile: the renderer already emits JavaScript. To run it, open index.html in a browser, or serve the folder over any static host:

# any static server works
python3 -m http.server 8000
# then open http://localhost:8000

For a single-file drop-in, the renderer can emit a bundle — runtime, native modules, and the program concatenated into one .js with no imports — so the page needs just one <script>. That single artifact is also what an embedded example on this site uses. A typed build instead goes through TypeScript.