add includeRegenerator option

This commit is contained in:
Sebastian McKenzie 2015-01-12 20:03:02 +11:00
parent f97bd584f7
commit 49cdacbcb4
3 changed files with 37 additions and 28 deletions

View File

@ -25,6 +25,7 @@ commander.option("-I, --indent [width]", "Indent width [2]", 2);
commander.option("-a, --amd-module-ids", "Insert module id in AMD modules", false); // todo: remove in 3.0.0 commander.option("-a, --amd-module-ids", "Insert module id in AMD modules", false); // todo: remove in 3.0.0
commander.option("-m, --module-ids", "Insert module id in modules", false); commander.option("-m, --module-ids", "Insert module id in modules", false);
commander.option("-R, --react-compat", "Makes the react transformer produce pre-v0.12 code"); commander.option("-R, --react-compat", "Makes the react transformer produce pre-v0.12 code");
commander.option("-E, --include-regenerator", "Include the regenerator runtime if necessary", false);
commander.on("--help", function(){ commander.on("--help", function(){
var outKeys = function (title, obj) { var outKeys = function (title, obj) {
@ -100,18 +101,19 @@ if (errors.length) {
// //
exports.opts = { exports.opts = {
sourceMapName: commander.outFile, includeRegenerator: commander.includeRegenerator,
experimental: commander.experimental, sourceMapName: commander.outFile,
playground: commander.playground, experimental: commander.experimental,
moduleIds: commander.amdModuleIds || commander.moduleIds, reactCompat: commander.reactCompat,
blacklist: commander.blacklist, playground: commander.playground,
whitelist: commander.whitelist, moduleIds: commander.amdModuleIds || commander.moduleIds,
sourceMap: commander.sourceMaps || commander.sourceMapsInline, blacklist: commander.blacklist,
optional: commander.optional, whitelist: commander.whitelist,
comments: !commander.removeComments, sourceMap: commander.sourceMaps || commander.sourceMapsInline,
runtime: commander.runtime, optional: commander.optional,
modules: commander.modules, comments: !commander.removeComments,
reactCompat: commander.reactCompat, runtime: commander.runtime,
modules: commander.modules,
format: { format: {
indent: { indent: {
style: util.repeat(parseInt(commander.indent)) style: util.repeat(parseInt(commander.indent))

View File

@ -48,21 +48,22 @@ File.normaliseOptions = function (opts) {
opts = _.cloneDeep(opts || {}); opts = _.cloneDeep(opts || {});
_.defaults(opts, { _.defaults(opts, {
experimental: false, includeRegenerator: false,
reactCompat: false, experimental: false,
playground: false, reactCompat: false,
whitespace: true, playground: false,
moduleIds: opts.amdModuleIds || false, whitespace: true,
blacklist: [], moduleIds: opts.amdModuleIds || false,
whitelist: [], blacklist: [],
sourceMap: false, whitelist: [],
optional: [], sourceMap: false,
comments: true, optional: [],
filename: "unknown", comments: true,
modules: "common", filename: "unknown",
runtime: false, modules: "common",
code: true, runtime: false,
ast: true code: true,
ast: true
}); });
// normalise windows path separators to unix // normalise windows path separators to unix

View File

@ -1,3 +1,9 @@
var regenerator = require("regenerator");
exports.ast = { exports.ast = {
before: require("regenerator").transform before: function (ast, file) {
regenerator.transform(ast, {
includeRuntime: file.opts.includeRegenerator && "if used"
});
}
}; };