wking-io / elm-live

⚡ A flexible dev server for Elm. Live reload included.
https://elm-live.com
MIT License
1.05k stars 61 forks source link

Hot-reload mode completely blank #272

Open kwshi opened 2 years ago

kwshi commented 2 years ago

Running a basic elm project created from scratch with elm init and a single src/Main.elm with the following contents:

module Main exposing (..)
import Html
main : Html.Html msg
main = Html.text "hello world"

Expecting to see a page with just the text "hello world". This works correctly when I run elm-live src/Main.elm, but it doesn't work when I run elm-live --hot -- src/Main.elm: instead I get a blank page with nothing showing, and the console shows a myDisposeCallback is not a function error after ~10 seconds or so: image

Versions: tested on 4.0.0, 4.0.0-rc.1 (@next as of writing), 4.0.1, 4.0.2. Same results all around.

Seems related to https://github.com/wking-io/elm-live/issues/211, (I know @codesections was having the same error message); however, that thread was closed as "fixed" without much/any explanation for how the fix was made. The one suggestion about bumping elm-hot dependency version from 1.1.1 to 1.1.4 does not seem to help-- 4.0.2 already uses elm-hot@1.1.4 (by inspecting installed lock file) and still has this issue.

doubledup commented 9 months ago

The docs say that the --hot flag only works when outputting a js file, so you'll want to pass --output to elm make like elm-live --hot -- --output=main.js src/Main.elm.

You'll also want to set up an HTML file that will load the compiled js. See the --output docs and the js interop section in the guide for an example HTML file.