Skip to content

v4.0.0

Latest

Choose a tag to compare

@hmsk hmsk released this 22 Nov 10:33
· 29 commits to main since this release
v4.0.0
430798e

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 make by itself instead of through node-elm-compiler (#873). Install elm in your project, or have it in PATH.
  • nodeElmCompilerOptions is removed. Use the new pathToElm option instead of nodeElmCompilerOptions.pathToElm.
  • debug and optimize default by Vite's command instead of NODE_ENV (#881): vite build makes an optimized build, and the dev server compiles with the debugger. NODE_ENV=development vite build now makes an optimized build; set debug to 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 to postprocess to keep static assets and ?with= working.

See Migrating from v3.

New

  • pathToElm, and a lookup for elm from the closest node_modules/.bin, then PATH (#2)
  • postprocess to transform the compiled code, e.g. with elm-optimize-level-2's transform (#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-stuff at once and fail with resource busy (file is locked) or CORRUPT CACHE.
  • Passing something other than a string literal to VitePluginHelper.asset shows 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.allow permits (#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).