← All decisions

No bundler for the browser build; raw Gleam ESM output plus a hand-written index.html

buildbrowserbundler

Context

Gleam's JavaScript-target output is plain ES modules. Need a way to actually load it in a browser eventually; common web tooling defaults to a bundler (esbuild/Vite/webpack) for this.

Options considered

A bundler (esbuild/Vite) — rejected
Not needed yet: Gleam's output is already valid browser-loadable ESM, and there's no third-party npm package that needs bundling for the browser specifically.
Raw ESM output + a hand-written HTML file with <script type="module"> — chosen
Confirmed as a working, precedented pattern by an existing (if immature) Gleam canvas-game engine, kitten-engine, found during research. Simplest thing that works; revisit only if a real need for bundling (npm packages that must run in-browser, code splitting) appears.

Decision

Defer any bundler decision; plan to serve the Gleam-built JS output directly via a plain HTML file once there's a browser bootstrap to build.

Verification

Confirmed via research (not yet built, since there's no browser entrypoint yet) that Gleam's build output requires no transformation to be browser-loadable.

Consequences

If a real browser-only npm dependency is ever needed (e.g. for render's canvas setup), this decision will need revisiting -- flagged for future attention, not a current blocker.

References