On Ubuntu, Elm files do not compile and hot reload after a change is made. This only affects changes after the very first change.
Parcel should compile Elm files after a change is made to it
Changes after the first change (first from starting parcel serve) to an Elm file do not trigger a compile. Interestingly this issue does not occur on my Macbook Air Sierra with the exact same parcel/npm/node versions.
'
Something wrong with chokidar on Ubuntu?
Just trying to run hello world in Elm
parcel index.htmlHello, Elm! in Main.elm to something else| Software | Version(s) |
| ---------------- | ---------- |
| Parcel |1.11.0|
| Node |v10.9.0|
| npm/Yarn |6.7.0|
| Operating System |Ubuntu 16.04.5 LTS|
That example is missing module Main exposing (..) at the top
I added module Main exposing (..) and it still does not work. I noticed that the first change to the Elm file (after parcel is started) gets compiled but subsequent changes are not picked up by parcel.
I found out that commenting out the import { Elm } from './Main.elm' in the index.js file, which gives an error, then uncommenting out the line forces parcel to trigger a recompile of the Elm file. However this "fix" is quite tedious for every change to an Elm file.
@richyliu if you can make a git repo that reproduces this issue, I'm happy to look into it.
I created a repo here: https://github.com/richyliu/elm-parcel-bug.
Run npm start and make changes to the src/Main.elm file. The first change gets picked up by Parcel, but subsequent changes aren't. Commenting out the elm import line and then uncommenting it forces Parcel to recompile the Elm changes.
Running the same code on a Macbook Air Sierra works fine, with Parcel picking up every change I make to the Elm file.
It also works here. Maybe your node is too old?
I am running node v10.9.10
Exact same issue here, running on Archlinux.
I'm not sure I can help until I can reproduce this myself or get access to an enviroment. Maybe try using VM with ubuntu and confirm the problem there?
Ok, it seems it is Safe Write issue described here: https://en.parceljs.org/hmr.html#safe-write.
In fact, editing said files in nano works just fine, but editing them from neovim does not work. However, setting
backupcopy=yes also does nothing to prevent this issue.
@richyliu same for you? If so, this should be closed as it's not elm specific
Just FYI, I figured out why the safe-write workaround does not work.
The elm-vim extension has autoformat on, which apparently renames file during reformatting.
To disable this behaviour add
let g:elm_format_autosave=0
to your .vim file.
The issue is definitely related to renaming the file on write, as evidenced by inotify events.
Thank you, this was the bug.
Thank you that helped me too :+1:
However, there must be a way around this as I have never had these issues with webpack or other file watchers before. Would be cool if that could be implemented in parcel, since right now my only option is to turn off auto formatting which is very useful.
FYI the issue is a bit more nuanced, I've found out that (at least in my case) running elm-format just one time breaks the parcel watcher, so that even touch Main.elm won't trigger a rebuild.
Posting this since it might help someone. For me it was a combination of disablling safe write (in vim) as well as using elmcast/elm-vim plugin (which uses safe write internally). Once I switched to a different elm vim plugin the issues were gone and hot reloading worked again on my Ubuntu machine.
Once I switched to a different elm vim plugin the issues were gone and hot reloading worked again on my Ubuntu machine.
@ChristophP to which vim plugin did you switch to?
@jc00ke I am now using coc.vim with the elm language server. Works even better than the elm plugin used to. Here's some links:
https://github.com/neoclide/coc.nvim
https://github.com/elm-tooling/elm-language-server
@ChristophP thanks. I'm using those both but I've also got elm-vim installed, which I'll have to remove and just go with coc.nvim and ElmLS.
Yup, that should do the job.