2020-03-22 10:51:12 +08:00
This example shows the 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:
2020-03-22 10:51:12 +08:00
Note: The optimization compares the 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
```
2019-05-10 03:34:28 +08:00
# dist/394.output.js
2015-01-12 06:15:11 +08:00
2019-04-05 05:04:47 +08:00
```javascript
2019-05-10 03:34:28 +08:00
_{{dist/394.output.js}}_
2015-01-12 06:15:11 +08:00
```
2019-05-10 03:34:28 +08:00
# dist/460.output.js
2015-01-12 06:15:11 +08:00
2019-04-05 05:04:47 +08:00
```javascript
2019-05-10 03:34:28 +08:00
_{{dist/460.output.js}}_
2015-01-12 06:15:11 +08:00
```
2019-05-10 03:34:28 +08:00
# dist/767.output.js
2015-01-12 06:15:11 +08:00
2019-04-05 05:04:47 +08:00
```javascript
2019-05-10 03:34:28 +08:00
_{{dist/767.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
```