Skip to content

1.2.0

Latest
Compare
Choose a tag to compare
@lydell lydell released this 10 Jan 11:34

This release fixes a bunch of bugs and edge cases.

The biggest new thing is that elm-watch no longer depends on window.Elm! Previously, elm-watch required window.Elm to exist, for its hot reloading to work. That is no longer the case. This allows for using elm-watch in Node.js (and for postprocessing the output to ESM, if you really want to).

All changes:

  • Platform.worker programs can now be run in Node.js with hot reloading, with some setup. Note that you need a recent enough Node.js version that supports the WebSocket global (in short, basically Node.js 22 or later).
  • elm-watch no longer requires window.Elm to exist.
  • elm-watch now supports postprocessing Elm’s generated JS into ESM (see the end of window.Elm).
  • The above changes made it possible for vite-plugin-elm-watch to depend on elm-watch, instead of copying code in a difficult to maintain way.
  • The watcher now ignores .stack-work/ folders (for Haskell), similar to how node_modules/ is already ignored, which avoids an error on Linux about watching too many files. For a future version of elm-watch, I’m planning a better way of watching files that shouldn’t need ignoring of certain known folders.
  • elm make commands executed by elm-watch now use relative paths instead of absolute paths, because Windows has a maximum command length that some users hit. As a bonus, it looks nicer in error messages (the printed commands are much shorter).
  • The page is now reloaded (if needed) due to Cmds in init. Something that can happen is that you open your Elm app in the browser, and then close it. After that, you make changes to some Cmds (probably HTTP requests) that you make in init. Finally, you open the app in the browser again. The previous version (the one you had open in the browser last) is then going to be loaded (no new JS has been compiled yet), so the Cmds from the previous version are going to be run. Then, elm-watch notices the code needs to be recompiled since you made changes. Previously, the new version would then be hot reloaded into the page. Now, the page will be reloaded instead, so that the new Cmds get to run. This should be less confusing.
  • elm-watch’s browser UI has always used the maximum z-index so that it stays on top of everything else on the page. However, these days browsers have the so called top layer so that z-index is not enough anymore. If you use popovers or modal <dialog>s on your page, they could end up on top of elm-watch’s UI. elm-watch now renders itself inside a popover to get into the top layer. It also uses a modal <dialog> for the error overlay, which also has an accessibility bonus: <dialog> makes content outside the dialog inert, which means that keyboard users can’t accidentally tab outside the modal, and screen readers won’t read things behind the modal.
  • Global text CSS styles can no longer leak into elm-watch’s browser UI.
  • Previously, if you didn’t initialize your app at page load, elm-watch’s browser UI would display ❓ and a message suggesting that maybe you did something wrong. Now, elm-watch displays ✅ as usual instead – it’s fine to initialize the app later if you want. If you expand the UI, there’s text with hints in case you actually made a mistake that resulted in no apps being initialized by mistake.
  • window.Elm is now updated on hot reload. Previously, only already initialized apps were updated on hot reloads, but window.Elm wasn’t patched with the new code. So if you initialized more Elm apps later, they would be running some old version of your Elm app.
  • You can now use quotes or escapes in target names. Previously, that resulted in elm-watch creating JS with syntax errors. Maybe don’t do that anyway, but at least elm-watch isn’t doing something wrong!
  • elm-watch used to watch just a single directory recursively – it was called the “watch root”. Now, elm-watch has multiple watch roots. This allows you to put "../../../../" in your source directories without watching a very large part of your drive.
  • JSON decode errors are slightly better sometimes, due to upgrading tiny-decoders.
  • The ℹ️ emoji no longer appears dimmed in some terminals. In some terminal emulators, dimming text also dims emoji, while in others they emojis are never displayed dimmed. The terminals I’ve used don’t dim emoji, but I’ve seen the emoji being dimmed on others’ computers. elm-watch now only dims the text next to the emoji, not the emoji itself.

Apart from the above, I’ve spent time on upgrading internal tooling of elm-watch, and on making the tests more reliable, which will help me finish the beta version of elm-watch (with the static file server), and making other changes that I want to do.