elm-esm

raw JSON →
1.1.4 verified Fri May 01 auth: no javascript

Turn Elm compiler output into modern ES Modules. v1.1.4, updated regularly. Transforms traditional Elm JS output to ESM, enabling browser-native module loading without bundlers. Supports CLI usage as a drop-in replacement for elm make, plus a standalone toESModule function for tooling integration. Tested with Elm 0.19.1, works via simple regex transforms. Ideal for directly using Elm in browsers without Webpack or other bundlers.

error Cannot find module 'elm-esm'
cause Package not installed.
fix
Run: npm i -D elm-esm
gotcha elm-esm is not meant for elm-test; Node.js still has experimental ESM support.
fix Use regular elm make for testing; avoid elm-esm with elm-test.
gotcha Only tested with Elm 0.19.1; may not work with other versions.
fix Check compatibility; open an issue if problems arise.
npm install elm-esm
yarn add elm-esm
pnpm add elm-esm

Build Elm project to ES module and use it in the browser with a script type module.

npx elm-esm make src/Main.elm --output=myElmModule.js

<script type="module">
import { Elm } from './myElmModule.js';
Elm.Main.init({ node: document.body });
</script>