Quick Summary: elm make often does not correctly determine which files need to be recompiled when a module is changed that is used by multiple entrypoints.
Create an elm.json with elm init
create src/M1.elm:
module M1 exposing (A1)
type alias A1 =
Int
src/M3.elm:module M3 exposing (A2)
import M1
type alias A2 =
M1.A1
src/Main1.elm:module Main1 exposing (x)
import M3
x : M3.A2
x =
0
src/Main2.elm:module Main2 exposing (unused)
import M1
unused =
()
elm-stuff if it already exists with rm -Rf ./elm-stuffMain1 with elm make src/Main1.elm --output /dev/nullInt to String in M1, and 0 to "" in Main1):--- a/src/M1.elm
+++ b/src/M1.elm
@@ -5 +5 @@ type alias A1 =
- Int
+ String
--- a/src/Main1.elm
+++ b/src/Main1.elm
@@ -8 +8 @@ x =
- 0
+ ""
Main2 with elm make src/Main2.elm --output /dev/nullMain1 with elm make src/Main1.elm --output /dev/nullThis results in the following incorrect error:
$ elm make src/Main1.elm --output /dev/null
Detected problems in 1 module.
-- TYPE MISMATCH ------------------------------------------------- src/Main1.elm
Something is off with the body of the `x` definition:
8| ""
^^
The body is a string of type:
String
But the type annotation on `x` says it should be:
M3.A2
Note that deleting elm-stuff causes both files to then compile successfully.
If you don't change Main1 when changing M1, then following the rest of the steps will result in Main1 incorrectly compiling successfully (deleting elm-stuff will make it give the correct compilation error).
Thank you for the excellent SSCCE. This made it really easy to understand the problem and test fixes!
The fix is spread across three commits:
The danger here is that there is some logic mistake that leads to compiling modules more than is necessary, so it will be important to have people look at the Success! Compiled 1 module. message to make sure that "modifying a file without changing the public API" always triggers just one recompile. It should never cascade, even across different builds with different entrypoints!
Anyway, thanks again for the great SSCCE!
This appears to be fixed for the SSCCE in alpha-4. I'll try to confirm it against the original large test case...
Confirmed that the originally observed reproducible issue on our large codebase is fixed with alpha-4 馃帀
Most helpful comment
Confirmed that the originally observed reproducible issue on our large codebase is fixed with alpha-4 馃帀