mirror of https://github.com/webpack/webpack.git
parent
88d01c76a9
commit
eb7d7ea678
|
@ -1,19 +1,19 @@
|
||||||
# pageA.js
|
# pageA.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{pageA.js}}
|
_{{pageA.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# pageB.js
|
# pageB.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{pageB.js}}
|
_{{pageB.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# pageC.js
|
# pageC.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{pageC.js}}
|
_{{pageC.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# common.js
|
# common.js
|
||||||
|
@ -22,8 +22,8 @@ a big file...
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -31,11 +31,11 @@ a big file...
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -4,50 +4,47 @@ A very simple solution to this problem is to create another chunk which contains
|
||||||
|
|
||||||
The configuration required for this is:
|
The configuration required for this is:
|
||||||
|
|
||||||
* use `[chunkhash]` in `output.filename` (Note that this example doesn't do this because of the example generator infrastructure, but you should)
|
- use `[chunkhash]` in `output.filename` (Note that this example doesn't do this because of the example generator infrastructure, but you should)
|
||||||
* use `[chunkhash]` in `output.chunkFilename` (Note that this example doesn't do this because of the example generator infrastructure, but you should)
|
- use `[chunkhash]` in `output.chunkFilename` (Note that this example doesn't do this because of the example generator infrastructure, but you should)
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# index.html
|
# index.html
|
||||||
|
|
||||||
``` html
|
```html
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head> </head>
|
||||||
</head>
|
<body>
|
||||||
<body>
|
<!-- inlined minimized file "runtime~main.[chunkhash].js" -->
|
||||||
|
<script>
|
||||||
|
_{{production:dist/runtime~main.chunkhash.js}}_
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- inlined minimized file "runtime~main.[chunkhash].js" -->
|
<script src="dist/main.[chunkhash].js"></script>
|
||||||
<script>
|
</body>
|
||||||
{{production:dist/runtime~main.chunkhash.js}}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script src="dist/main.[chunkhash].js"></script>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/runtime~main.[chunkhash].js
|
# dist/runtime~main.[chunkhash].js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/runtime~main.chunkhash.js}}
|
_{{dist/runtime~main.chunkhash.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/main.[chunkhash].js
|
# dist/main.[chunkhash].js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/main.chunkhash.js}}
|
_{{dist/main.chunkhash.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -55,11 +52,11 @@ The configuration required for this is:
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/1.output.js
|
# dist/1.output.js
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
{{dist/1.output.js}}
|
_{{dist/1.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -21,11 +21,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/1.output.js
|
# dist/1.output.js
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
{{dist/1.output.js}}
|
_{{dist/1.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -21,11 +21,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -4,27 +4,26 @@ The bundle loader is used to create a wrapper module for `file.js` that loads th
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# file.js
|
# file.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{file.js}}
|
_{{file.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/1.output.js
|
# dist/1.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/1.output.js}}
|
_{{dist/1.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -32,11 +31,11 @@ The bundle loader is used to create a wrapper module for `file.js` that loads th
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -8,28 +8,26 @@ Providing dynamic expressions to `import` is possible. The same limits as with d
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -3,29 +3,29 @@
|
||||||
This example illustrates how to filter the ContextModule results of `import()` statements. only `.js` files that don't
|
This example illustrates how to filter the ContextModule results of `import()` statements. only `.js` files that don't
|
||||||
end in `.noimport.js` within the `templates` folder will be bundled.
|
end in `.noimport.js` within the `templates` folder will be bundled.
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# templates/
|
# templates/
|
||||||
|
|
||||||
* foo.js
|
- foo.js
|
||||||
* foo.noimport.js
|
- foo.noimport.js
|
||||||
* baz.js
|
- baz.js
|
||||||
* foo.noimport.js
|
- foo.noimport.js
|
||||||
* bar.js
|
- bar.js
|
||||||
* foo.noimport.js
|
- foo.noimport.js
|
||||||
|
|
||||||
All templates are of this pattern:
|
All templates are of this pattern:
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{templates/foo.js}}
|
_{{templates/foo.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -33,11 +33,11 @@ All templates are of this pattern:
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -2,26 +2,26 @@
|
||||||
|
|
||||||
This example illustrates how to leverage the `import()` syntax to create ContextModules which are separated into separate chunks for each module in the `./templates` folder.
|
This example illustrates how to leverage the `import()` syntax to create ContextModules which are separated into separate chunks for each module in the `./templates` folder.
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# templates/
|
# templates/
|
||||||
|
|
||||||
* foo.js
|
- foo.js
|
||||||
* baz.js
|
- baz.js
|
||||||
* bar.js
|
- bar.js
|
||||||
|
|
||||||
All templates are of this pattern:
|
All templates are of this pattern:
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{templates/foo.js}}
|
_{{templates/foo.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -29,11 +29,11 @@ All templates are of this pattern:
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -2,26 +2,26 @@
|
||||||
|
|
||||||
This example illustrates how to specify chunk name in `require.ensure()` and `import()` to separated modules into separate chunks manually.
|
This example illustrates how to specify chunk name in `require.ensure()` and `import()` to separated modules into separate chunks manually.
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# templates/
|
# templates/
|
||||||
|
|
||||||
* foo.js
|
- foo.js
|
||||||
* baz.js
|
- baz.js
|
||||||
* bar.js
|
- bar.js
|
||||||
|
|
||||||
All templates are of this pattern:
|
All templates are of this pattern:
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{templates/foo.js}}
|
_{{templates/foo.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -29,11 +29,11 @@ All templates are of this pattern:
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,52 +1,51 @@
|
||||||
This example illustrates a very simple case of Code Splitting with `require.ensure`.
|
This example illustrates a very simple case of Code Splitting with `require.ensure`.
|
||||||
|
|
||||||
* `a` and `b` are required normally via CommonJS
|
- `a` and `b` are required normally via CommonJS
|
||||||
* `c` is depended through the `require.ensure` array.
|
- `c` is depended through the `require.ensure` array.
|
||||||
* This means: make it available, but don't execute it
|
- This means: make it available, but don't execute it
|
||||||
* webpack will load it on demand
|
- webpack will load it on demand
|
||||||
* `b` and `d` are required via CommonJs in the `require.ensure` callback
|
- `b` and `d` are required via CommonJs in the `require.ensure` callback
|
||||||
* webpack detects that these are in the on-demand-callback and
|
- webpack detects that these are in the on-demand-callback and
|
||||||
* will load them on demand
|
- will load them on demand
|
||||||
* webpacks optimizer can optimize `b` away
|
- webpacks optimizer can optimize `b` away
|
||||||
* as it is already available through the parent chunks
|
- as it is already available through the parent chunks
|
||||||
|
|
||||||
You can see that webpack outputs two files/chunks:
|
You can see that webpack outputs two files/chunks:
|
||||||
|
|
||||||
* `output.js` is the entry chunk and contains
|
- `output.js` is the entry chunk and contains
|
||||||
* the module system
|
- the module system
|
||||||
* chunk loading logic
|
- chunk loading logic
|
||||||
* the entry point `example.js`
|
- the entry point `example.js`
|
||||||
* module `a`
|
- module `a`
|
||||||
* module `b`
|
- module `b`
|
||||||
* `1.output.js` is an additional chunk (on demand loaded) and contains
|
- `1.output.js` is an additional chunk (on demand loaded) and contains
|
||||||
* module `c`
|
- module `c`
|
||||||
* module `d`
|
- module `d`
|
||||||
|
|
||||||
You can see that chunks are loaded via JSONP. The additional chunks are pretty small and minimize well.
|
You can see that chunks are loaded via JSONP. The additional chunks are pretty small and minimize well.
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/1.output.js
|
# dist/1.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/1.output.js}}
|
_{{dist/1.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
Minimized
|
Minimized
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{production:dist/1.output.js}}
|
_{{production:dist/1.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -54,11 +53,11 @@ Minimized
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,26 +1,25 @@
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# cup1.coffee
|
# cup1.coffee
|
||||||
|
|
||||||
``` coffee-script
|
```coffee-script
|
||||||
{{cup1.coffee}}
|
_{{cup1.coffee}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# cup2.coffee
|
# cup2.coffee
|
||||||
|
|
||||||
``` coffee-script
|
```coffee-script
|
||||||
{{cup2.coffee}}
|
_{{cup2.coffee}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -28,11 +27,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
|
@ -33,44 +33,44 @@ With this bundle configuration, you would load your third party libraries, then
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/vendor.js
|
# dist/vendor.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/vendor.js}}
|
_{{dist/vendor.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/commons~pageA~pageB~pageC.js
|
# dist/commons~pageA~pageB~pageC.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/commons~pageA~pageB~pageC.js}}
|
_{{dist/commons~pageA~pageB~pageC.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/commons~pageB~pageC.js
|
# dist/commons~pageB~pageC.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/commons~pageB~pageC.js}}
|
_{{dist/commons~pageB~pageC.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/pageA.js
|
# dist/pageA.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/pageA.js}}
|
_{{dist/pageA.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/pageB.js
|
# dist/pageB.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/pageB.js}}
|
_{{dist/pageB.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/pageC.js
|
# dist/pageC.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/pageC.js}}
|
_{{dist/pageC.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -78,11 +78,11 @@ With this bundle configuration, you would load your third party libraries, then
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,89 +1,88 @@
|
||||||
This example illustrates how common modules from deep ancestors of an entry point can be split into a separate common chunk
|
This example illustrates how common modules from deep ancestors of an entry point can be split into a separate common chunk
|
||||||
|
|
||||||
* `pageA` and `pageB` are dynamically required
|
- `pageA` and `pageB` are dynamically required
|
||||||
* `pageC` and `pageA` both require the `reusableComponent`
|
- `pageC` and `pageA` both require the `reusableComponent`
|
||||||
* `pageB` dynamically requires `PageC`
|
- `pageB` dynamically requires `PageC`
|
||||||
|
|
||||||
You can see that webpack outputs five files/chunks:
|
You can see that webpack outputs five files/chunks:
|
||||||
|
|
||||||
* `output.js` is the entry chunk and contains
|
- `output.js` is the entry chunk and contains
|
||||||
* the module system
|
- the module system
|
||||||
* chunk loading logic
|
- chunk loading logic
|
||||||
* the entry point `example.js`
|
- the entry point `example.js`
|
||||||
* `0.output.js` is an additional chunk
|
- `0.output.js` is an additional chunk
|
||||||
* module `reusableComponent`
|
- module `reusableComponent`
|
||||||
* `1.output.js` is an additional chunk
|
- `1.output.js` is an additional chunk
|
||||||
* module `pageB`
|
- module `pageB`
|
||||||
* `2.output.js` is an additional chunk
|
- `2.output.js` is an additional chunk
|
||||||
* module `pageA`
|
- module `pageA`
|
||||||
* `3.output.js` is an additional chunk
|
- `3.output.js` is an additional chunk
|
||||||
* module `pageC`
|
- module `pageC`
|
||||||
|
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# pageA.js
|
# pageA.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{pageA.js}}
|
_{{pageA.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# pageB.js
|
# pageB.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{pageB.js}}
|
_{{pageB.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# pageC.js
|
# pageC.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{pageC.js}}
|
_{{pageC.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# reusableComponent.js
|
# reusableComponent.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{reusableComponent.js}}
|
_{{reusableComponent.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/0.output.js
|
# dist/0.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/0.output.js}}
|
_{{dist/0.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/2.output.js
|
# dist/2.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/2.output.js}}
|
_{{dist/2.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/3.output.js
|
# dist/3.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/3.output.js}}
|
_{{dist/3.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/4.output.js
|
# dist/4.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/4.output.js}}
|
_{{dist/4.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -91,11 +90,11 @@ You can see that webpack outputs five files/chunks:
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -8,26 +8,26 @@ You can also see the info messages webpack prints to console (for both normal an
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# increment.js
|
# increment.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{increment.js}}
|
_{{increment.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# math.js
|
# math.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{math.js}}
|
_{{math.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -35,11 +35,11 @@ You can also see the info messages webpack prints to console (for both normal an
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
|
@ -8,26 +8,26 @@ A manifest is created which includes mappings from module names to internal ids.
|
||||||
|
|
||||||
### webpack.config.js
|
### webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# example-vendor
|
# example-vendor
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{../node_modules/example-vendor.js}}
|
_{{../node_modules/example-vendor.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/vendor.js
|
# dist/vendor.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/vendor.js}}
|
_{{dist/vendor.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/vendor-manifest.json
|
# dist/vendor-manifest.json
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/vendor-manifest.json}}
|
_{{dist/vendor-manifest.json}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -35,12 +35,11 @@ A manifest is created which includes mappings from module names to internal ids.
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -4,26 +4,26 @@ The previously built vendor dll is used. The DllReferencePlugin reads the conten
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# example-app.js
|
# example-app.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example-app.js}}
|
_{{example-app.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# example.html
|
# example.html
|
||||||
|
|
||||||
``` html
|
```html
|
||||||
{{example.html}}
|
_{{example.html}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/app.js
|
# dist/app.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/app.js}}
|
_{{dist/app.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -31,13 +31,13 @@ The previously built vendor dll is used. The DllReferencePlugin reads the conten
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- @TODO:
|
<!-- @TODO:
|
||||||
|
|
|
@ -24,29 +24,28 @@ from the corresponding modules `a.js`, `b.js` and `cjs.js`. None of the other mo
|
||||||
Also see [tree shaking](https://github.com/webpack/webpack/tree/master/examples/harmony-unused)
|
Also see [tree shaking](https://github.com/webpack/webpack/tree/master/examples/harmony-unused)
|
||||||
and [scope hoisting example](https://github.com/webpack/webpack/tree/master/examples/scope-hoisting).
|
and [scope hoisting example](https://github.com/webpack/webpack/tree/master/examples/scope-hoisting).
|
||||||
|
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/dll.js
|
# dist/dll.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/dll.js}}
|
_{{dist/dll.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/dll-manifest.json
|
# dist/dll-manifest.json
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/dll-manifest.json}}
|
_{{dist/dll-manifest.json}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -54,11 +53,11 @@ and [scope hoisting example](https://github.com/webpack/webpack/tree/master/exam
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -6,20 +6,20 @@ This is the _user_ bundle, which uses the manifest from [dll-reference example](
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -27,11 +27,11 @@ This is the _user_ bundle, which uses the manifest from [dll-reference example](
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -4,23 +4,22 @@
|
||||||
|
|
||||||
This is the _reference_ bundle (with the manifests) for [dll user example](https://github.com/webpack/webpack/tree/master/examples/dll-user)
|
This is the _reference_ bundle (with the manifests) for [dll user example](https://github.com/webpack/webpack/tree/master/examples/dll-user)
|
||||||
|
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/MyDll.alpha.js
|
# dist/MyDll.alpha.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/MyDll.alpha.js}}
|
_{{dist/MyDll.alpha.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/alpha-manifest.json
|
# dist/alpha-manifest.json
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/alpha-manifest.json}}
|
_{{dist/alpha-manifest.json}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -28,11 +27,11 @@ This is the _reference_ bundle (with the manifests) for [dll user example](https
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/vendor.js
|
# dist/vendor.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/vendor.js}}
|
_{{dist/vendor.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/pageA.js
|
# dist/pageA.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/pageA.js}}
|
_{{dist/pageA.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -21,11 +21,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -9,7 +9,7 @@ In the simple case we just need to specify a string (`"add"`). Then it's resolve
|
||||||
In the complex case we specify different values for each environment:
|
In the complex case we specify different values for each environment:
|
||||||
|
|
||||||
| environment | config value | resolved as |
|
| environment | config value | resolved as |
|
||||||
|--------------------|--------------------------|------------------------------|
|
| ------------------ | ------------------------ | ---------------------------- |
|
||||||
| CommonJs (strict) | `["./math", "subtract"]` | `require("./math").subtract` |
|
| CommonJs (strict) | `["./math", "subtract"]` | `require("./math").subtract` |
|
||||||
| CommonJs (node.js) | `"./subtract"` | `require("./subtract")` |
|
| CommonJs (node.js) | `"./subtract"` | `require("./subtract")` |
|
||||||
| AMD | `"subtract"` | `define(["subtract"], ...)` |
|
| AMD | `"subtract"` | `define(["subtract"], ...)` |
|
||||||
|
@ -17,20 +17,20 @@ In the complex case we specify different values for each environment:
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -38,11 +38,11 @@ In the complex case we specify different values for each environment:
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
|
@ -1,21 +1,19 @@
|
||||||
|
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -23,11 +21,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -2,64 +2,63 @@ This example shows automatically created async commons chunks.
|
||||||
|
|
||||||
The example entry references two chunks:
|
The example entry references two chunks:
|
||||||
|
|
||||||
* entry chunk
|
- entry chunk
|
||||||
* async require -> chunk X
|
- async require -> chunk X
|
||||||
* async require -> chunk Y
|
- async require -> chunk Y
|
||||||
* chunk X
|
- chunk X
|
||||||
* module `a`
|
- module `a`
|
||||||
* module `b`
|
- module `b`
|
||||||
* module `c`
|
- module `c`
|
||||||
* chunk Y
|
- chunk Y
|
||||||
* module `a`
|
- module `a`
|
||||||
* module `b`
|
- module `b`
|
||||||
* module `d`
|
- module `d`
|
||||||
|
|
||||||
These chunks share modules `a` and `b`. The optimization extract these into chunk Z:
|
These chunks share modules `a` and `b`. The optimization extract these into chunk Z:
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* entry chunk
|
- entry chunk
|
||||||
* async require -> chunk X & Z
|
- async require -> chunk X & Z
|
||||||
* async require -> chunk Y & Z
|
- async require -> chunk Y & Z
|
||||||
* chunk X
|
- chunk X
|
||||||
* module `c`
|
- module `c`
|
||||||
* chunk Y
|
- chunk Y
|
||||||
* module `d`
|
- module `d`
|
||||||
* chunk Z
|
- chunk Z
|
||||||
* module `a`
|
- module `a`
|
||||||
* module `b`
|
- module `b`
|
||||||
|
|
||||||
Pretty useful for a router in a SPA.
|
Pretty useful for a router in a SPA.
|
||||||
|
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/0.output.js
|
# dist/0.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/0.output.js}}
|
_{{dist/0.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/2.output.js
|
# dist/2.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/2.output.js}}
|
_{{dist/2.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/3.output.js
|
# dist/3.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/3.output.js}}
|
_{{dist/3.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -67,11 +66,11 @@ Pretty useful for a router in a SPA.
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,38 +1,37 @@
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# fs.js
|
# fs.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{fs.js}}
|
_{{fs.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# reexport-commonjs.js
|
# reexport-commonjs.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{reexport-commonjs.js}}
|
_{{reexport-commonjs.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# example2.js
|
# example2.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example2.js}}
|
_{{example2.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# harmony.js
|
# harmony.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{harmony.js}}
|
_{{harmony.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -40,11 +39,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
|
@ -1,13 +1,13 @@
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/MyLibrary.umd.js
|
# dist/MyLibrary.umd.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/MyLibrary.umd.js}}
|
_{{dist/MyLibrary.umd.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -15,11 +15,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -8,32 +8,32 @@ In addition to that, `library.js` simulates an entry point to a big library. `li
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# math.js
|
# math.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{math.js}}
|
_{{math.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# library.js
|
# library.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{library.js}}
|
_{{library.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{production:dist/output.js}}
|
_{{production:dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -41,11 +41,11 @@ In addition to that, `library.js` simulates an entry point to a big library. `li
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# increment.js
|
# increment.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{increment.js}}
|
_{{increment.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -22,11 +21,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
|
@ -16,8 +16,8 @@ The compression improves with bigger `maxSize`, as gzip works better for bigger
|
||||||
|
|
||||||
The backward compatibility (non HTTP2 client) improves with bigger `maxSize`, as the number of requests decreases.
|
The backward compatibility (non HTTP2 client) improves with bigger `maxSize`, as the number of requests decreases.
|
||||||
|
|
||||||
``` js
|
```js
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -25,17 +25,17 @@ The backward compatibility (non HTTP2 client) improves with bigger `maxSize`, as
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Records
|
## Records
|
||||||
|
|
||||||
```
|
```
|
||||||
{{dist/records.json}}
|
_{{dist/records.json}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,53 +1,53 @@
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# aEntry.js
|
# aEntry.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{aEntry.js}}
|
_{{aEntry.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
`bEntry.js` is similar. You may want to use a loader to generate this file.
|
`bEntry.js` is similar. You may want to use a loader to generate this file.
|
||||||
|
|
||||||
# aPage.js
|
# aPage.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{aPage.js}}
|
_{{aPage.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
`bEntry.js` is similar.
|
`bEntry.js` is similar.
|
||||||
|
|
||||||
# router.js
|
# router.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{router.js}}
|
_{{router.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# pageA.html
|
# pageA.html
|
||||||
|
|
||||||
``` html
|
```html
|
||||||
{{pageA.html}}
|
_{{pageA.html}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/pageA~pageB.chunk.js
|
# dist/pageA~pageB.chunk.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/pageA~pageB.chunk.js}}
|
_{{dist/pageA~pageB.chunk.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/pageA.bundle.js
|
# dist/pageA.bundle.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/pageA.bundle.js}}
|
_{{dist/pageA.bundle.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/aPage.chunk.js
|
# dist/aPage.chunk.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/aPage.chunk.js}}
|
_{{dist/aPage.chunk.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -55,11 +55,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -4,35 +4,34 @@ The `webpack.config.js` exports an array of all config combinations that should
|
||||||
|
|
||||||
The I18nPlugin replaces every occurrence of the i18n function `__(...)` with a const string. i. e. `__("Hello World")` with `"Hello World"` resp. `"Hallo Welt"`.
|
The I18nPlugin replaces every occurrence of the i18n function `__(...)` with a const string. i. e. `__("Hello World")` with `"Hello World"` resp. `"Hallo Welt"`.
|
||||||
|
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# de.json
|
# de.json
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{de.json}}
|
_{{de.json}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/de.output.js
|
# dist/de.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/de.output.js}}
|
_{{dist/de.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/en.output.js
|
# dist/en.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/en.output.js}}
|
_{{dist/en.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -40,11 +39,11 @@ The I18nPlugin replaces every occurrence of the i18n function `__(...)` with a c
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
|
@ -1,31 +1,31 @@
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# file.js
|
# file.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{file.js}}
|
_{{file.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# loader.js
|
# loader.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{loader.js}}
|
_{{loader.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# test.css
|
# test.css
|
||||||
|
|
||||||
``` css
|
```css
|
||||||
{{test.css}}
|
_{{test.css}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Console output
|
# Console output
|
||||||
|
@ -43,11 +43,11 @@ Prints in node.js (`enhanced-require example.js`) and in browser:
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -6,15 +6,15 @@ This example application contains 7 pages, each of them importing 1-3 modules fr
|
||||||
|
|
||||||
The following configuration is used:
|
The following configuration is used:
|
||||||
|
|
||||||
* `optimization.splitChunks.chunks: "all"` - This opt-in into automatic splitting of initial chunks which is off by default
|
- `optimization.splitChunks.chunks: "all"` - This opt-in into automatic splitting of initial chunks which is off by default
|
||||||
* `optimization.splitChunks.maxInitial/AsyncRequests: 20` - This opt-in into a HTTP2 optimized splitting mode by increasing the allowed amount of requests. Browser only supports 6 requests in parallel for HTTP1.1.
|
- `optimization.splitChunks.maxInitial/AsyncRequests: 20` - This opt-in into a HTTP2 optimized splitting mode by increasing the allowed amount of requests. Browser only supports 6 requests in parallel for HTTP1.1.
|
||||||
|
|
||||||
# Interpreting the result
|
# Interpreting the result
|
||||||
|
|
||||||
* `pageA.js` the normal output files for the entrypoint `pageA`
|
- `pageA.js` the normal output files for the entrypoint `pageA`
|
||||||
* `vendors~pageD~pageE~pageF~pageG.js` vendor libs shared by these pages extracted into a separate output file when larger then the threshold in size
|
- `vendors~pageD~pageE~pageF~pageG.js` vendor libs shared by these pages extracted into a separate output file when larger then the threshold in size
|
||||||
* `vendors~pageA.js` vendors only used by a single page but larger than the threshold in size
|
- `vendors~pageA.js` vendors only used by a single page but larger than the threshold in size
|
||||||
* `pageA~pageD~pageF.js` application modules shared by these pages and larger than the threshold in size
|
- `pageA~pageD~pageF.js` application modules shared by these pages and larger than the threshold in size
|
||||||
|
|
||||||
The threshold is here 40 bytes, but by default (in a real application) 30kb.
|
The threshold is here 40 bytes, but by default (in a real application) 30kb.
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ Note: decreasing `maxInitial/AsyncRequest` will increase duplication further to
|
||||||
## webpack.config.js
|
## webpack.config.js
|
||||||
|
|
||||||
```
|
```
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
|
@ -4,32 +4,32 @@ You see that everything is working nicely together.
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# amd.js
|
# amd.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{amd.js}}
|
_{{amd.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# commonjs.js
|
# commonjs.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{commonjs.js}}
|
_{{commonjs.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/1.output.js
|
# dist/1.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/1.output.js}}
|
_{{dist/1.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -37,11 +37,11 @@ You see that everything is working nicely together.
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,26 +1,25 @@
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/desktop.js
|
# dist/desktop.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/desktop.js}}
|
_{{dist/desktop.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/mobile.js
|
# dist/mobile.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/mobile.js}}
|
_{{dist/mobile.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -28,11 +27,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
|
@ -14,20 +14,20 @@ Note: When your library has dependencies that should not be included in the comp
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/MyLibrary.alpha.js
|
# dist/MyLibrary.alpha.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/MyLibrary.alpha.js}}
|
_{{dist/MyLibrary.alpha.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/MyLibrary.beta.js
|
# dist/MyLibrary.beta.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/MyLibrary.beta.js}}
|
_{{dist/MyLibrary.beta.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -35,11 +35,11 @@ Note: When your library has dependencies that should not be included in the comp
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -8,72 +8,72 @@ You can use
|
||||||
|
|
||||||
You can see the output files:
|
You can see the output files:
|
||||||
|
|
||||||
* `commons.js` contains:
|
- `commons.js` contains:
|
||||||
* module `common.js` which is used in both pages
|
- module `common.js` which is used in both pages
|
||||||
* `pageA.js` contains: (`pageB.js` is similar)
|
- `pageA.js` contains: (`pageB.js` is similar)
|
||||||
* the module system
|
- the module system
|
||||||
* chunk loading logic
|
- chunk loading logic
|
||||||
* the entry point `pageA.js`
|
- the entry point `pageA.js`
|
||||||
* it would contain any other module that is only used by `pageA`
|
- it would contain any other module that is only used by `pageA`
|
||||||
* `0.chunk.js` is an additional chunk which is used by both pages. It contains:
|
- `0.chunk.js` is an additional chunk which is used by both pages. It contains:
|
||||||
* module `shared.js`
|
- module `shared.js`
|
||||||
|
|
||||||
You can also see the info that is printed to console. It shows among others:
|
You can also see the info that is printed to console. It shows among others:
|
||||||
|
|
||||||
* the generated files
|
- the generated files
|
||||||
* the chunks with file, name and id
|
- the chunks with file, name and id
|
||||||
* see lines starting with `chunk`
|
- see lines starting with `chunk`
|
||||||
* the modules that are in the chunks
|
- the modules that are in the chunks
|
||||||
* the reasons why the modules are included
|
- the reasons why the modules are included
|
||||||
* the reasons why a chunk is created
|
- the reasons why a chunk is created
|
||||||
* see lines starting with `>`
|
- see lines starting with `>`
|
||||||
|
|
||||||
# pageA.js
|
# pageA.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{pageA.js}}
|
_{{pageA.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# pageB.js
|
# pageB.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{pageB.js}}
|
_{{pageB.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# pageA.html
|
# pageA.html
|
||||||
|
|
||||||
``` html
|
```html
|
||||||
{{pageA.html}}
|
_{{pageA.html}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/commons.js
|
# dist/commons.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/commons.js}}
|
_{{dist/commons.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/pageA.js
|
# dist/pageA.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/pageA.js}}
|
_{{dist/pageA.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/pageB.js
|
# dist/pageB.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/pageB.js}}
|
_{{dist/pageB.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/1.js
|
# dist/1.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/1.js}}
|
_{{dist/1.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -81,11 +81,11 @@ You can also see the info that is printed to console. It shows among others:
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,26 +1,25 @@
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/1.output.js
|
# dist/1.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/1.output.js}}
|
_{{dist/1.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/2.output.js
|
# dist/2.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/2.output.js}}
|
_{{dist/2.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -28,11 +27,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# templates/
|
# templates/
|
||||||
|
@ -21,7 +21,7 @@ module.exports = function() {
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -29,13 +29,13 @@ module.exports = function() {
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Code Splitting
|
# Code Splitting
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# a.js
|
# a.js
|
||||||
|
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
{{a.js}}
|
_{{a.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
``` javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -22,11 +22,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -8,9 +8,9 @@ All modules except `cjs` are EcmaScript modules. `cjs` is a CommonJs module.
|
||||||
|
|
||||||
The interesting thing here is that putting all modules in single scope won't work, because of multiple reasons:
|
The interesting thing here is that putting all modules in single scope won't work, because of multiple reasons:
|
||||||
|
|
||||||
* Modules `lazy`, `c`, `d` and `cjs` need to be in a separate chunk
|
- Modules `lazy`, `c`, `d` and `cjs` need to be in a separate chunk
|
||||||
* Module `shared` is accessed by two chunks (different scopes)
|
- Module `shared` is accessed by two chunks (different scopes)
|
||||||
* Module `cjs` is a CommonJs module
|
- Module `cjs` is a CommonJs module
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@ -22,85 +22,80 @@ While module concatenation identifiers in modules are renamed to avoid conflicts
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# lazy.js
|
# lazy.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{lazy.js}}
|
_{{lazy.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# a.js
|
# a.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{node_modules/a.js}}
|
_{{node_modules/a.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# b.js
|
# b.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{node_modules/b.js}}
|
_{{node_modules/b.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# c.js
|
# c.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{node_modules/c.js}}
|
_{{node_modules/c.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# d.js
|
# d.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{node_modules/d.js}}
|
_{{node_modules/d.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# cjs.js
|
# cjs.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{node_modules/cjs.js}}
|
_{{node_modules/cjs.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# shared.js
|
# shared.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{node_modules/shared.js}}
|
_{{node_modules/shared.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# shared2.js
|
# shared2.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{node_modules/shared2.js}}
|
_{{node_modules/shared2.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/1.output.js
|
# dist/1.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/1.output.js}}
|
_{{dist/1.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
Minimized
|
Minimized
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{production:dist/1.output.js}}
|
_{{production:dist/1.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -108,11 +103,11 @@ Minimized
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -10,37 +10,37 @@ After being built by webpack, the output bundle contains `index.js` `a.js` `b.js
|
||||||
|
|
||||||
Advantages:
|
Advantages:
|
||||||
|
|
||||||
* Smaller bundles
|
- Smaller bundles
|
||||||
* Faster bootup
|
- Faster bootup
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# node_modules/big-module/package.json
|
# node_modules/big-module/package.json
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{node_modules/big-module/package.json}}
|
_{{node_modules/big-module/package.json}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# node_modules/big-module-with-flag/package.json
|
# node_modules/big-module-with-flag/package.json
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{node_modules/big-module-with-flag/package.json}}
|
_{{node_modules/big-module-with-flag/package.json}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# node_modules/big-module(-with-flag)/index.js
|
# node_modules/big-module(-with-flag)/index.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{node_modules/big-module-with-flag/index.js}}
|
_{{node_modules/big-module-with-flag/index.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -48,11 +48,11 @@ Advantages:
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -2,78 +2,88 @@ This example demonstrates various types of source-maps.
|
||||||
|
|
||||||
# example.coffee
|
# example.coffee
|
||||||
|
|
||||||
``` coffeescript
|
```coffeescript
|
||||||
{{example.coffee}}
|
_{{example.coffee}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Generated source-maps
|
# Generated source-maps
|
||||||
|
|
||||||
## source-map.js and source-map.js.map
|
## source-map.js and source-map.js.map
|
||||||
``` javascript
|
|
||||||
{{dist/bundle-source-map.js}}
|
```javascript
|
||||||
|
_{{dist/bundle-source-map.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/bundle-source-map.js.map}}
|
_{{dist/bundle-source-map.js.map}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## hidden-source-map.js and hidden-source-map.js.map
|
## hidden-source-map.js and hidden-source-map.js.map
|
||||||
``` javascript
|
|
||||||
{{dist/bundle-hidden-source-map.js}}
|
```javascript
|
||||||
|
_{{dist/bundle-hidden-source-map.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/bundle-hidden-source-map.js.map}}
|
_{{dist/bundle-hidden-source-map.js.map}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## inline-source-map.js
|
## inline-source-map.js
|
||||||
``` javascript
|
|
||||||
{{dist/bundle-inline-source-map.js}}
|
```javascript
|
||||||
|
_{{dist/bundle-inline-source-map.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## nosources-source-map.js.map
|
## nosources-source-map.js.map
|
||||||
``` javascript
|
|
||||||
{{dist/bundle-nosources-source-map.js.map}}
|
```javascript
|
||||||
|
_{{dist/bundle-nosources-source-map.js.map}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## eval-source-map.js
|
## eval-source-map.js
|
||||||
``` javascript
|
|
||||||
{{dist/bundle-eval-source-map.js}}
|
```javascript
|
||||||
|
_{{dist/bundle-eval-source-map.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## eval.js
|
## eval.js
|
||||||
``` javascript
|
|
||||||
{{dist/bundle-eval.js}}
|
```javascript
|
||||||
|
_{{dist/bundle-eval.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## cheap-eval-source-map.js
|
## cheap-eval-source-map.js
|
||||||
``` javascript
|
|
||||||
{{dist/bundle-cheap-eval-source-map.js}}
|
```javascript
|
||||||
|
_{{dist/bundle-cheap-eval-source-map.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## cheap-module-eval-source-map.js
|
## cheap-module-eval-source-map.js
|
||||||
``` javascript
|
|
||||||
{{dist/bundle-cheap-module-eval-source-map.js}}
|
```javascript
|
||||||
|
_{{dist/bundle-cheap-module-eval-source-map.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## cheap-module-source-map.js.map
|
## cheap-module-source-map.js.map
|
||||||
``` javascript
|
|
||||||
{{dist/bundle-cheap-module-source-map.js.map}}
|
```javascript
|
||||||
|
_{{dist/bundle-cheap-module-source-map.js.map}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## cheap-source-map.js.map
|
## cheap-source-map.js.map
|
||||||
``` javascript
|
|
||||||
{{dist/bundle-cheap-source-map.js.map}}
|
```javascript
|
||||||
|
_{{dist/bundle-cheap-source-map.js.map}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# webpack output
|
# webpack output
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
# webpack.config.js
|
# webpack.config.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{webpack.config.js}}
|
_{{webpack.config.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/vendor1.js
|
# dist/vendor1.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/vendor1.js}}
|
_{{dist/vendor1.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/vendor2.js
|
# dist/vendor2.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/vendor2.js}}
|
_{{dist/vendor2.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/pageA.js
|
# dist/pageA.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/pageA.js}}
|
_{{dist/pageA.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -27,11 +27,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -4,32 +4,32 @@ WebAssembly modules can be imported like other modules. Their download and compi
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# math.js
|
# math.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{math.js}}
|
_{{math.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/1.output.js
|
# dist/1.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/1.output.js}}
|
_{{dist/1.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/2.output.js
|
# dist/2.output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/2.output.js}}
|
_{{dist/2.output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -37,11 +37,11 @@ WebAssembly modules can be imported like other modules. Their download and compi
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,32 +1,31 @@
|
||||||
|
|
||||||
# example.js
|
# example.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{example.js}}
|
_{{example.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# worker.js
|
# worker.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{worker.js}}
|
_{{worker.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/output.js
|
# dist/output.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/output.js}}
|
_{{dist/output.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/[hash].worker.js
|
# dist/[hash].worker.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/hash.worker.js}}
|
_{{dist/hash.worker.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# dist/1.[hash].worker.js
|
# dist/1.[hash].worker.js
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
{{dist/1.hash.worker.js}}
|
_{{dist/1.hash.worker.js}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
|
@ -34,11 +33,11 @@
|
||||||
## Unoptimized
|
## Unoptimized
|
||||||
|
|
||||||
```
|
```
|
||||||
{{stdout}}
|
_{{stdout}}_
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production mode
|
## Production mode
|
||||||
|
|
||||||
```
|
```
|
||||||
{{production:stdout}}
|
_{{production:stdout}}_
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue