This example shows how to create a async loaded commons chunk.
When a chunk has many child chunks which share common modules the CommonsChunkPlugin can extract these common modules into a commons chunk which is loaded in parallel to the requested child chunk.
The example entry references two chunks:
- entry chunk
- async require -> chunk X
- async require -> chunk Y
- chunk X
- module
a - module
b - module
c
- module
- chunk Y
- module
a - module
b - module
d
- module
These chunks share modules a and b. The CommonsChunkPlugin extract these into chunk Z:
- entry chunk
- async require -> chunk X & Z
- async require -> chunk Y & Z
- chunk X
- module
c
- module
- chunk Y
- module
d
- module
- chunk Z
- module
a - module
b
- module
Pretty useful for a router in a SPA.
{{example.js}}{{webpack.config.js}}{{js/output.js}}{{js/0.output.js}}{{js/1.output.js}}{{js/2.output.js}}{{stdout}}
{{min:stdout}}