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:
2019-04-05 05:04:47 +08:00
- 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`
2015-01-12 06:15:11 +08:00
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
2019-04-05 05:04:47 +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
2019-04-05 05:04:47 +08:00
```javascript
_{{example.js}}_
2015-01-12 06:15:11 +08:00
```
2018-01-05 04:39:29 +08:00
# dist/output.js
2015-01-12 06:15:11 +08:00
2019-04-05 05:04:47 +08:00
```javascript
_{{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
2019-04-05 05:04:47 +08:00
```javascript
_{{dist/0.output.js}}_
2015-01-12 06:15:11 +08:00
```
2018-09-25 23:08:35 +08:00
# dist/2.output.js
2015-01-12 06:15:11 +08:00
2019-04-05 05:04:47 +08:00
```javascript
_{{dist/2.output.js}}_
2015-01-12 06:15:11 +08:00
```
2018-09-25 23:08:35 +08:00
# dist/3.output.js
2015-01-12 06:15:11 +08:00
2019-04-05 05:04:47 +08:00
```javascript
_{{dist/3.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
```
2019-04-05 05:04:47 +08:00
_{{stdout}}_
2015-01-12 06:15:11 +08:00
```
2017-12-14 17:09:09 +08:00
## Production mode
2015-01-12 06:15:11 +08:00
```
2019-04-05 05:04:47 +08:00
_{{production:stdout}}_
2015-01-12 06:15:11 +08:00
```