-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
Cannot read property 'pop' of undefined #341
Comments
@a-aslan it is strange, maybe problem in |
I did some research. THIS IS EDITED, my previous observation was wrong. In case of dynamic imports while calling that function mini-css-extract-plugin/src/index.js Line 411 in 1ffc393
we are getting more modules than chunk needs to render. Loader compares size usedModules with size of modules. mini-css-extract-plugin/src/index.js Line 460 in 1ffc393
BUT when walking through all modulesByChunkGroups mini-css-extract-plugin/src/index.js Line 466 in 1ffc393
it find that all list elements are used (listed in userModules set) mini-css-extract-plugin/src/index.js Line 468 in 1ffc393
In case when ALL modules in modulesByChunkGroup are in usedModules, even if not all modules are used, it neither sets value for variable "bestMatch", nor setting "success" to true. In that case it can not .pop() from undefined value mini-css-extract-plugin/src/index.js Line 498 in 1ffc393
My proposal is to check existence of value in "bestMatch", if there not any - just break the cycle before trying to pop the bestMatch, since all modules, that needs rendering got their dependencies resolved. |
Is there any workaround for this, I'm also facing this issue. |
Just dont use this with HMR, just use in a production build. So skip this loader and plugin in dev and use style-loader in dev. |
Feel free to contact me for support 😀 |
only by modifying mini-css-extract-plugin itself. Before line mini-css-extract-plugin/src/index.js Line 498 in 1ffc393
add code
I think that's the right way, cause bestMatch is not filled when all chunks have all modules resolved. |
@khades Thx, dude, you are greate |
any news about this? how to fix this issue? |
Found a problem |
Original:
Need to changed to:
Why? Because entry: {
app: './src/index.js',
}, Anyway you will have empty chunk due #85 and webpack/webpack#11088, we will fix it on webpack@5 side, maybe backport on plugin side in near future I think we can also improve error reporting here with some advice if we can't solve it. |
Let's close in favor #257, anyway if somebody still have the problem and solution from #341 (comment) not help you please open a new issue with reproducible test repo, I am very sorry for the long delay in the reply and please forgive us. Also I will try to improve error reporting in near future, it is in my TODO |
I'm running Node
v8.11.4
on Windows 10 version 1803.I have a minimal project showcasing the issue on: https://github.com/a-aslan/webpack-dynamic-imports
The issue is that when I'm using
mini-css-extract-plugin
withdynamic imports
, I'm getting the following error on a webpack build:I've also recorded the issue on: https://youtu.be/b0Q312y2LSU
How to reproduce the issue:
git checkout master
to see a simple hello world project withstyle-loader
andbootstrap
git checkout css-extract
to see the project still working now with thebootstrap
css extractedgit checkout dynamic-imports
to see a project where I addedreact-mapbox-gl
with thestyle-loader
working (somini-css-extract-plugin
is not applied in this branch) and the library is being split intovendors~mapbox.js
git checkout merge-dynamic-imports-with-css-extract
to see the previous two branches merged on how to reproduce the issueAs you can see both extracting css and dynamic imports works when they are excluded from eachother. But when I want to extract css in combination with code splitting (by using dynamic imports), I'm getting the issue.
Am I doing something wrong?
The text was updated successfully, but these errors were encountered: