callstack/linaria

webpack hot reload fails after compile error

bbenezech opened this issue · 1 comments

Hi, I found a pretty bad bug that messes up the webpack hot reload.

It would mean a lot to me if you could have a look, I tried to make things as easy as possible:

Reproduction

https://github.com/bbenezech/repro-linaria-bug

git clone git@github.com:bbenezech/repro-linaria-bug.git
cd repro-linaria-bug
yarn; yarn start
  • open src/Other.jsx
  • change the first <span> to <spa> (make a typo that breaks webpack compilation)
  • the build now won't refresh if you try to fix the typo or try any other change in src/Other.jsx. The file is "frozen"

Important points

  • you must either restart the server to fix the server, or modify another file (src/index.jsx for ex.)
  • reloading the page won't help
  • won't trigger if you copy the Other component definition in index.jsx
  • won't trigger if you remove the const StyledOther = styled(Other) in src/index.jsx and use the Other component directly
  • happens on compile errors, not runtime errors
  • happens with webpack 4 and 5
  • happens on linaria 2 and 3

Thank you for your time! Please tell me if I can be of any assistance.

Anber commented

Hi @bbenezech,
Thank you for your report!

In case of an error, webpack loaders didn't mark Other.jsx as a dependency of index.jsx.

Fixed.