Skip to content

Commit 4105297

Browse files
authored
Merge branch 'next' into deprecation/webpack-3
2 parents 6eed938 + d87c88e commit 4105297

386 files changed

Lines changed: 7586 additions & 5086 deletions

File tree

Some content is hidden

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

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module.exports = {
3636
"space-before-function-paren": ["error", "never"],
3737
"space-before-blocks": "error",
3838
"object-curly-spacing": ["error", "always"],
39+
"indent": "off",
3940
"keyword-spacing": ["error", {
4041
"after": false,
4142
"overrides": {

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/test/fixtures/temp-cache-fixture
55
/benchmark/js
66
/benchmark/fixtures
7-
/examples/*/js
7+
/examples/**/js
88
/coverage
99
.DS_Store
1010
*.log

.travis.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
sudo: false
2+
dist: trusty
23
language: node_js
34

45
branches:
@@ -7,9 +8,7 @@ branches:
78
- next
89

910
cache:
10-
directories:
11-
- $HOME/.npm
12-
- $HOME/.yarn-cache
11+
yarn: true
1312

1413
matrix:
1514
include:
@@ -23,16 +22,16 @@ matrix:
2322
node_js: "6"
2423
env: NO_WATCH_TESTS=1 JOB_PART=test
2524
- os: linux
26-
node_js: "4.3"
25+
node_js: "4"
2726
env: NO_WATCH_TESTS=1 JOB_PART=test
2827
- os: osx
29-
node_js: "7"
28+
node_js: "8"
3029
env: NO_WATCH_TESTS=1 JOB_PART=test
3130
allow_failures:
3231
- os: osx
3332
fast_finish: true
3433

35-
before_script:
34+
install:
3635
- bash ./ci/travis-install.sh
3736

3837
script: npm run travis:$JOB_PART

README.md

Lines changed: 68 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1+
<div align="center">
2+
<a href="https://github.com/webpack/webpack">
3+
<img width="200" heigth="200" src="https://webpack.js.org/assets/icon-square-big.svg">
4+
</a>
5+
<br>
6+
<br>
7+
18
[![npm][npm]][npm-url]
9+
210
[![node][node]][node-url]
311
[![deps][deps]][deps-url]
412
[![tests][tests]][tests-url]
513
[![builds][builds]][builds-url]
614
[![coverage][cover]][cover-url]
715
[![licenses][licenses]][licenses-url]
816

9-
<div align="center">
10-
<a href="https://github.com/webpack/webpack">
11-
<img width="200" heigth="200" src="https://webpack.js.org/assets/icon-square-big.svg">
12-
</a>
13-
<br>
1417
<br>
1518
<a href="https://npmjs.com/package/webpack">
1619
<img src="https://img.shields.io/npm/dm/webpack.svg">
@@ -32,13 +35,21 @@
3235

3336
<h2 align="center">Install</h2>
3437

38+
Install with npm:
39+
3540
```bash
3641
npm install --save-dev webpack
3742
```
3843

44+
Install with yarn:
45+
46+
```bash
47+
yarn add webpack --dev
48+
```
49+
3950
<h2 align="center">Introduction</h2>
4051

41-
> The README reflects webpack v2.x, webpack v1.x [documentation can be found here](https://webpack.github.io/docs/?utm_source=github&utm_medium=readme&utm_campaign=top).
52+
> This README reflects Webpack v2.x and v3.x. The Webpack v1.x [documentation can be found here](https://webpack.github.io/docs/?utm_source=github&utm_medium=readme&utm_campaign=top).
4253
4354
webpack is a bundler for modules. The main purpose is to bundle JavaScript
4455
files for usage in a browser, yet it is also capable of transforming, bundling,
@@ -69,7 +80,6 @@ within webpack itself use this plugin interface. This makes webpack very
6980
|:--:|:----:|:----------|
7081
|[common-chunks-webpack-plugin][common]|![common-npm]|Generates chunks of common modules shared between entry points and splits them into separate bundles (e.g vendor.bundle.js && app.bundle.js)|
7182
|[extract-text-webpack-plugin][extract]|![extract-npm]|Extracts Text (CSS) from your bundles into a separate file (app.bundle.css)|
72-
|[component-webpack-plugin][component]|![component-npm]|Use components with webpack|
7383
|[compression-webpack-plugin][compression]|![compression-npm]|Prepare compressed versions of assets to serve them with Content-Encoding|
7484
|[i18n-webpack-plugin][i18n]|![i18n-npm]|Adds i18n support to your bundles|
7585
|[html-webpack-plugin][html-plugin]|![html-plugin-npm]| Simplifies creation of HTML files (`index.html`) to serve your bundles|
@@ -121,7 +131,7 @@ or are automatically applied via regex from your webpack configuration.
121131
|Name|Status|Description|
122132
|:--:|:----:|:----------|
123133
|<a href="https://github.com/webpack/json-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/json.svg"></a>|![json-npm]|Loads a JSON file (included by default)|
124-
|<a href="https://github.com/webpack/json5-loader"><img width="48" height="48" src="https://cdn.rawgit.com/json5/json5-logo/master/json5-logo.svg"></a>|![json5-npm]|Loads and transpiles a JSON 5 file|
134+
|<a href="https://github.com/webpack/json5-loader"><img width="48" height="10.656" src="https://cdn.rawgit.com/json5/json5-logo/master/json5-logo.svg"></a>|![json5-npm]|Loads and transpiles a JSON 5 file|
125135
|<a href="https://github.com/awnist/cson-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a>|![cson-npm]|Loads and transpiles a CSON file|
126136

127137

@@ -184,19 +194,17 @@ or are automatically applied via regex from your webpack configuration.
184194
[stylus-npm]: https://img.shields.io/npm/v/stylus-loader.svg
185195
[postcss-npm]: https://img.shields.io/npm/v/postcss-loader.svg
186196

187-
#### Linting && Testing
197+
#### Linting & Testing
188198

189199
|Name|Status|Description|
190200
|:--:|:----:|:----------|
191201
|<a href="https://github.com/webpack/mocha-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/mocha.svg"></a>|![mocha-npm]|Tests with mocha (Browser/NodeJS)|
192202
|<a href="https://github.com/MoOx/eslint-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/eslint.svg"></a>|![eslint-npm]|PreLoader for linting code using ESLint|
193-
|<a href="https://github.com/webpack/jslint-loader"><img width="48" height="48" src="http://jshint.com/res/jshint-dark.png"></a>|![jshint-npm]|PreLoader for linting code using JSHint|
194-
|<a href="https://github.com/unindented/jscs-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/jscs.svg"></a>|![jscs-npm]|PreLoader for code style checking using JSCS|
195-
203+
|<a href="https://github.com/webpack-contrib/jshint-loader"><img width="48" height="20.64" src="http://jshint.com/res/jshint-dark.png"></a>|![jshint-npm]|PreLoader for linting code using JSHint|
196204

197205
[mocha-npm]: https://img.shields.io/npm/v/mocha-loader.svg
198206
[eslint-npm]: https://img.shields.io/npm/v/eslint-loader.svg
199-
[jshint-npm]: https://img.shields.io/npm/v/jslint-loader.svg
207+
[jshint-npm]: https://img.shields.io/npm/v/jshint-loader.svg
200208
[jscs-npm]: https://img.shields.io/npm/v/jscs-loader.svg
201209

202210
#### Frameworks
@@ -241,20 +249,44 @@ friendly** by using hashes.
241249

242250
<h2 align="center">Contributing</h2>
243251

244-
Most of the time, if webpack is not working correctly for you it is a simple configuration issue.
252+
**We want contributing to webpack to be fun, enjoyable, and educational for anyone, and everyone.** We have a [vibrant ecosystem](https://medium.com/webpack/contributors-guide/home) that spans beyond this single repo. We welcome you to check out any of the repositories in [our organization](http://github.com/webpack) or [webpack-contrib organization](http://github.com/webpack-contrib) which houses all of our loaders and plugins.
245253

246-
If you are still having difficulty after looking over your configuration carefully, please post
247-
a question to [StackOverflow with the webpack tag](https://stackoverflow.com/tags/webpack). Questions
248-
that include your webpack.config.js and relevant files are more likely to receive responses.
254+
Contributions go far beyond pull requests and commits. Although we love giving you the opportunity to put your stamp on webpack, we also are thrilled to receive a variety of other contributions including:
249255

250-
If you have discovered a bug or have a feature suggestion, feel free to create an issue on Github.
256+
* [Documentation](https://github.com/webpack/webpack.js.org) updates, enhancements, designs, or bugfixes
257+
* Spelling or grammar fixes
258+
* README.md corrections or redesigns
259+
* Adding unit, or functional tests
260+
* Triaging GitHub issues -- especially determining whether an issue still persists or is reproducible.
261+
* [Searching #webpack on twitter](https://twitter.com/search?q=webpack) and helping someone else who needs help
262+
* Teaching others how to contribute to one of the many webpack repo's!
263+
* [Blogging, speaking about, or creating tutorials](https://github.com/webpack-contrib/awesome-webpack) about one of webpack's many features.
264+
* Helping others in our webpack [gitter channel](https://gitter.im/webpack/webpack).
251265

252-
If you create a loader or plugin, please consider open sourcing it, putting it
253-
on npm and following the `x-loader`, `x-webpack-plugin` convention.
266+
If you are worried or don't know where to start, you can **always** reach out to [Sean Larkin (@TheLarkInn) on Twitter](https://twitter.com/thelarkinn) or simply submit an issue and a maintainer can help give you guidance!
254267

255-
You are also welcome to correct any spelling mistakes or any language issues.
268+
We have also started a series on our [Medium Publication](https://medium.com/webpack) called [The Contributor's Guide to webpack](https://medium.com/webpack/contributors-guide/home). We welcome you to read it and post any questions or responses if you still need help.
256269

257-
If you want to discuss something or just need help, [here is our Gitter room](https://gitter.im/webpack/webpack).
270+
_Looking to speak about webpack?_ We'd **love** to review your talk abstract/CFP! You can email it to webpack [at] opencollective [dot] com and we can give pointers or tips!!!
271+
272+
<h3 align="center">Creating your own plugins and loaders</h3>
273+
274+
If you create a loader or plugin, we would <3 for you to open source it, and put it on npm. We follow the `x-loader`, `x-webpack-plugin` naming convention.
275+
276+
<h2 align="center">Support</h2>
277+
278+
We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of it's flexibility, webpack isn't always the _easiest_ entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!
279+
280+
If you're just getting started, take a look at [our new docs and concepts page](https://webpack.js.org/concepts/). This has a high level overview that is great for beginners!!
281+
282+
If you want to discuss something or just need help, [here is our Gitter room](https://gitter.im/webpack/webpack) where there are always individuals looking to help out!
283+
284+
If you are still having difficulty, we would love for you to post
285+
a question to [StackOverflow with the webpack tag](https://stackoverflow.com/tags/webpack). It is much easier to answer questions that include your webpack.config.js and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!)
286+
287+
If you are twitter savvy you can tweet #webpack with your question and someone should be able to reach out and help also.
288+
289+
If you have discovered a 🐜 or have a feature suggestion, feel free to create an issue on Github.
258290

259291
### License
260292

@@ -293,7 +325,7 @@ If you want to discuss something or just need help, [here is our Gitter room](ht
293325
<img width="150" height="150" src="https://github.com/bebraw.png?s=150">
294326
<br>
295327
<a href="https://github.com/bebraw">Juho Vepsäläinen</a>
296-
<p>Documentation<p>
328+
<p>Documentation</p>
297329
<br>
298330
<p>Author</p>
299331
<a href="https://leanpub.com/survivejs-webpack">
@@ -333,23 +365,33 @@ This is how we use the donations:
333365

334366
<h2 align="center">Premium Partners</h2>
335367

368+
<div align="center">
369+
336370
<a href="https://www.ag-grid.com/?utm_source=webpack&utm_medium=banner&utm_campaign=sponsorship" target="_blank"><img align="center" src="https://raw.githubusercontent.com/webpack/media/2b399d58/horiz-banner-ad-ag-grid.png">
337371
</a>
338372

373+
</div>
374+
339375
<h2 align="center">Other Backers and Sponsors</h2>
340376

341377
Before we started using OpenCollective, donations were made anonymously. Now that we have made the switch, we would like to acknowledge these sponsors (and the ones who continue to donate using OpenCollective). If we've missed someone, please send us a PR, and we'll add you to this list.
342378

379+
<div align="center">
380+
343381
[Google Angular Team](https://angular.io/), [Architects.io](http://architects.io/),
344382
<a href="https://moonmail.io" target="_blank" title="Email Marketing Software"><img
345383
src="https://static.moonmail.io/moonmail-logo.svg" height="30" alt="MoonMail"></a>
346384
<a href="https://monei.net" target="_blank" title="Best payment gateway rates"><img
347385
src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"></a>
348386

387+
</div>
388+
349389
<h2 align="center">Sponsors</h2>
350390

351391
[Become a sponsor](https://opencollective.com/webpack#sponsor) and get your logo on our README on Github with a link to your site.
352392

393+
<div align="center">
394+
353395
<a href="https://opencollective.com/webpack/sponsor/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/0/avatar.svg?requireActive=false"></a>
354396
<a href="https://opencollective.com/webpack/sponsor/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/1/avatar.svg?requireActive=false"></a>
355397
<a href="https://opencollective.com/webpack/sponsor/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/2/avatar.svg?requireActive=false"></a>
@@ -381,6 +423,8 @@ src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"></a>
381423
<a href="https://opencollective.com/webpack/sponsor/28/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/28/avatar.svg?requireActive=false"></a>
382424
<a href="https://opencollective.com/webpack/sponsor/29/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/29/avatar.svg?requireActive=false"></a>
383425

426+
</div>
427+
384428
<h2 align="center">Backers</h2>
385429

386430
[Become a backer](https://opencollective.com/webpack#backer) and get your image on our README on Github with a link to your site.
@@ -490,7 +534,7 @@ src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"></a>
490534
<h2 align="center">Thanks to</h2>
491535
<p align="center">(In chronological order)</p>
492536

493-
* @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.
537+
* @google for [Google Web Toolkit (GWT)](http://www.gwtproject.org/), which aims to compile Java to JavaScript. It features a similar [Code Splitting](http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html) as webpack.
494538
* @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-webmake. Interestingly the [Code Splitting issue is still open](https://github.com/medikoo/modules-webmake/issues/7) (thanks also to @Phoscur for the discussion).
495539
* @substack for [browserify](http://browserify.org/), which is a similar project and source for many ideas.
496540
* @jrburke for [require.js](http://requirejs.org/), which is a similar project and source for many ideas.

benchmark/createBenchmark.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const webpack = require("webpack");
2+
const path = require("path");
3+
4+
webpack({
5+
context: __dirname,
6+
entry: "./createBenchmark/entry.js",
7+
output: {
8+
path: __dirname,
9+
filename: "benchmark-bundle.js"
10+
},
11+
target: "node",
12+
node: {
13+
__dirname: false
14+
},
15+
plugins: [
16+
new webpack.NamedModulesPlugin(),
17+
new webpack.IgnorePlugin(/^(fsevents|uglify-js)$/),
18+
new webpack.NormalModuleReplacementPlugin(/^.\/loadLoader$/, path.resolve(__dirname, "./createBenchmark/loadLoader"))
19+
]
20+
}, function(err, stats) {
21+
console.log(stats.toString());
22+
});

benchmark/createBenchmark/entry.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const webpack = require("webpack");
2+
const MemoryFs = require("memory-fs");
3+
const path = require("path");
4+
5+
const testCase = process.argv[2];
6+
7+
const config = {
8+
context: __dirname,
9+
entry: `./${testCase}`,
10+
output: {
11+
path: path.resolve(__dirname, "output-" + testCase)
12+
},
13+
devtool: process.argv[3]
14+
};
15+
16+
const compiler = webpack(config);
17+
compiler.run((err, stats) => {
18+
if(err) {
19+
console.error(err);
20+
} else {
21+
console.log(stats.toString({
22+
errorDetails: true
23+
}));
24+
}
25+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = (loader, callback) => {
2+
callback(new Error("Loaders are not supported"));
3+
}

benchmark/createTestCases.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
let avgJs = `
2+
const str = "we" + "do" + "some" + "ops";
3+
for(const x of str.split("")) {
4+
if(x.charCodeAt(0) > 40) {
5+
console.log("omg");
6+
} else {
7+
console.log(Math.random() * 2 + 3 * 2);
8+
}
9+
}
10+
11+
// Some comment
12+
switch(a.b.c.d.f.e.g.h.i) {
13+
case true:
14+
break;
15+
case "magic":
16+
throw new Error("Error!");
17+
case 9:
18+
(function() {
19+
// extra scope
20+
var x = 123;
21+
var y = 456;
22+
var z = x + z * x / y;
23+
x && y && (z = x ? y : x);
24+
}())
25+
}
26+
27+
function a() {}
28+
function b() {}
29+
function c() {}
30+
function d() {}
31+
function e() {}
32+
function f() {}
33+
`
34+
35+
for(var i = 0; i < 2; i++) {
36+
avgJs += `(function() {${avgJs}}());`;
37+
}
38+
39+
const fs = require("fs");
40+
const root = __dirname;
41+
42+
createTree(fs, 100, `${root}/modules-100`);
43+
createTree(fs, 500, `${root}/modules-500`);
44+
createTree(fs, 1000, `${root}/modules-1000`);
45+
createTree(fs, 3000, `${root}/modules-3000`);
46+
createTree(fs, 5000, `${root}/modules-5000`);
47+
48+
function createTree(fs, count, folder) {
49+
fs.mkdirSync(folder);
50+
let remaining = count - 1;
51+
52+
function make(prefix, count, depth) {
53+
if(count === 0) {
54+
fs.writeFileSync(`${folder}/${prefix}.js`, `export default 1;\n${avgJs}`);
55+
} else {
56+
const list = [];
57+
for(let i = 0; i < count; i++) {
58+
if(remaining-- <= 0) break;
59+
if(depth <= 4 && i >= 3 && i <= 4) {
60+
list.push(`const module${i} = import("./${prefix}-${i}");\ncounter += module${i};`);
61+
} else {
62+
list.push(`import module${i} from "./${prefix}-${i}";\ncounter += module${i};`);
63+
}
64+
make(`${prefix}-${i}`, depth > 4 || count > 30 ? 0 : count + depth + i ** 2, depth + 1);
65+
}
66+
fs.writeFileSync(`${folder}/${prefix}.js`, `let counter = 0;\n${list.join("\n")};\nexport default counter;\n${avgJs}`)
67+
}
68+
}
69+
make("index", 2, 0);
70+
}

bin/config-optimist.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = function(optimist) {
22
optimist
33
.boolean("help").alias("help", "h").alias("help", "?").describe("help")
44
.string("config").describe("config", "Path to the config file")
5+
.string("config-name").describe("config-name", "Name of the config to use")
56
.string("env").describe("env", "Environment passed to the config, when it is a function")
67
.string("context").describe("context", "The root directory for resolving entry point and stats")
78
.string("entry").describe("entry", "The entry point")

0 commit comments

Comments
 (0)