put experimental ES7 features behind a flag --experimental and experimental option
This commit is contained in:
@@ -25,15 +25,16 @@ File.normaliseOptions = function (opts) {
|
||||
opts = _.cloneDeep(opts || {});
|
||||
|
||||
_.defaults(opts, {
|
||||
whitespace: true,
|
||||
blacklist: [],
|
||||
whitelist: [],
|
||||
sourceMap: false,
|
||||
comments: true,
|
||||
filename: "unknown",
|
||||
modules: "common",
|
||||
runtime: false,
|
||||
code: true
|
||||
experimental: false,
|
||||
whitespace: true,
|
||||
blacklist: [],
|
||||
whitelist: [],
|
||||
sourceMap: false,
|
||||
comments: true,
|
||||
filename: "unknown",
|
||||
modules: "common",
|
||||
runtime: false,
|
||||
code: true
|
||||
});
|
||||
|
||||
// normalise windows path separators to unix
|
||||
|
||||
@@ -57,24 +57,25 @@ blacklistTest("unicodeRegex", function () { new RegExp("foo", "u"); });
|
||||
|
||||
//
|
||||
|
||||
var ignoreRegex = /node_modules/;
|
||||
var transformOpts = {};
|
||||
var ignoreRegex = /node_modules/;
|
||||
var onlyRegex;
|
||||
var whitelist = [];
|
||||
var exts = {};
|
||||
var maps = {};
|
||||
var old = require.extensions[".js"];
|
||||
var whitelist = [];
|
||||
var exts = {};
|
||||
var maps = {};
|
||||
var old = require.extensions[".js"];
|
||||
|
||||
var loader = function (m, filename) {
|
||||
if ((ignoreRegex && ignoreRegex.test(filename)) || (onlyRegex && !onlyRegex.test(filename))) {
|
||||
return old.apply(this, arguments);
|
||||
}
|
||||
|
||||
var result = to5.transformFileSync(filename, {
|
||||
var result = to5.transformFileSync(filename, _.extend({
|
||||
whitelist: whitelist,
|
||||
blacklist: blacklist,
|
||||
sourceMap: true,
|
||||
modules: "commonInterop"
|
||||
});
|
||||
}, transformOpts));
|
||||
|
||||
maps[filename] = result.map;
|
||||
|
||||
@@ -107,6 +108,5 @@ module.exports = function (opts) {
|
||||
|
||||
if (opts.extensions) hookExtensions(util.arrayify(opts.extensions));
|
||||
|
||||
if (opts.blacklist) blacklist = util.arrayify(opts.blacklist);
|
||||
if (opts.whitelist) whitelist = util.arrayify(opts.whitelist);
|
||||
_.extend(transformOpts, opts);
|
||||
};
|
||||
|
||||
@@ -218,7 +218,7 @@ exports.parse = function (opts, code, callback) {
|
||||
var ast = acorn.parse(code, {
|
||||
allowReturnOutsideFunction: true,
|
||||
preserveParens: true,
|
||||
ecmaVersion: Infinity,
|
||||
ecmaVersion: opts.experimental ? 7 : 6,
|
||||
strictMode: true,
|
||||
onComment: comments,
|
||||
locations: true,
|
||||
|
||||
Reference in New Issue
Block a user