Skip to content

Commit

Permalink
Merge branch 'master' into use-set-in-chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra authored Jul 18, 2017
2 parents 4c18dbf + a014332 commit f6a0d51
Show file tree
Hide file tree
Showing 77 changed files with 1,507 additions and 1,509 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ within webpack itself use this plugin interface. This makes webpack very
|:--:|:----:|:----------|
|[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)|
|[extract-text-webpack-plugin][extract]|![extract-npm]|Extracts Text (CSS) from your bundles into a separate file (app.bundle.css)|
|[component-webpack-plugin][component]|![component-npm]|Use components with webpack|
|[compression-webpack-plugin][compression]|![compression-npm]|Prepare compressed versions of assets to serve them with Content-Encoding|
|[i18n-webpack-plugin][i18n]|![i18n-npm]|Adds i18n support to your bundles|
|[html-webpack-plugin][html-plugin]|![html-plugin-npm]| Simplifies creation of HTML files (`index.html`) to serve your bundles|
Expand Down Expand Up @@ -191,8 +190,6 @@ or are automatically applied via regex from your webpack configuration.
|<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)|
|<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|
|<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|
|<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|


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

<h3 align="center">Creating your own plugins and loaders</h3>

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.

<h2 align="center">Support</h2>
Expand Down
2 changes: 1 addition & 1 deletion bin/config-yargs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var OPTIMIZE_GROUP = "Optimizing options:";
module.exports = function(yargs) {
yargs
.help("help")
.alias("help", "h", "?")
.alias("help", "h")
.version()
.alias("version", "v")
.options({
Expand Down
9 changes: 2 additions & 7 deletions bin/convert-argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var path = require("path");
var fs = require("fs");
fs.existsSync = fs.existsSync || path.existsSync;
var interpret = require("interpret");
var prepareOptions = require("../lib/prepareOptions");

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

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

var requireConfig = function requireConfig(configPath) {
var options = require(configPath);
var isES6DefaultExportedFunc = (
typeof options === "object" && options !== null && typeof options.default === "function"
);
if(typeof options === "function" || isES6DefaultExportedFunc) {
options = isES6DefaultExportedFunc ? options.default : options;
options = options(argv.env, argv);
}
options = prepareOptions(options, argv);
return options;
};

Expand Down
9 changes: 8 additions & 1 deletion hot/log-apply-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ module.exports = function(updatedModules, renewedModules) {
} else {
log("info", "[HMR] Updated modules:");
renewedModules.forEach(function(moduleId) {
log("info", "[HMR] - " + moduleId);
if(typeof moduleId === "string" && moduleId.indexOf("!") !== -1) {
var parts = moduleId.split("!");
log.groupCollapsed("info", "[HMR] - " + parts.pop());
log("info", "[HMR] - " + moduleId);
log.groupEnd("info");
} else {
log("info", "[HMR] - " + moduleId);
}
});
var numberIds = renewedModules.every(function(moduleId) {
return typeof moduleId === "number";
Expand Down
42 changes: 36 additions & 6 deletions hot/log.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
var logLevel = "info";

function dummy() {}

function shouldLog(level) {
var shouldLog = (logLevel === "info" && level === "info") ||
(["info", "warning"].indexOf(logLevel) >= 0 && level === "warning") ||
(["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error");
return shouldLog;
}

function logGroup(logFn) {
return function(level, msg) {
if(shouldLog(level)) {
logFn(msg);
}
};
}

module.exports = function(level, msg) {
if(logLevel === "info" && level === "info")
return console.log(msg);
if(["info", "warning"].indexOf(logLevel) >= 0 && level === "warning")
return console.warn(msg);
if(["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error")
return console.error(msg);
if(shouldLog(level)) {
if(level === "info") {
console.log(msg);
} else if(level === "warning") {
console.warn(msg);
} else if(level === "error") {
console.error(msg);
}
}
};

var group = console.group || dummy;
var groupCollapsed = console.groupCollapsed || dummy;
var groupEnd = console.groupEnd || dummy;

module.exports.group = logGroup(group);

module.exports.groupCollapsed = logGroup(groupCollapsed);

module.exports.groupEnd = logGroup(groupEnd);

module.exports.setLogLevel = function(level) {
logLevel = level;
};
2 changes: 1 addition & 1 deletion lib/AmdMainTemplatePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AmdMainTemplatePlugin {
const mainTemplate = compilation.mainTemplate;

compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
const externals = chunk.modules.filter((m) => m.external);
const externals = chunk.getModules().filter((m) => m.external);
const externalsDepsArray = JSON.stringify(externals.map((m) =>
typeof m.request === "object" ? m.request.amd : m.request
));
Expand Down
6 changes: 5 additions & 1 deletion lib/Chunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,12 @@ class Chunk {
};
}

sortModules(sortByFn) {
this._modules.sortWith(sortByFn || sortById);
}

sortItems() {
this._modules.sortWith(sortById);
this.sortModules();
this.origins.sort((a, b) => {
const aIdent = a.module.identifier();
const bIdent = b.module.identifier();
Expand Down
1 change: 1 addition & 0 deletions lib/Compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class Compilation extends Tapable {
this.children = [];
this.dependencyFactories = new Map();
this.dependencyTemplates = new Map();
this.dependencyTemplates.set("hash", "");
this.childrenCounters = {};
}

Expand Down
Loading

0 comments on commit f6a0d51

Please sign in to comment.