-
-
Notifications
You must be signed in to change notification settings - Fork 388
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
fix(order): find modules from each chunk in group #455
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #455 +/- ##
==========================================
- Coverage 88.17% 87.34% -0.83%
==========================================
Files 5 5
Lines 406 411 +5
Branches 86 87 +1
==========================================
+ Hits 358 359 +1
- Misses 46 50 +4
Partials 2 2
Continue to review full report at Codecov.
|
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 we add tests?
I will add tests soon so the coverage delta doesn't change. |
I'm afraid writing a test for this will be difficult; running tests locally fails for me and I haven't been able to get them to pass. (The |
Just use prettier to fix problem |
Thanks folks for being working on this. Any updates? |
fixes #257
This PR contains a:
Motivation / Use-Case
As discussed in #257, when the plugin calls
modulesByChunkGroup
, it calls the chunk group'sgetModuleIndex2()
function from the ChunkGroup object's_moduleIndices2
Map property. However, the error occurs because the module it's trying to find the index for doesn't exist in_moduleIndices2
, causingmodulesByChunkGroup
to return an empty array. The for loop that uses the array never iterates, sobestMatch
is never set and is left undefined, resulting in an error when trying to call.pop()
on that undefined object.This fix checks if
getModuleIndex2()
returns no matching modules and, if so, dives into each chunk in the chunk group to find matching modules.Breaking Changes
None.
Additional Info
While this solution dives into a chunk group's chunks to find modules that weren't in the chunk group's
_moduleIndices2
property, it might indicate a bug in webpack where that property is not being fully populated as it should be. If that is the case, then this fix should no longer be necessary, but perhaps it wouldn't hurt to have an extra guard for finding chunk modules.