mirror of https://github.com/webpack/webpack.git
Merge branch 'webpack-1'
Conflicts: bin/config-optimist.js bin/convert-argv.js package.json test/browsertest/library2config.coffee
This commit is contained in:
commit
ff16bf4561
|
@ -1,7 +1,7 @@
|
|||
module.exports = function(optimist) {
|
||||
optimist
|
||||
.boolean("help").alias("help", "h").alias("help", "?").describe("help")
|
||||
.string("config").alias("config", "c").describe("config")
|
||||
.string("config").describe("config")
|
||||
.string("env").describe("env", "Enviroment passed to the config, when it is a function")
|
||||
.string("context").describe("context")
|
||||
.string("entry").describe("entry")
|
||||
|
@ -27,7 +27,7 @@ module.exports = function(optimist) {
|
|||
.boolean("watch-stdin").alias("watch-stdin", "stdin").describe("watch which closes when stdin ends")
|
||||
.describe("watch-aggregate-timeout")
|
||||
.describe("watch-poll")
|
||||
.boolean("hot").alias("hot", "h").describe("hot")
|
||||
.boolean("hot").describe("hot")
|
||||
.boolean("debug").describe("debug")
|
||||
.string("devtool").describe("devtool")
|
||||
.boolean("progress").describe("progress")
|
||||
|
|
|
@ -11,7 +11,7 @@ module.exports = function(optimist, argv, convertOptions) {
|
|||
// Help
|
||||
if(argv.help) {
|
||||
optimist.showHelp();
|
||||
process.exit(-1);
|
||||
process.exit(-1); // eslint-disable-line
|
||||
}
|
||||
|
||||
// Shortcuts
|
||||
|
@ -85,9 +85,22 @@ module.exports = function(optimist, argv, convertOptions) {
|
|||
options = options(argv.env, argv);
|
||||
}
|
||||
|
||||
return processConfiguredOptions(options);
|
||||
|
||||
function processConfiguredOptions(options) {
|
||||
if(typeof options !== "object" || options === null) {
|
||||
console.log("Config did not export an object or a function returning an object.");
|
||||
process.exit(-1);
|
||||
process.exit(-1); // eslint-disable-line
|
||||
}
|
||||
|
||||
// process Promise
|
||||
if(typeof options.then === "function") {
|
||||
return options.then(processConfiguredOptions);
|
||||
}
|
||||
|
||||
// process ES6 default
|
||||
if(typeof options === "object" && typeof options["default"] === "object") {
|
||||
return processConfiguredOptions(options["default"]);
|
||||
}
|
||||
|
||||
if(Array.isArray(options)) {
|
||||
|
@ -143,6 +156,9 @@ module.exports = function(optimist, argv, convertOptions) {
|
|||
options.watch = true;
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
function processOptions(options) {
|
||||
function ifArg(name, fn, init, finalize) {
|
||||
if(Array.isArray(argv[name])) {
|
||||
|
@ -214,7 +230,7 @@ module.exports = function(optimist, argv, convertOptions) {
|
|||
}
|
||||
} catch(e) {
|
||||
console.log("Invalid plugin arguments " + name + " (" + e + ").");
|
||||
process.exit(-1);
|
||||
process.exit(-1); // eslint-disable-line
|
||||
}
|
||||
|
||||
var path;
|
||||
|
@ -222,7 +238,7 @@ module.exports = function(optimist, argv, convertOptions) {
|
|||
path = resolve.sync(process.cwd(), name);
|
||||
} catch(e) {
|
||||
console.log("Cannot resolve plugin " + name + ".");
|
||||
process.exit(-1);
|
||||
process.exit(-1); // eslint-disable-line
|
||||
}
|
||||
var Plugin;
|
||||
try {
|
||||
|
@ -514,7 +530,7 @@ module.exports = function(optimist, argv, convertOptions) {
|
|||
} else {
|
||||
optimist.showHelp();
|
||||
console.error("Output filename not configured.");
|
||||
process.exit(-1);
|
||||
process.exit(-1); // eslint-disable-line
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -551,8 +567,5 @@ module.exports = function(optimist, argv, convertOptions) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return options;
|
||||
};
|
||||
|
|
|
@ -48,6 +48,16 @@ function ifArg(name, fn, init) {
|
|||
}
|
||||
}
|
||||
|
||||
function processOptions(options) {
|
||||
// process Promise
|
||||
if(typeof options.then === "function") {
|
||||
options.then(processOptions).catch(function(err) {
|
||||
console.error(err.stack || err);
|
||||
process.exit(); // eslint-disable-line
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var firstOptions = Array.isArray(options) ? options[0] : options;
|
||||
|
||||
var outputOptions = Object.create(options.stats || firstOptions.stats || {});
|
||||
|
@ -152,7 +162,7 @@ function compilerCallback(err, stats) {
|
|||
if(err.details) console.error(err.details);
|
||||
if(!options.watch) {
|
||||
process.on("exit", function() {
|
||||
process.exit(1);
|
||||
process.exit(1); // eslint-disable-line
|
||||
});
|
||||
}
|
||||
return;
|
||||
|
@ -165,7 +175,7 @@ function compilerCallback(err, stats) {
|
|||
}
|
||||
if(!options.doWatch && stats.hasErrors()) {
|
||||
process.on("exit", function() {
|
||||
process.exit(2);
|
||||
process.exit(2); // eslint-disable-line
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -174,10 +184,14 @@ if(options.watch) {
|
|||
var watchOptions = primaryOptions.watchOptions || primaryOptions.watch || {};
|
||||
if(watchOptions.stdin) {
|
||||
process.stdin.on('end', function() {
|
||||
process.exit(0)
|
||||
process.exit(0); // eslint-disable-line
|
||||
});
|
||||
process.stdin.resume();
|
||||
}
|
||||
compiler.watch(watchOptions, compilerCallback);
|
||||
} else
|
||||
compiler.run(compilerCallback);
|
||||
|
||||
}
|
||||
|
||||
processOptions(options);
|
||||
|
|
|
@ -85,6 +85,6 @@
|
|||
"beautify": "node ./scripts/beautify-rewrite",
|
||||
"precover": "npm run lint && npm run beautify-lint",
|
||||
"cover": "istanbul cover -x *.runtime.js node_modules/mocha/bin/_mocha",
|
||||
"publish-patch": "mocha && npm version patch && git push && git push --tags && npm publish"
|
||||
"publish-patch": "npm run lint && npm run beautify-lint && mocha && npm version patch && git push && git push --tags && npm publish"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
webpack = require("../../");
|
||||
module.exports =
|
||||
exports.default = new Promise (resolve, reject) ->
|
||||
resolveIt = ->
|
||||
resolve
|
||||
entry:
|
||||
common: "library2/lib/common"
|
||||
output:
|
||||
|
@ -17,12 +19,14 @@ module.exports =
|
|||
should: require.resolve "should"
|
||||
plugins: [
|
||||
new webpack.optimize.LimitChunkCountPlugin
|
||||
maxChunks: 3
|
||||
new webpack.optimize.CommonsChunkPlugin "common", "library2.commons.js"
|
||||
maxChunks: 2
|
||||
new webpack.optimize.CommonsChunkPlugin
|
||||
name: "common"
|
||||
filename: "library2.commons.js"
|
||||
new webpack.DefinePlugin
|
||||
"typeof CONST_TYPEOF": JSON.stringify("typeof"),
|
||||
CONST_UNDEFINED: undefined,
|
||||
CONST_NULL: null,
|
||||
CONST_NULL: "null",
|
||||
CONST_TRUE: true,
|
||||
CONST_FALSE: false,
|
||||
CONST_FUNCTION: -> return "ok";
|
||||
|
@ -41,3 +45,4 @@ module.exports =
|
|||
data.resource = data.resource.replace /extra\.js/, "extra2.js";
|
||||
callback null, data;
|
||||
]
|
||||
setTimeout resolveIt, 300
|
||||
|
|
Loading…
Reference in New Issue