Skip to content

Commit

Permalink
run prettier on existing code
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Feb 25, 2018
1 parent 518d1e0 commit 5238159
Show file tree
Hide file tree
Showing 399 changed files with 18,970 additions and 12,632 deletions.
8 changes: 5 additions & 3 deletions bin/webpack.js
Expand Up @@ -4,15 +4,17 @@ let webpackCliInstalled = false;
try {
require.resolve("webpack-cli");
webpackCliInstalled = true;
} catch(e) {
} catch (e) {
webpackCliInstalled = false;
}

if(webpackCliInstalled) {
if (webpackCliInstalled) {
require("webpack-cli"); // eslint-disable-line node/no-missing-require, node/no-extraneous-require, node/no-unpublished-require
} else {
console.error("The CLI moved into a separate package: webpack-cli.");
console.error("Please install 'webpack-cli' in addition to webpack itself to use the CLI.");
console.error(
"Please install 'webpack-cli' in addition to webpack itself to use the CLI."
);
console.error("-> When using npm: npm install webpack-cli -D");
console.error("-> When using yarn: yarn add webpack-cli -D");
process.exitCode = 1;
Expand Down
7 changes: 3 additions & 4 deletions buildin/global.js
Expand Up @@ -7,11 +7,10 @@ g = (function() {

try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1,eval)("this");
} catch(e) {
g = g || Function("return this")() || (1, eval)("this");
} catch (e) {
// This works if the window reference is available
if(typeof window === "object")
g = window;
if (typeof window === "object") g = window;
}

// g can still be undefined, but nothing to do about it...
Expand Down
6 changes: 3 additions & 3 deletions buildin/harmony-module.js
@@ -1,8 +1,8 @@
module.exports = function(originalModule) {
if(!originalModule.webpackPolyfill) {
if (!originalModule.webpackPolyfill) {
var module = Object.create(originalModule);
// module.parent = undefined by default
if(!module.children) module.children = [];
if (!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
Expand All @@ -16,7 +16,7 @@ module.exports = function(originalModule) {
}
});
Object.defineProperty(module, "exports", {
enumerable: true,
enumerable: true
});
module.webpackPolyfill = 1;
}
Expand Down
4 changes: 2 additions & 2 deletions buildin/module.js
@@ -1,9 +1,9 @@
module.exports = function(module) {
if(!module.webpackPolyfill) {
if (!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
if(!module.children) module.children = [];
if (!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
Expand Down
10 changes: 6 additions & 4 deletions examples/coffee-script/webpack.config.js
@@ -1,10 +1,12 @@
module.exports = {
// mode: "development || "production",
module: {
rules: [{
test: /\.coffee$/,
loader: "coffee-loader"
}]
rules: [
{
test: /\.coffee$/,
loader: "coffee-loader"
}
]
},
resolve: {
extensions: [".web.coffee", ".web.js", ".coffee", ".js"]
Expand Down
8 changes: 4 additions & 4 deletions examples/dll-app-and-vendor/0-vendor/webpack.config.js
Expand Up @@ -8,12 +8,12 @@ module.exports = {
output: {
filename: "vendor.js", // best use [hash] here too
path: path.resolve(__dirname, "dist"),
library: "vendor_lib_[hash]",
library: "vendor_lib_[hash]"
},
plugins: [
new webpack.DllPlugin({
name: "vendor_lib_[hash]",
path: path.resolve(__dirname, "dist/vendor-manifest.json"),
}),
],
path: path.resolve(__dirname, "dist/vendor-manifest.json")
})
]
};
8 changes: 4 additions & 4 deletions examples/dll-app-and-vendor/1-app/webpack.config.js
Expand Up @@ -7,12 +7,12 @@ module.exports = {
entry: "./example-app",
output: {
filename: "app.js",
path: path.resolve(__dirname, "dist"),
path: path.resolve(__dirname, "dist")
},
plugins: [
new webpack.DllReferencePlugin({
context: ".",
manifest: require("../0-vendor/dist/vendor-manifest.json"), // eslint-disable-line
}),
],
manifest: require("../0-vendor/dist/vendor-manifest.json") // eslint-disable-line
})
]
};
2 changes: 0 additions & 2 deletions examples/explicit-vendor-chunk/webpack.config.js
@@ -1,7 +1,6 @@
var path = require("path");
var webpack = require("../../");
module.exports = [

{
name: "vendor",
// mode: "development || "production",
Expand Down Expand Up @@ -38,5 +37,4 @@ module.exports = [
})
]
}

];
2 changes: 1 addition & 1 deletion examples/externals/webpack.config.js
Expand Up @@ -6,7 +6,7 @@ module.exports = {
externals: [
"add",
{
"subtract": {
subtract: {
root: "subtract",
commonjs2: "./subtract",
commonjs: ["./math", "subtract"],
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid-routing/webpack.config.js
Expand Up @@ -5,7 +5,7 @@ module.exports = {
// The entry points for the pages
// They also contains router
pageA: ["./aEntry", "./router"],
pageB: ["./bEntry", "./router"],
pageB: ["./bEntry", "./router"]
},
output: {
path: path.join(__dirname, "dist"),
Expand Down
10 changes: 3 additions & 7 deletions examples/i18n/webpack.config.js
@@ -1,8 +1,8 @@
var path = require("path");
var I18nPlugin = require("i18n-webpack-plugin");
var languages = {
"en": null,
"de": require("./de.json")
en: null,
de: require("./de.json")
};
module.exports = Object.keys(languages).map(function(language) {
return {
Expand All @@ -13,10 +13,6 @@ module.exports = Object.keys(languages).map(function(language) {
path: path.join(__dirname, "dist"),
filename: language + ".output.js"
},
plugins: [
new I18nPlugin(
languages[language]
)
]
plugins: [new I18nPlugin(languages[language])]
};
});
10 changes: 6 additions & 4 deletions examples/loader/webpack.config.js
@@ -1,9 +1,11 @@
module.exports = {
// mode: "development || "production",
module: {
rules: [{
test: /\.css$/,
loader: "css-loader"
}]
rules: [
{
test: /\.css$/,
loader: "css-loader"
}
]
}
};
2 changes: 0 additions & 2 deletions examples/multi-compiler/webpack.config.js
@@ -1,7 +1,6 @@
var path = require("path");
var webpack = require("../../");
module.exports = [

{
name: "mobile",
// mode: "development || "production",
Expand Down Expand Up @@ -31,5 +30,4 @@ module.exports = [
})
]
}

];
6 changes: 3 additions & 3 deletions examples/source-map/webpack.config.js
Expand Up @@ -10,15 +10,15 @@ module.exports = [
"hidden-source-map",
"inline-source-map",
"nosources-source-map",
"source-map",
"source-map"
].map(devtool => ({
mode: "development",
entry: {
bundle: "coffee-loader!./example.coffee",
bundle: "coffee-loader!./example.coffee"
},
output: {
path: path.join(__dirname, "dist"),
filename: `./[name]-${devtool}.js`,
filename: `./[name]-${devtool}.js`
},
devtool,
optimization: {
Expand Down
10 changes: 6 additions & 4 deletions examples/wasm-simple/webpack.config.js
Expand Up @@ -5,10 +5,12 @@ module.exports = {
publicPath: "js/"
},
module: {
rules: [{
test: /\.wasm$/,
type: "webassembly/experimental"
}]
rules: [
{
test: /\.wasm$/,
type: "webassembly/experimental"
}
]
},
optimization: {
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
Expand Down
1 change: 0 additions & 1 deletion hot/.eslintrc
Expand Up @@ -5,5 +5,4 @@
"rules": {
"node/exports-style": ["off"]
}

}
62 changes: 35 additions & 27 deletions hot/dev-server.js
Expand Up @@ -3,46 +3,54 @@
Author Tobias Koppers @sokra
*/
/*globals window __webpack_hash__ */
if(module.hot) {
if (module.hot) {
var lastHash;
var upToDate = function upToDate() {
return lastHash.indexOf(__webpack_hash__) >= 0;
};
var log = require("./log");
var check = function check() {
module.hot.check(true).then(function(updatedModules) {
if(!updatedModules) {
log("warning", "[HMR] Cannot find update. Need to do a full reload!");
log("warning", "[HMR] (Probably because of restarting the webpack-dev-server)");
window.location.reload();
return;
}
module.hot
.check(true)
.then(function(updatedModules) {
if (!updatedModules) {
log("warning", "[HMR] Cannot find update. Need to do a full reload!");
log(
"warning",
"[HMR] (Probably because of restarting the webpack-dev-server)"
);
window.location.reload();
return;
}

if(!upToDate()) {
check();
}
if (!upToDate()) {
check();
}

require("./log-apply-result")(updatedModules, updatedModules);
require("./log-apply-result")(updatedModules, updatedModules);

if(upToDate()) {
log("info", "[HMR] App is up to date.");
}

}).catch(function(err) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
log("warning", "[HMR] Cannot apply update. Need to do a full reload!");
log("warning", "[HMR] " + err.stack || err.message);
window.location.reload();
} else {
log("warning", "[HMR] Update failed: " + err.stack || err.message);
}
});
if (upToDate()) {
log("info", "[HMR] App is up to date.");
}
})
.catch(function(err) {
var status = module.hot.status();
if (["abort", "fail"].indexOf(status) >= 0) {
log(
"warning",
"[HMR] Cannot apply update. Need to do a full reload!"
);
log("warning", "[HMR] " + err.stack || err.message);
window.location.reload();
} else {
log("warning", "[HMR] Update failed: " + err.stack || err.message);
}
});
};
var hotEmitter = require("./emitter");
hotEmitter.on("webpackHotUpdate", function(currentHash) {
lastHash = currentHash;
if(!upToDate() && module.hot.status() === "idle") {
if (!upToDate() && module.hot.status() === "idle") {
log("info", "[HMR] Checking for updates on the server...");
check();
}
Expand Down
18 changes: 12 additions & 6 deletions hot/log-apply-result.js
Expand Up @@ -8,19 +8,22 @@ module.exports = function(updatedModules, renewedModules) {
});
var log = require("./log");

if(unacceptedModules.length > 0) {
log("warning", "[HMR] The following modules couldn't be hot updated: (They would need a full reload!)");
if (unacceptedModules.length > 0) {
log(
"warning",
"[HMR] The following modules couldn't be hot updated: (They would need a full reload!)"
);
unacceptedModules.forEach(function(moduleId) {
log("warning", "[HMR] - " + moduleId);
});
}

if(!renewedModules || renewedModules.length === 0) {
if (!renewedModules || renewedModules.length === 0) {
log("info", "[HMR] Nothing hot updated.");
} else {
log("info", "[HMR] Updated modules:");
renewedModules.forEach(function(moduleId) {
if(typeof moduleId === "string" && moduleId.indexOf("!") !== -1) {
if (typeof moduleId === "string" && moduleId.indexOf("!") !== -1) {
var parts = moduleId.split("!");
log.groupCollapsed("info", "[HMR] - " + parts.pop());
log("info", "[HMR] - " + moduleId);
Expand All @@ -32,7 +35,10 @@ module.exports = function(updatedModules, renewedModules) {
var numberIds = renewedModules.every(function(moduleId) {
return typeof moduleId === "number";
});
if(numberIds)
log("info", "[HMR] Consider using the NamedModulesPlugin for module names.");
if (numberIds)
log(
"info",
"[HMR] Consider using the NamedModulesPlugin for module names."
);
}
};

0 comments on commit 5238159

Please sign in to comment.