elm-webpack-loader icon indicating copy to clipboard operation
elm-webpack-loader copied to clipboard

Version 7.01 doesn't observe source code changes anymore

Open sporto opened this issue 4 years ago • 14 comments

In version 6.01 making a change in the source will cause webpack to re-compile the changes. Nothing happens in version 7.01 now. The only way to get the changes is by kiling the dev server and running again. I'm using Ubuntu 20.04

To replicate

  • Create a basic project e.g. the example folder in the repo. Example: https://github.com/sporto/elm-webpack-7-repro

  • Install version 6.01

  • Run npm run dev

  • Open the browser, see Hello ...

  • Make a change in the Content.elm, observe the change in the browser

  • Then repeat using version 7.01

  • Observe how the page doesn't change when changing the code

sporto avatar Aug 28 '20 02:08 sporto

Agree here. I came to the same issue yesterday. OS X, version 10.15.6 (19G2021) p.s. also error message way more nicer in version 6.0.1 p.p.s. thx for your loader!

maxfarseer avatar Sep 02 '20 13:09 maxfarseer

Same is happening for me. I was using forceWatch: true

rlopzc avatar Sep 02 '20 14:09 rlopzc

I'm also having this problem. To add some info that seems to be the case for me:

  • The problem only happens when using npx webpack-dev-server - using npx webpack --watch seems to still work just fine?
  • It only affects the file not referenced in my webpack entry point javascript file. So changes in Main.elm do trigger a recompile, while changes in other files (not referenced in JS files) do not.

IloSophiep avatar Sep 06 '20 16:09 IloSophiep

Having the same issue currently, any workarounds? I went back to 6.0.1 and everything is working fine.

dccarmo avatar Sep 10 '20 20:09 dccarmo

Ran into the same issue today, adding --watch to my dev server script solved it:

    "dev": "webpack-dev-server --mode development --port 3000 --hot --watch",

However, my hot reload errors are still broken, instead of the elm compiler output, I just get this in the browser modal overlay:

Failed to compile.

./src/Main.elm
Module build failed (from ./node_modules/elm-webpack-loader/index.js):
Compiler process exited with error Compilation failed

Configs I'm using:

https://github.com/inbucket/inbucket/blob/cf4c5a29bb05bd029221c890ea5ff9842ba295cb/ui/package.json https://github.com/inbucket/inbucket/blob/cf4c5a29bb05bd029221c890ea5ff9842ba295cb/ui/webpack.config.js

jhillyerd avatar Sep 13 '20 00:09 jhillyerd

We upgraded to Webpack 5 and this works fine provided that you have --watch. In version 6 of this plugin somehow the flag --watch was not necessary.

sporto avatar Nov 11 '20 04:11 sporto

I had the same issue and adding the --watch flag to the webpack-dev-server command fixed the issue 👍

rdelgatte avatar Nov 16 '20 15:11 rdelgatte

But --watch gave me a webpack 5 deprecation warning. That said, after remove. --watch, I seem to have everything working fine anyway - see https://github.com/simonh1000/elm-webpack-starter/pull/35 for code

simonh1000 avatar Nov 18 '20 08:11 simonh1000

at the end of the day, this is a webpack bug, and it might have been fixed. This issue should probably be closed

simonh1000 avatar Nov 18 '20 09:11 simonh1000

This bug is still a thing, but it only occurs for files that are imported from other files. Entry points load just fine, that's why it's working in that example repo @simonh1000 - there's only one Elm file there. Adding --watch option to webpack does work, however it recompiles all the files instead of just the one that's been changed.

DawidJanczak avatar Jan 28 '21 05:01 DawidJanczak

As of version 4.5.0 of the webpack cli you cannot pass --watch anymore to the dev server. ie. webpack serve --watch will throw an error.

Without --watch the loader doesn't recompile changes. So atm this loader seems to be incompatible with webpack-cli 4.5. Unless I'm missing some options that need to be passed somewhere else.

https://github.com/elm-community/elm-webpack-loader/issues/198

sporto avatar Feb 03 '21 04:02 sporto

I'd like to suggest we bring back forceWatch for a different reason - using this with Storybook. Storybook seems to run its own server which means compiler.watching is false. I'm not entirely sure if that can be fixed, but right now it means that I can't get proper dependency tracking in Storybook at all, which really sucks. Just having this flag and letting me set it in my Storybook Webpack config would unblock me.

ocharles avatar Feb 23 '21 13:02 ocharles

Just for info, downgrading to webpack before 4.5 is incompatible with dev server see https://github.com/webpack/webpack-cli/issues/2422

wadouk avatar Mar 08 '21 14:03 wadouk

had to install live-server and run webpack --watch --mode=development

    "webpack": "4.44.1",
    "webpack-cli": "4.5.0"

wadouk avatar Mar 08 '21 16:03 wadouk