All elm apps rebuild on each change
See original GitHub issueThis might be a peculiarity of my setup but I have 4 separate elm apps being built by webpack and when ever I make a change all 4 rebuild. Even when the change is to a file that is only used by one of them.
The rebuilding can be quite quick for 3 of the 4 apps but it is still slows down the experience.
I see output like this on a typical file change:
[1354] ./node_modules/moment/locale ^\.\/.*$ 2.86 kB {27} [optional] [built]
+ 1495 hidden modules
46% building modules 6/10 modules 4 active ...erver/apps/business/src/Locations.elmStarted compiling Elm..
52% building modules 7/10 modules 3 active ...erver/apps/business/src/Locations.elmStarted compiling Elm..
57% building modules 8/10 modules 2 active ...erver/apps/business/src/Locations.elmStarted compiling Elm..
64% building modules 9/10 modules 1 active ...erver/apps/business/src/Locations.elmStarted compiling Elm..
94% asset optimization
Though interestingly, src/Locations.elm
is only one of the 4 elm entry files. Not sure why that name is printed out each time.
My set up is that I have a single folder (server/apps/business
) which has a elm-package.json
and 4 typescript files. Each of those typescript files requires a different .elm
file from the src
subdirectory in server/apps/business
.
My webpack elm rule looks like:
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
use: [
'elm-css-modules-loader',
{
loader: 'elm-webpack-loader',
options: {
debug,
cwd: path.join(__dirname, '..', 'server', 'apps', 'business'),
pathToMake
}
}
]
},
I’ve tried looking at the code. I get the feeling that it is watching all *.elm
files and rebuilds everything if any of them changes rather than following imports from each entry .elm
file. Understandable if that is the case but I wanted to check in case the behaviour I’m seeing is avoidable with some configuration changes.
Thanks for the project. It has made it much easier to add elm into my stack at work.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:6
Top GitHub Comments
I’ve run into the same issue and finally got it resolved by removing
cwd
option fromelm-webpack-loader
. Seems working fine though I don’t know if it was a time bomb as this option is recommended.We also just managed to get this working by removing the
cwd
option as well.We did run into an issue were some files were not compiling when file dependencies changed but this was due to some files not having the proper namespaced module name in the main elm file that was initialised in the Javascript. These files shouldn’t have been compiling from the start because of the module name but because the
cwd
adds all of these file as dependencies of each other they compiled regardless.