Skip to content

Commit 5b25024

Browse files
committed
Merge
2 parents 8738b8d + 36e4fd2 commit 5b25024

File tree

217 files changed

+2605
-1378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+2605
-1378
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/coverage
88
.DS_Store
99
*.log
10+
.idea

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
sudo: false
22
language: node_js
3+
os:
4+
- linux
5+
- osx
36
node_js:
47
- node
8+
- "6"
59
- "5"
10+
- "4"
611
- "0.12"
712
script: npm run travis
813
env:
914
- NO_WATCH_TESTS=1
1015

11-
before_install:
12-
- '[ "${TRAVIS_NODE_VERSION}" != "0.10" ] || npm install -g npm@^2'
13-
1416
before_script:
1517
- npm link
1618
- npm link webpack

CONTRIBUTING.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
21
# Contributing
32

3+
From opening a bug report to creating a pull request: every contribution is
4+
appreciated and welcome. If you're planning to implement a new feature or change
5+
the api please create an issue first. This way we can ensure that your precious
6+
work is not in vain.
7+
8+
## Issues
9+
410
Most of the time, if webpack is not working correctly for you it is a simple configuration issue.
511

612
If you are still having difficulty after looking over your configuration carefully, please post
@@ -9,25 +15,31 @@ that include your webpack.config.js and relevant files are more likely to receiv
915

1016
**If you have discovered a bug or have a feature suggestion, feel free to create an issue on Github.**
1117

18+
## Contributing to the webpack ecosystem
19+
1220
If you have created your own loader/plugin please include it on the relevant
1321
documentation pages:
1422

15-
[List of loaders](https://webpack.github.io/docs/list-of-loaders.html)
23+
[List of loaders](https://webpack.github.io/docs/list-of-loaders.html)
1624
[List of plugins](https://webpack.github.io/docs/list-of-plugins.html)
1725

18-
### Documentation
26+
## Setup
1927

20-
webpack is insanely feature rich and documentation is a huge time sink. We
21-
greatly appreciate any time spent fixing typos or clarifying sections in the
22-
documentation.
28+
```bash
29+
git clone https://github.com/webpack/webpack.git
30+
cd webpack
31+
npm install
32+
npm link
33+
npm link webpack
34+
```
2335

36+
To run the entire test suite use:
2437

25-
## Submitting Changes
38+
```bash
39+
npm test
40+
```
2641

27-
From opening a bug report to creating a pull request: every contribution is
28-
appreciated and welcome. If you're planning to implement a new feature or change
29-
the api please create an issue first. This way we can ensure that your precious
30-
work is not in vain.
42+
## Submitting Changes
3143

3244
After getting some feedback, push to your fork and submit a pull request. We
3345
may suggest some changes or improvements or alternatives, but for small changes
@@ -38,3 +50,9 @@ Some things that will increase the chance that your pull request is accepted:
3850
* Write tests
3951
* Follow the existing coding style
4052
* Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
53+
54+
## Documentation
55+
56+
webpack is insanely feature rich and documentation is a huge time sink. We
57+
greatly appreciate any time spent fixing typos or clarifying sections in the
58+
documentation.

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ or packaging just about any resource or asset.
2727

2828
**TL; DR**
2929

30-
* Bundles both [CommonJs](http://wiki.commonjs.org/) and [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules (even combined).
30+
* Bundles both [CommonJS](http://wiki.commonjs.org/) and [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules (even combined).
3131
* Can create a single bundle or multiple chunks that are asynchronously loaded at runtime (to reduce initial loading time).
3232
* Dependencies are resolved during compilation reducing the runtime size.
3333
* Loaders can preprocess files while compiling, e.g. coffeescript to JavaScript, handlebars strings to compiled functions, images to Base64, etc.
@@ -158,7 +158,7 @@ friendly** by using hashes.
158158
// This means webpack takes modules with dependencies
159159
// and emits static assets representing those modules.
160160

161-
// Dependencies can be written in CommonJs
161+
// Dependencies can be written in CommonJS
162162
var commonjs = require("./commonjs");
163163
// or in AMD
164164
define(["amd-module", "../file"], function (amdModule, file) {
@@ -254,7 +254,7 @@ MIT (http://opensource.org/licenses/mit-license.php)
254254

255255
(In chronological order)
256256

257-
* @google for [Google Web Toolkit (GWT)](https://code.google.com/archive/p/google-web-toolkit), which aims to compile Java to JavaScript. It features a similar [Code Splitting](https://code.google.com/archive/p/google-web-toolkit/wikis/CodeSplitting.wiki) as webpack.
257+
* @google for [Google Web Toolkit (GWT)](https://code.google.com/archive/p/google-web-toolkit), which aims to compile Java to JavaScript. It features a similar [Code Splitting](http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html) as webpack.
258258
* @medikoo for [modules-webmake](https://github.com/medikoo/modules-webmake), which is a similar 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).
259259
* @substack for [browserify](http://browserify.org/), which is a similar project and source for many ideas.
260260
* @jrburke for [require.js](http://requirejs.org/), which is a similar project and source for many ideas.
@@ -269,6 +269,8 @@ MIT (http://opensource.org/licenses/mit-license.php)
269269

270270
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.
271271

272+
Another way you can help fund Webpack is by buying the ebook ["SurviveJS - Webpack"](https://leanpub.com/survivejs-webpack), where around ~30% of the book's profit will go to me.
273+
272274
I'm very thankful for every dollar. If you leave your username or email, I may show my thanks by giving you extra support.
273275

274276

@@ -286,7 +288,7 @@ I'm very thankful for every dollar. If you leave your username or email, I may s
286288

287289

288290
[travis-url]: https://travis-ci.org/webpack/webpack
289-
[travis-image]: https://img.shields.io/travis/webpack/webpack.svg
291+
[travis-image]: https://img.shields.io/travis/webpack/webpack/master.svg
290292
[appveyor-url]: https://ci.appveyor.com/project/sokra/webpack/branch/master
291293
[appveyor-image]: https://ci.appveyor.com/api/projects/status/github/webpack/webpack?svg=true
292294
[coveralls-url]: https://coveralls.io/r/webpack/webpack/

benchmark/createFixtures2.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
var path = require("path");
2+
var fs = require("fs");
3+
4+
var fixtures = path.join(__dirname, "fixtures");
5+
6+
try {
7+
fs.mkdirSync(fixtures);
8+
} catch(e) {}
9+
10+
function genModule(prefix, depth, asyncDepth, multiplex, r, circular) {
11+
var source = [];
12+
var async = depth >= asyncDepth;
13+
if(!async)
14+
circular.push(path.resolve(fixtures, prefix + "/index.js"));
15+
source.push("(function() {");
16+
var m = (r % multiplex) + 1;
17+
var sum = 1;
18+
try {
19+
fs.mkdirSync(path.resolve(fixtures, prefix));
20+
} catch(e) {}
21+
if(depth > 0) {
22+
for(var i = 0; i < m; i++) {
23+
sum += genModule(prefix + "/" + i, depth - 1, asyncDepth, multiplex, (r + i + depth) * m + i + depth, circular);
24+
source.push("require(" + JSON.stringify("./" + i) + ");");
25+
if(i === 0) {
26+
if(async)
27+
source.push("}); require.ensure([], function() {");
28+
}
29+
}
30+
var item = circular[r % circular.length];
31+
}
32+
source.push("}, " + JSON.stringify(prefix) + ");");
33+
if(item)
34+
source.push("require(" + JSON.stringify(item) + ");");
35+
source.push("module.exports = " + JSON.stringify(prefix) + ";");
36+
fs.writeFileSync(path.resolve(fixtures, prefix + "/index.js"), source.join("\n"), "utf-8");
37+
return sum;
38+
}
39+
40+
for(var i = 2; i < 14; i++) {
41+
var count = genModule("tree-" + i, 6, 100, i, 0, []);
42+
console.log("generated tree", i, count);
43+
}
44+
45+
for(var i = 2; i < 14; i++) {
46+
var count = genModule("async-tree-" + i, 6, 1, i, 0, []);
47+
console.log("generated async tree", i, count);
48+
}
49+
50+
var a = genModule("module-async", 7, 1, 3, 2, []);
51+
52+
var b = genModule("module-big-async", 5, 2, 9, 2, []);
53+
54+
var c = genModule("module-broad-async", 3, 3, 20, 10, []);
55+
56+
console.log("generated modules", a, b, c);

bin/convert-argv.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,7 @@ module.exports = function(optimist, argv, convertOptions) {
376376
ifBooleanArg("hot", function() {
377377
ensureArray(options, "plugins");
378378
var HotModuleReplacementPlugin = require("../lib/HotModuleReplacementPlugin");
379-
options.plugins.push(new HotModuleReplacementPlugin({
380-
multiStep: true
381-
}));
379+
options.plugins.push(new HotModuleReplacementPlugin());
382380
});
383381

384382
ifBooleanArg("debug", function() {
@@ -426,7 +424,9 @@ module.exports = function(optimist, argv, convertOptions) {
426424
ensureArray(options, "plugins");
427425
var UglifyJsPlugin = require("../lib/optimize/UglifyJsPlugin");
428426
var LoaderOptionsPlugin = require("../lib/LoaderOptionsPlugin");
429-
options.plugins.push(new UglifyJsPlugin());
427+
options.plugins.push(new UglifyJsPlugin({
428+
sourceMap: options.devtool && (options.devtool.indexOf("sourcemap") >= 0 || options.devtool.indexOf("source-map") >= 0)
429+
}));
430430
options.plugins.push(new LoaderOptionsPlugin({
431431
minimize: true
432432
}));

bin/webpack.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ function processOptions(options) {
133133
return;
134134
}
135135

136-
var firstOptions = Array.isArray(options) ? options[0] : options;
136+
var firstOptions = Array.isArray(options) ? (options[0] || {}) : options;
137+
138+
if(typeof options.stats === "boolean" || typeof options.stats === "string") {
139+
var statsPresetToOptions = require("../lib/Stats.js").presetToOptions;
140+
options.stats = statsPresetToOptions(options.stats);
141+
}
137142

138143
var outputOptions = Object.create(options.stats || firstOptions.stats || {});
139144
if(typeof outputOptions.context === "undefined")

buildin/global.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var g;
2+
3+
// This works in non-strict mode
4+
g = (function() { return this; })();
5+
6+
try {
7+
// This works if eval is allowed (see CSP)
8+
g = g || Function("return this")() || (1,eval)("this");
9+
} catch(e) {
10+
// This works if the window reference is available
11+
if(typeof window === "object")
12+
g = window;
13+
}
14+
15+
// g can still be undefined, but nothing to do about it...
16+
// We return undefined, instead of nothing here, so it's
17+
// easier to handle this case. if(!global) { ...}
18+
19+
module.exports = g;

buildin/module.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ module.exports = function(module) {
33
module.deprecate = function() {};
44
module.paths = [];
55
// module.parent = undefined by default
6-
module.children = [];
7-
Object.defineProperty(module, "exports", {
8-
enumerable: true,
9-
configurable: false,
10-
get: function() { return module.e; },
11-
set: function(v) { return module.e = v; }
12-
});
6+
if(!module.children) module.children = [];
137
Object.defineProperty(module, "loaded", {
148
enumerable: true,
159
configurable: false,

examples/agressive-merging/README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ module.exports = {
5757

5858
```
5959
Hash: 042a9d90b141419e1b34
60-
Version: webpack 2.0.6-beta
61-
Time: 116ms
60+
Version: webpack 2.1.0-beta.11
61+
Time: 84ms
6262
Asset Size Chunks Chunk Names
6363
0.chunk.js 5.72 kB 0 [emitted]
64-
pageB.bundle.js 4.72 kB 1 [emitted] pageB
65-
pageA.bundle.js 4.69 kB 2 [emitted] pageA
64+
pageB.bundle.js 5 kB 1 [emitted] pageB
65+
pageA.bundle.js 4.97 kB 2 [emitted] pageA
6666
3.chunk.js 291 bytes 3 [emitted]
67-
pageC.bundle.js 4.54 kB 4 [emitted] pageC
67+
pageC.bundle.js 4.82 kB 4 [emitted] pageC
6868
chunk {0} 0.chunk.js 5.55 kB {2} {1} [rendered]
6969
> [3] ./pageA.js 1:0-3:2
7070
> aggressive-merge [4] ./pageB.js 1:0-3:2
@@ -100,14 +100,14 @@ chunk {4} pageC.bundle.js (pageC) 70 bytes [rendered]
100100

101101
```
102102
Hash: 042a9d90b141419e1b34
103-
Version: webpack 2.0.6-beta
104-
Time: 317ms
103+
Version: webpack 2.1.0-beta.11
104+
Time: 253ms
105105
Asset Size Chunks Chunk Names
106106
0.chunk.js 75 bytes 0 [emitted]
107-
pageB.bundle.js 1.1 kB 1 [emitted] pageB
108-
pageA.bundle.js 1.1 kB 2 [emitted] pageA
107+
pageB.bundle.js 1.18 kB 1 [emitted] pageB
108+
pageA.bundle.js 1.18 kB 2 [emitted] pageA
109109
3.chunk.js 78 bytes 3 [emitted]
110-
pageC.bundle.js 1.09 kB 4 [emitted] pageC
110+
pageC.bundle.js 1.17 kB 4 [emitted] pageC
111111
chunk {0} 0.chunk.js 5.55 kB {2} {1} [rendered]
112112
> [3] ./pageA.js 1:0-3:2
113113
> aggressive-merge [4] ./pageB.js 1:0-3:2
@@ -137,7 +137,4 @@ chunk {3} 3.chunk.js 42 bytes {4} [rendered]
137137
chunk {4} pageC.bundle.js (pageC) 70 bytes [rendered]
138138
> pageC [5] ./pageC.js
139139
[5] ./pageC.js 70 bytes {4} [built]
140-
141-
WARNING in 0.chunk.js from UglifyJs
142-
Dropping unused variable justToBeABigFile [./common.js:4,0]
143140
```

0 commit comments

Comments
 (0)