A define from an earlier build stays active in later builds that don't pass it. This seems to happen because project_cracked.json caches the defines of the build that created it, and is not refreshed on subsequent runs, so the compile gets the union of the cached and the current ones. Deleting that file or building with --noCache fixes the issue.
For example, in a project with a source file like the one below:
let first =
#if FIRST
true
#else
false
#endif
let second =
#if SECOND
true
#else
false
#endif
printfn "FIRST=%b SECOND=%b" first second
Running fable --define FIRST -o out && node out/Program.js, the output is the expected FIRST=true SECOND=false.
But then, if you run dotnet fable --define SECOND -o out && node out/Program.js, the output is now FIRST=true SECOND=true instead of the expected FIRST=false SECOND=true.
A define from an earlier build stays active in later builds that don't pass it. This seems to happen because
project_cracked.jsoncaches the defines of the build that created it, and is not refreshed on subsequent runs, so the compile gets the union of the cached and the current ones. Deleting that file or building with--noCachefixes the issue.For example, in a project with a source file like the one below:
Running
fable --define FIRST -o out && node out/Program.js, the output is the expectedFIRST=true SECOND=false.But then, if you run
dotnet fable --define SECOND -o out && node out/Program.js, the output is nowFIRST=true SECOND=trueinstead of the expectedFIRST=false SECOND=true.