elm-lang / elm-make

A build tool for Elm projects
BSD 3-Clause "New" or "Revised" License
175 stars 45 forks source link

modified source files are not reliably detected due to filesystem timestamp resolution #172

Open avh4 opened 7 years ago

avh4 commented 7 years ago

If an Elm file is modified less than one second after it is compiled, then future runs of elm-make will fail to recompile the file until it is modified again. I believe this is due to the fact that the filesystem (on Mac OS) only has one-second resolution. To fix this, I suspect elm-make should rebuild a file if the source file's timestamp is >= the .elmo file's timestamp (rather than only if it is >).

To reproduce, start with the following files:

A.elm

module A exposing (value)

import B
import C
import Html

value = "A0"

main = Html.text <| Debug.log "A" <| String.join ":" [ value, B.value, C.value ]

B.elm

module B exposing (value)

import C

value = "B0"

C.elm

module C exposing (value)

value = "C0"

Then use the following script:

go.sh

sed -i -e '/value =/{s/.*/value = "A1"/;}' A.elm
sed -i -e '/value =/{s/.*/value = "B1"/;}' B.elm
sed -i -e '/value =/{s/.*/value = "C1"/;}' C.elm
elm-make --yes B.elm --output /dev/null
sed -i -e '/value =/{s/.*/value = "B2"/;}' B.elm
elm-make --yes A.elm --output elm.js
node elm.js

Running go.sh produces:

Success! Compiled 2 modules.
Successfully generated /dev/null
Success! Compiled 1 module.
Successfully generated elm.js
A: "A1:B1:C1"

But it should produce A: "A1:B2:C1" (with B2) as the last line.

process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.