Skip to content
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: account for there being no chunk with the same name as the chunk group #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hedgepigdaniel
Copy link

Webpack 4 introduced the concept of chunk groups.

I think there has been a false assumption in webpack-flush-chunks - that there is at least one chunk with the same name as the chunk group corresponding to the entry point or async chunk (provided via the before and after parameters and the chunkNames parameter respectively.

In an app I was working with this was not the case. The flushing of chunks was failing with the error "... check usage of babel plugin" because hasChunk was checking for a chunk with the required name, when it should instead be checking for a chunk group with the required name.

So the changes:

  • Rename functions to more accurately refer to the webpack concepts of chunks, chunk groups, entry points, and assets/files
  • Update hasChunk (now hasChunkGroup) to check the namedChunkGroups key in the stats object instead of the assetsByChunkName key, fixing the bug I experienced.
  • Remove the adding of a hyphen to the chunk name, which I assume is a workaround for the same issue
  • Update unit tests to add examples where:
    • The chunk name is different from the chunk group/entry point/split point name
    • A chunk group has multiple chunks, none of which have the same name as the chunk group

…p. Update unit tests to test this, and the possibility that there are multiple chunks in a named chunk group
@hedgepigdaniel hedgepigdaniel changed the title Account for there being no chunk with the same name as the chunk group fix: account for there being no chunk with the same name as the chunk group Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant