Skip to content

Commit 94ba35c

Browse files
committed
Merge branch 'master' into webpack-2
Conflicts: lib/WebpackOptionsApply.js
2 parents 5454a89 + 69df24c commit 94ba35c

35 files changed

+157
-80
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,21 @@ Copyright (c) 2012-2015 Tobias Koppers
236236

237237
MIT (http://www.opensource.org/licenses/mit-license.php)
238238

239+
## Thanks to
240+
241+
(In chronological order)
242+
243+
* @google for [Google Web Toolkit (GWT)](https://code.google.com/p/google-web-toolkit), which aims to compile Java to Javascript. It features a similar [Code Splitting](https://code.google.com/p/google-web-toolkit/wiki/CodeSplitting) as webpack.
244+
* @medikoo for [modules-webmake](https://github.com/medikoo/modules-webmake), which is a simlar project. webpack was born because I wanted Code Splitting for modules-webpack. Interestingly the [Code Splitting issue is still open](https://github.com/medikoo/modules-webmake/issues/7) (thanks also to @Phoscur for the discussion).
245+
* @substack for [browserify](http://browserify.org/), which is a similar project and source for many ideas.
246+
* @jrburke for [require.js](http://requirejs.org/), which is a similar project and source for many ideas.
247+
* @defunctzombie for the [browser-field spec](https://gist.github.com/defunctzombie/4339901), which makes modules available for node.js, browserify and webpack.
248+
* Every early webpack user, which contributed to webpack by writing issues or PRs. You influenced the direction...
249+
* @shama, @jhnns and @sokra for maintaining this project
250+
* Everyone who has written a loader for webpack. You are the ecosystem...
251+
* Everyone I forgot to mention here, but also influenced webpack.
252+
253+
239254
## Sponsor
240255

241256
This is a free-time project. The time I invest in it fluctuates. If you use webpack for a serious task, and you'd like me to invest more time on it, please donate. This project increases your income/productivity too. It makes development and applications faster and it reduces the required bandwidth.

bin/webpack.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ function ifArg(name, fn, init) {
6363
}
6464
}
6565

66+
var firstOptions = Array.isArray(options) ? options[0] : options;
6667

67-
68-
var outputOptions = {
69-
cached: false,
70-
cachedAssets: false,
71-
context: options.context
72-
};
68+
var outputOptions = Object.create(options.stats || firstOptions.stats || {});
69+
if(typeof outputOptions.context === "undefined")
70+
outputOptions.context = firstOptions.context;
7371

7472
ifArg("json", function(bool) {
75-
outputOptions.json = bool;
73+
if(bool)
74+
outputOptions.json = bool;
7675
});
7776

78-
outputOptions.colors = require("supports-color");
77+
if(typeof outputOptions.colors === "undefined")
78+
outputOptions.colors = require("supports-color");
7979

8080
ifArg("sort-modules-by", function(value) {
8181
outputOptions.modulesSort = value;
@@ -94,6 +94,11 @@ ifArg("display-exclude", function(value) {
9494
});
9595

9696
if(!outputOptions.json) {
97+
if(typeof outputOptions.cached === "undefined")
98+
outputOptions.cached = false;
99+
if(typeof outputOptions.cachedAssets === "undefined")
100+
outputOptions.cachedAssets = false;
101+
97102
ifArg("display-chunks", function(bool) {
98103
outputOptions.modules = !bool;
99104
outputOptions.chunks = bool;
@@ -124,12 +129,18 @@ if(!outputOptions.json) {
124129
if(!outputOptions.exclude && !argv["display-modules"])
125130
outputOptions.exclude = ["node_modules", "bower_components", "jam", "components"];
126131
} else {
127-
outputOptions.chunks = true;
128-
outputOptions.modules = true;
129-
outputOptions.chunkModules = true;
130-
outputOptions.reasons = true;
131-
outputOptions.cached = true;
132-
outputOptions.cachedAssets = true;
132+
if(typeof outputOptions.chunks === "undefined")
133+
outputOptions.chunks = true;
134+
if(typeof outputOptions.modules === "undefined")
135+
outputOptions.modules = true;
136+
if(typeof outputOptions.chunkModules === "undefined")
137+
outputOptions.chunkModules = true;
138+
if(typeof outputOptions.reasons === "undefined")
139+
outputOptions.reasons = true;
140+
if(typeof outputOptions.cached === "undefined")
141+
outputOptions.cached = true;
142+
if(typeof outputOptions.cachedAssets === "undefined")
143+
outputOptions.cachedAssets = true;
133144
}
134145

135146
ifArg("hide-modules", function(bool) {

examples/code-splitting/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
This example illustrate a very simple case of Code Splitting with `require.ensure`.
1+
This example illustrates a very simple case of Code Splitting with `require.ensure`.
22

3-
* `a` and `b` are required normally via CommonsJs
3+
* `a` and `b` are required normally via CommonJS
44
* `c` is depdended through the `require.ensure` array.
55
* This means: make it available, but don't execute it
66
* webpack will load it on demand
@@ -12,7 +12,7 @@ This example illustrate a very simple case of Code Splitting with `require.ensur
1212

1313
You can see that webpack outputs two files/chunks:
1414

15-
* `output.js` is the entry chunks and contains
15+
* `output.js` is the entry chunk and contains
1616
* the module system
1717
* chunk loading logic
1818
* the entry point `example.js`

examples/code-splitting/template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
This example illustrate a very simple case of Code Splitting with `require.ensure`.
1+
This example illustrates a very simple case of Code Splitting with `require.ensure`.
22

3-
* `a` and `b` are required normally via CommonsJs
3+
* `a` and `b` are required normally via CommonJS
44
* `c` is depdended through the `require.ensure` array.
55
* This means: make it available, but don't execute it
66
* webpack will load it on demand
@@ -12,7 +12,7 @@ This example illustrate a very simple case of Code Splitting with `require.ensur
1212

1313
You can see that webpack outputs two files/chunks:
1414

15-
* `output.js` is the entry chunks and contains
15+
* `output.js` is the entry chunk and contains
1616
* the module system
1717
* chunk loading logic
1818
* the entry point `example.js`

examples/commonjs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
This very simple example shows usage of CommonsJS.
1+
This very simple example shows usage of CommonJS.
22

33
The three files `example.js`, `increment.js` and `math.js` form a dependency chain. They use `require(dependency)` to declare dependencies.
44

5-
You can see the output file that webpack creates by bundling them together in one file. Keep in mind that webpack adds comments to make reading this file easier. These commonent are removed when minimizing the file.
5+
You can see the output file that webpack creates by bundling them together in one file. Keep in mind that webpack adds comments to make reading this file easier. These comments are removed when minimizing the file.
66

77
You can also see the info messages webpack prints to console (for both normal and minimized build).
88

examples/commonjs/template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
This very simple example shows usage of CommonsJS.
1+
This very simple example shows usage of CommonJS.
22

33
The three files `example.js`, `increment.js` and `math.js` form a dependency chain. They use `require(dependency)` to declare dependencies.
44

5-
You can see the output file that webpack creates by bundling them together in one file. Keep in mind that webpack adds comments to make reading this file easier. These commonent are removed when minimizing the file.
5+
You can see the output file that webpack creates by bundling them together in one file. Keep in mind that webpack adds comments to make reading this file easier. These comments are removed when minimizing the file.
66

77
You can also see the info messages webpack prints to console (for both normal and minimized build).
88

examples/externals/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
This example demonstrate how to build a library with webpack that has dependencies to other libraries which should not be included in the compiled version.
1+
This example demonstrates how to build a library with webpack that has dependencies to other libraries which should not be included in the compiled version.
22

33
We use the `libraryTarget: "umd"` option to build a UMD module that is consumable in CommonJs, AMD and with script tags. We don't specify the `library` option so the library is exported to the root namespace.
44

55
We use the `externals` option to define dependencies that should be resolved in the target environment.
66

7-
In the simple case we just need to specify a string (`"add"`). Than it's resolved as `"add"` module in CommonJs and AMD, and as global `add` when used with script tag.
7+
In the simple case we just need to specify a string (`"add"`). Then it's resolved as `"add"` module in CommonJs and AMD, and as global `add` when used with script tag.
88

99
In the complex case we specify different values for each environment:
1010

examples/externals/template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
This example demonstrate how to build a library with webpack that has dependencies to other libraries which should not be included in the compiled version.
1+
This example demonstrates how to build a library with webpack that has dependencies to other libraries which should not be included in the compiled version.
22

33
We use the `libraryTarget: "umd"` option to build a UMD module that is consumable in CommonJs, AMD and with script tags. We don't specify the `library` option so the library is exported to the root namespace.
44

55
We use the `externals` option to define dependencies that should be resolved in the target environment.
66

7-
In the simple case we just need to specify a string (`"add"`). Than it's resolved as `"add"` module in CommonJs and AMD, and as global `add` when used with script tag.
7+
In the simple case we just need to specify a string (`"add"`). Then it's resolved as `"add"` module in CommonJs and AMD, and as global `add` when used with script tag.
88

99
In the complex case we specify different values for each environment:
1010

examples/multiple-entry-points/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
This example show how to use multiple entry points with a commons chunk.
1+
This example shows how to use multiple entry points with a commons chunk.
22

3-
In this example you have two (HTML) pages `pageA` and `pageB`. You want to create individual bundles for each page. In addition to this you want to create a shared bundle that contains all modules that used in both pages (assuming there are many/big modules in common). The pages also use Code Splitting to load a less used part of the features on demand.
3+
In this example you have two (HTML) pages `pageA` and `pageB`. You want to create individual bundles for each page. In addition to this you want to create a shared bundle that contains all modules used in both pages (assuming there are many/big modules in common). The pages also use Code Splitting to load a less used part of the features on demand.
44

55
You can see how to define multiple entry points via the `entry` option and the required changes (`[name]`) in the `output` option. You can also see how to use the CommonsChunkPlugin.
66

@@ -13,15 +13,15 @@ You can see the output files:
1313
* `pageA.bundle.js` contains: (`pageB.bundle.js` is similar)
1414
* the entry point `pageA.js`
1515
* it would contain any other module that is only used by `pageA`
16-
* `0.chunk.js` is an additional chunk which if used by both pages. It contains:
16+
* `0.chunk.js` is an additional chunk which is used by both pages. It contains:
1717
* module `shared.js`
1818

1919
You can also see the info that is printed to console. It shows among others:
2020

2121
* the generated files
2222
* the chunks with file, name and id
2323
* see lines starting with `chunk`
24-
* the modules that are in this chunks
24+
* the modules that are in the chunks
2525
* the reasons why the modules are included
2626
* the reasons why a chunk is created
2727
* see lines starting with `>`
@@ -63,7 +63,7 @@ module.exports = {
6363
plugins: [
6464
new CommonsChunkPlugin("commons.js")
6565
]
66-
}
66+
};
6767
```
6868

6969
# pageA.html

examples/multiple-entry-points/template.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
This example show how to use multiple entry points with a commons chunk.
1+
This example shows how to use multiple entry points with a commons chunk.
22

3-
In this example you have two (HTML) pages `pageA` and `pageB`. You want to create individual bundles for each page. In addition to this you want to create a shared bundle that contains all modules that used in both pages (assuming there are many/big modules in common). The pages also use Code Splitting to load a less used part of the features on demand.
3+
In this example you have two (HTML) pages `pageA` and `pageB`. You want to create individual bundles for each page. In addition to this you want to create a shared bundle that contains all modules used in both pages (assuming there are many/big modules in common). The pages also use Code Splitting to load a less used part of the features on demand.
44

55
You can see how to define multiple entry points via the `entry` option and the required changes (`[name]`) in the `output` option. You can also see how to use the CommonsChunkPlugin.
66

@@ -13,15 +13,15 @@ You can see the output files:
1313
* `pageA.bundle.js` contains: (`pageB.bundle.js` is similar)
1414
* the entry point `pageA.js`
1515
* it would contain any other module that is only used by `pageA`
16-
* `0.chunk.js` is an additional chunk which if used by both pages. It contains:
16+
* `0.chunk.js` is an additional chunk which is used by both pages. It contains:
1717
* module `shared.js`
1818

1919
You can also see the info that is printed to console. It shows among others:
2020

2121
* the generated files
2222
* the chunks with file, name and id
2323
* see lines starting with `chunk`
24-
* the modules that are in this chunks
24+
* the modules that are in the chunks
2525
* the reasons why the modules are included
2626
* the reasons why a chunk is created
2727
* see lines starting with `>`

0 commit comments

Comments
 (0)