Repository navigation
v4 for Vite 6, 7 and 8. Install it with npm i -D vite-plugin-elm elm. For Vite 5, stay on v3 (npm i -D vite-plugin-elm@3).
Changes since 3.1.0, through 4.0.0-0, 4.0.0-1 and 4.0.0-2:
Breaking changes
- Supports Vite 6, 7 and 8 (#872). Stay on v3 for Vite 5.
- Requires Node.js 22.12 or later (#882). Node.js 20 reached its end of life in April 2026, so v4 doesn't support it even though Vite 6–8 do.
- The plugin runs
elm makeby itself instead of through node-elm-compiler (#873). Installelmin your project, or have it inPATH. nodeElmCompilerOptionsis removed. Use the newpathToElmoption instead ofnodeElmCompilerOptions.pathToElm.debugandoptimizedefault by Vite's command instead ofNODE_ENV(#881):vite buildmakes an optimized build, and the dev server compiles with the debugger.NODE_ENV=development vite buildnow makes an optimized build; setdebugto build with the debugger, e.g.debug: mode === 'staging'.- Compile errors are reported in the format of the Elm CLI. They keep colors in the terminal and point at the file and line on Vite's overlay.
- If you use elm-optimize-level-2 through
compiler, move topostprocessto keep static assets and?with=working.
See Migrating from v3.
New
pathToElm, and a lookup forelmfrom the closestnode_modules/.bin, thenPATH(#2)postprocessto transform the compiled code, e.g. with elm-optimize-level-2'stransform(#646, #878)/* @__PURE__ */annotations, which make the example's bundles about 40% smaller (#837, #875)- Tested with Elm 0.19.1, 0.19.2 and 0.19.3 (#877)
Fixes
- HMR works when the Vite root isn't the cwd. This was a hard error on Vite 8 (#806, #872).
- No deprecation warnings from Vite's Environment API, and
moduleType: 'js'for Rolldown (#872) - Elm files compile one at a time (#884). Two compilations could run on the same
elm-stuffat once and fail withresource busy (file is locked)orCORRUPT CACHE. - Passing something other than a string literal to
VitePluginHelper.assetshows an error on the overlay instead of crashing the dev server (#455, #874). - Asset tags are found in any quotes, and right after another tag (#878).
- The dev server compiles only the files that
server.fs.allowpermits (#879). - Imports in Elm block comments are no longer taken as dependencies (#873).
Dependencies
- The only dependency is tinyexec. node-elm-compiler and elm-esm (#873), find-up (#871), and acorn and acorn-walk (#885) are gone; the compiled code is parsed with Vite's own
parseAst.
Internal
- e2e tests run with Vitest and Playwright instead of Cypress (#880), on every Vite and Elm version in CI, with and without elm-optimize-level-2, and with the plugin itself running on that Vite (#885).
- CI covers Node 22, 24 and 26 on Linux, plus Windows and macOS.
- oxlint and oxfmt replace ESLint and Prettier (#876).