fix(order): find modules from each chunk in group#455
Closed
ryansully wants to merge 1 commit into
Closed
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.
|
Author
|
I will add tests soon so the coverage delta doesn't change. |
Author
|
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 |
Member
|
Just use prettier to fix problem |
|
Thanks folks for being working on this. Any updates? |
archual
approved these changes
Feb 28, 2020
archual
approved these changes
Feb 28, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_moduleIndices2Map property. However, the error occurs because the module it's trying to find the index for doesn't exist in_moduleIndices2, causingmodulesByChunkGroupto return an empty array. The for loop that uses the array never iterates, sobestMatchis 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
_moduleIndices2property, 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.