-
-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid HMR crash when src is undefined #508
base: master
Are you sure you want to change the base?
Avoid HMR crash when src is undefined #508
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add test or create reproducible test repo and I will write test
Unfortunately, I haven't been able to track down why we hit https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/hmr/hotModuleReplacement.js#L54 and have However, if you reach L54 for any reason then it will crash the webpack because https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/hmr/hotModuleReplacement.js#L137 will always throw an error trying to runn It appears null is the incorrect thing to return when no src is found, instead an empty array makes more sense. |
Any progress on this PR? I'm experiencing the error and sadly it prevents me to hot reload styling. 😢 |
@AntonioRedondo - I run a forked version now, since this hasn't been fixed. Given the fact this does fix it, and null is obviously incorrect since later on it runs You can run the forked version as |
We experience that as well with some |
This PR contains a:
Motivation / Use-Case
The function returned by
getCurrentScriptUrl
usually returns an array. However when!src
is true it returnsnull
.This causes a crash when
getReloadUrl()
is run and tries to executesrc.some((url) =>)
https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/hmr/hotModuleReplacement.js#L137
This instead returns an empty array instead so that it can always safely be assumed that an array will be returned.
I couldn't find any reason to return
null
instead, but if there is a reason. Another option would be to have a guard before or insidereloadStyle
.Breaking Changes
None that I am aware of.
Additional Info
Log from our setup. This happens every time we change a CSS file, and occasionally when just changing a JS file.