parcel: Elm + parcel serve unusable: File changes not detected after compilation error

πŸ› bug report

If Elm compilation fails then parcel serve/watch auto-recomplitaion mostly breaks. If the entry-point Elm file (i.e. Main.elm) is edited then recompilation will work, but if any non-entry-point Elm file is edited recompilation does not occur. Since the entry point (Main.elm) is very rarely touched in most Elm projects it makes parcel serve/watch basically unusable w/ Elm.

SSCCE here

πŸŽ› Configuration (.babelrc, package.json, cli command)

https://github.com/cmditch/parcel2-elm-error/blob/master/package.json

πŸ€” Expected Behavior

Every time an Elm file is touched, regardless of the compilation state, parcel serve/watchshould recompile the project.

πŸ’ Possible Solution

No idea. The watcher seems to work on all Elm files, but only when the last compilation was a success.

πŸ’» Code Sample

Clone and run yarn; yarn hot in the SSCCE here and see instructions here to reproduce.

🌍 Your Environment

Software Version(s)
Parcel 2.0.0-nightly.639+059d502f
Node 12.22.0
npm/Yarn yarn 1.22.10
Operating System macOS 10.15.7

Thanks, Coury

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 23 (3 by maintainers)

Commits related to this issue

Most upvoted comments

I have the same issue. And the suggestion over by touching the Main.elm file did break hot-reloading for me. I found that touching index.js whenever any elm file changes will preserve the hot reloading functionallity πŸ˜ƒ in package.json

  ...
  "scripts": {
    "start": "concurrently \"npm run touchindex\" \"parcel serve\"",
    "touchindex": "nodemon --watch src --ext 'elm' --exec  \"touch src/index.js\""
  },
  ...

Similar to what @myrho suggested for Vim users, here’s a more generic node-based workaround using chokidar-cli and concurrently:

{
  "scripts": {
    "start:watch": "chokidar 'src/**/!(Main).elm' -c 'touch src/Main.elm'",
    "start": "concurrently -n \"watch,parcel\" -c \"blue,green\" -k \"npm run start:watch\" \"parcel serve index.html\""
  }
}

Workaround for vim: autocmd BufWritePost *.elm :silent exec "!touch src/index.html"

@n1k0 Thanks this chokidar and concurrently workaround works nicely for now.