2018-01-20 00:06:59 +08:00
This example shows automatically created async commons chunks.
2015-01-12 06:15:11 +08:00
The example entry references two chunks:
* entry chunk
* async require -> chunk X
* async require -> chunk Y
* chunk X
* module `a`
* module `b`
* module `c`
* chunk Y
* module `a`
* module `b`
* module `d`
2018-01-20 00:06:59 +08:00
These chunks share modules `a` and `b` . The optimization extract these into chunk Z:
2018-02-26 10:39:48 +08:00
Note: Actually the optimization compare size of chunk Z to some minimum value, but this is disabled from this example. In practice there is no configuration needed for this.
2015-01-12 06:15:11 +08:00
* entry chunk
* async require -> chunk X & Z
* async require -> chunk Y & Z
* chunk X
* module `c`
* chunk Y
* module `d`
* chunk Z
* module `a`
* module `b`
2015-01-12 06:17:24 +08:00
2015-01-12 06:15:11 +08:00
Pretty useful for a router in a SPA.
# example.js
``` javascript
{{example.js}}
```
2018-01-05 04:39:29 +08:00
# dist/output.js
2015-01-12 06:15:11 +08:00
``` javascript
2018-01-05 04:39:29 +08:00
{{dist/output.js}}
2015-01-12 06:15:11 +08:00
```
2018-01-05 04:39:29 +08:00
# dist/0.output.js
2015-01-12 06:15:11 +08:00
``` javascript
2018-01-05 04:39:29 +08:00
{{dist/0.output.js}}
2015-01-12 06:15:11 +08:00
```
2018-01-05 04:39:29 +08:00
# dist/1.output.js
2015-01-12 06:15:11 +08:00
``` javascript
2018-01-05 04:39:29 +08:00
{{dist/1.output.js}}
2015-01-12 06:15:11 +08:00
```
2018-01-05 04:39:29 +08:00
# dist/2.output.js
2015-01-12 06:15:11 +08:00
``` javascript
2018-01-05 04:39:29 +08:00
{{dist/2.output.js}}
2015-01-12 06:15:11 +08:00
```
# Info
2017-12-14 17:09:09 +08:00
## Unoptimized
2015-01-12 06:15:11 +08:00
```
{{stdout}}
```
2017-12-14 17:09:09 +08:00
## Production mode
2015-01-12 06:15:11 +08:00
```
2017-12-14 17:09:09 +08:00
{{production:stdout}}
2015-01-12 06:15:11 +08:00
```