Skip to content

Commit f6a0d51

Browse files
authored
Merge branch 'master' into use-set-in-chunks
2 parents 4c18dbf + a014332 commit f6a0d51

77 files changed

Lines changed: 1507 additions & 1509 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.

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ within webpack itself use this plugin interface. This makes webpack very
6969
|:--:|:----:|:----------|
7070
|[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)|
7171
|[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|
7372
|[compression-webpack-plugin][compression]|![compression-npm]|Prepare compressed versions of assets to serve them with Content-Encoding|
7473
|[i18n-webpack-plugin][i18n]|![i18n-npm]|Adds i18n support to your bundles|
7574
|[html-webpack-plugin][html-plugin]|![html-plugin-npm]| Simplifies creation of HTML files (`index.html`) to serve your bundles|
@@ -191,8 +190,6 @@ or are automatically applied via regex from your webpack configuration.
191190
|<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)|
192191
|<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|
193192
|<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-
196193

197194
[mocha-npm]: https://img.shields.io/npm/v/mocha-loader.svg
198195
[eslint-npm]: https://img.shields.io/npm/v/eslint-loader.svg
@@ -262,6 +259,7 @@ We have also started a series on our [Medium Publication](https://medium.com/web
262259
_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!!!
263260

264261
<h3 align="center">Creating your own plugins and loaders</h3>
262+
265263
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.
266264

267265
<h2 align="center">Support</h2>

bin/config-yargs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var OPTIMIZE_GROUP = "Optimizing options:";
99
module.exports = function(yargs) {
1010
yargs
1111
.help("help")
12-
.alias("help", "h", "?")
12+
.alias("help", "h")
1313
.version()
1414
.alias("version", "v")
1515
.options({

bin/convert-argv.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var path = require("path");
22
var fs = require("fs");
33
fs.existsSync = fs.existsSync || path.existsSync;
44
var interpret = require("interpret");
5+
var prepareOptions = require("../lib/prepareOptions");
56

67
module.exports = function(yargs, argv, convertOptions) {
78

@@ -94,13 +95,7 @@ module.exports = function(yargs, argv, convertOptions) {
9495

9596
var requireConfig = function requireConfig(configPath) {
9697
var options = require(configPath);
97-
var isES6DefaultExportedFunc = (
98-
typeof options === "object" && options !== null && typeof options.default === "function"
99-
);
100-
if(typeof options === "function" || isES6DefaultExportedFunc) {
101-
options = isES6DefaultExportedFunc ? options.default : options;
102-
options = options(argv.env, argv);
103-
}
98+
options = prepareOptions(options, argv);
10499
return options;
105100
};
106101

hot/log-apply-result.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ module.exports = function(updatedModules, renewedModules) {
2020
} else {
2121
log("info", "[HMR] Updated modules:");
2222
renewedModules.forEach(function(moduleId) {
23-
log("info", "[HMR] - " + moduleId);
23+
if(typeof moduleId === "string" && moduleId.indexOf("!") !== -1) {
24+
var parts = moduleId.split("!");
25+
log.groupCollapsed("info", "[HMR] - " + parts.pop());
26+
log("info", "[HMR] - " + moduleId);
27+
log.groupEnd("info");
28+
} else {
29+
log("info", "[HMR] - " + moduleId);
30+
}
2431
});
2532
var numberIds = renewedModules.every(function(moduleId) {
2633
return typeof moduleId === "number";

hot/log.js

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
11
var logLevel = "info";
22

3+
function dummy() {}
4+
5+
function shouldLog(level) {
6+
var shouldLog = (logLevel === "info" && level === "info") ||
7+
(["info", "warning"].indexOf(logLevel) >= 0 && level === "warning") ||
8+
(["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error");
9+
return shouldLog;
10+
}
11+
12+
function logGroup(logFn) {
13+
return function(level, msg) {
14+
if(shouldLog(level)) {
15+
logFn(msg);
16+
}
17+
};
18+
}
19+
320
module.exports = function(level, msg) {
4-
if(logLevel === "info" && level === "info")
5-
return console.log(msg);
6-
if(["info", "warning"].indexOf(logLevel) >= 0 && level === "warning")
7-
return console.warn(msg);
8-
if(["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error")
9-
return console.error(msg);
21+
if(shouldLog(level)) {
22+
if(level === "info") {
23+
console.log(msg);
24+
} else if(level === "warning") {
25+
console.warn(msg);
26+
} else if(level === "error") {
27+
console.error(msg);
28+
}
29+
}
1030
};
1131

32+
var group = console.group || dummy;
33+
var groupCollapsed = console.groupCollapsed || dummy;
34+
var groupEnd = console.groupEnd || dummy;
35+
36+
module.exports.group = logGroup(group);
37+
38+
module.exports.groupCollapsed = logGroup(groupCollapsed);
39+
40+
module.exports.groupEnd = logGroup(groupEnd);
41+
1242
module.exports.setLogLevel = function(level) {
1343
logLevel = level;
1444
};

lib/AmdMainTemplatePlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AmdMainTemplatePlugin {
1717
const mainTemplate = compilation.mainTemplate;
1818

1919
compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
20-
const externals = chunk.modules.filter((m) => m.external);
20+
const externals = chunk.getModules().filter((m) => m.external);
2121
const externalsDepsArray = JSON.stringify(externals.map((m) =>
2222
typeof m.request === "object" ? m.request.amd : m.request
2323
));

lib/Chunk.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,12 @@ class Chunk {
425425
};
426426
}
427427

428+
sortModules(sortByFn) {
429+
this._modules.sortWith(sortByFn || sortById);
430+
}
431+
428432
sortItems() {
429-
this._modules.sortWith(sortById);
433+
this.sortModules();
430434
this.origins.sort((a, b) => {
431435
const aIdent = a.module.identifier();
432436
const bIdent = b.module.identifier();

lib/Compilation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class Compilation extends Tapable {
8080
this.children = [];
8181
this.dependencyFactories = new Map();
8282
this.dependencyTemplates = new Map();
83+
this.dependencyTemplates.set("hash", "");
8384
this.childrenCounters = {};
8485
}
8586

0 commit comments

Comments
 (0)