Socket
Socket
Sign inDemoInstall

babel-core

Package Overview
Dependencies
67
Maintainers
1
Versions
257
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.7.16 to 5.0.0-beta2

lib/acorn/AUTHORS

6

bin/babel/dir.js

@@ -9,6 +9,2 @@ var outputFileSync = require("output-file-sync");

module.exports = function (commander, filenames, opts) {
if (commander.sourceMapsInline) {
opts.sourceMap = "inline";
}
var write = function (src, relative) {

@@ -24,3 +20,3 @@ // remove extension and then append back on .js

if (commander.sourceMaps) {
if (commander.sourceMaps && commander.sourceMaps !== "inline") {
var mapLoc = dest + ".map";

@@ -27,0 +23,0 @@ data.code = util.addSourceMappingUrl(data.code, mapLoc);

@@ -9,3 +9,7 @@ var convertSourceMap = require("convert-source-map");

module.exports = function (commander, filenames) {
module.exports = function (commander, filenames, opts) {
if (commander.sourceMaps === "inline") {
opts.sourceMaps = true;
}
var results = [];

@@ -45,3 +49,3 @@

if (commander.sourceMapsInline || (!commander.outFile && commander.sourceMaps)) {
if (commander.sourceMaps === "inline" || (!commander.outFile && commander.sourceMaps)) {
code += "\n" + convertSourceMap.fromObject(map).toComment();

@@ -60,3 +64,3 @@ }

if (commander.outFile) {
if (commander.sourceMaps) {
if (commander.sourceMaps && commander.sourceMaps !== "inline") {
var mapLoc = commander.outFile + ".map";

@@ -63,0 +67,0 @@ result.code = util.addSourceMappingUrl(result.code, mapLoc);

@@ -5,28 +5,34 @@ #!/usr/bin/env node

var transform = require("../../lib/babel/transformation");
var kebabCase = require("lodash/string/kebabCase");
var File = require("../../lib/babel/transformation/file");
var util = require("../../lib/babel/util");
var fs = require("fs");
var each = require("lodash/collection/each");
var keys = require("lodash/object/keys");
var fs = require("fs");
commander.option("-t, --source-maps-inline", "Append sourceMappingURL comment to bottom of code");
commander.option("-s, --source-maps", "Save source map alongside the compiled code");
commander.option("-f, --filename [filename]", "Filename to use when reading from stdin - this will be used in source-maps, errors etc [stdin]", "stdin");
each(File.options, function (option, key) {
if (option.hidden) return;
var arg = kebabCase(key);
if (option.type !== "boolean") {
arg += " [" + (option.type || "string") + "]";
}
if (option.type === "boolean" && option.default === true) {
arg = "no-" + key;
}
arg = "--" + arg;
if (option.shorthand) {
arg = "-" + option.shorthand + ", " + arg;
}
commander.option(arg, option.description);
})
commander.option("-w, --watch", "Recompile files on changes");
commander.option("-r, --external-helpers", "Replace helpers with references to a `babelHelpers` global");
commander.option("-e, --experimental", "Enable experimental support for proposed ES7 features");
commander.option("-p, --playground", "Enable playground support");
commander.option("-c, --compact [mode]", "When set to \"auto\" compact is `true` when the input size exceeds 100KB. (auto|true|false)", "auto");
commander.option("-m, --modules [modules]", "Module formatter type to use [common]", "common");
commander.option("-l, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list);
commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list);
commander.option("-i, --optional [list]", "List of optional transformers to enable", util.list);
commander.option("-L, --loose [list]", "List of transformers to enable loose mode ON", util.list);
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
commander.option("-c, --remove-comments", "Remove comments from the compiled code", 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("--keep-module-id-extensions", "Keep extensions when generating module ids", false);
commander.option("-a, --auxiliary-comment [comment]", "Comment text to prepend to all auxiliary code");
commander.option("-D, --copy-files", "When compiling a directory copy over non-compilable files");

@@ -42,5 +48,3 @@

if (obj[key].optional) {
key = "[" + key + "]";
}
if (obj[key].optional) key = "[" + key + "]";

@@ -92,8 +96,2 @@ console.log(" - " + key);

if (commander.sourceMaps) {
if (!commander.outFile && !commander.outDir) {
errors.push("--source-maps requires --out-file or --out-dir");
}
}
if (errors.length) {

@@ -106,21 +104,8 @@ console.error(errors.join(". "));

exports.opts = {
keepModuleIdExtensions: commander.keepModuleIdExtensions,
auxiliaryComment: commander.auxiliaryComment,
externalHelpers: commander.externalHelpers,
sourceMapName: commander.outFile,
experimental: commander.experimental,
reactCompat: commander.reactCompat,
playground: commander.playground,
moduleIds: commander.moduleIds,
blacklist: commander.blacklist,
whitelist: commander.whitelist,
sourceMap: commander.sourceMaps || commander.sourceMapsInline,
optional: commander.optional,
comments: !commander.removeComments,
modules: commander.modules,
compact: commander.compact,
loose: commander.loose
};
exports.opts = {};
each(File.options, function (opt, key) {
exports.opts[key] = commander[key];
});
var fn;

@@ -127,0 +112,0 @@

@@ -1,9 +0,8 @@

var resolveRc = require("../../lib/babel/api/register/resolve-rc");
var readdir = require("fs-readdir-recursive");
var index = require("./index");
var babel = require("../../lib/babel/api/node");
var util = require("../../lib/babel/util");
var path = require("path");
var fs = require("fs");
var _ = require("lodash");
var readdir = require("fs-readdir-recursive");
var index = require("./index");
var babel = require("../../lib/babel/api/node");
var util = require("../../lib/babel/util");
var path = require("path");
var fs = require("fs");
var _ = require("lodash");

@@ -27,3 +26,2 @@ exports.readdirFilter = function (filename) {

opts.filename = filename;
resolveRc(filename, opts);

@@ -30,0 +28,0 @@ var result = babel.transform(code, opts);

@@ -35,3 +35,3 @@ # Contributing

This will usually take around two minutes as it's compiling the entire
[test262](https://github.com/tc39/test262) test suite and validating it's AST.
[test262](https://github.com/tc39/test262) test suite and validating its AST.
This is mostly overkill and you can limit the tests to a select few by directly

@@ -44,2 +44,8 @@ running them with `mocha`:

Use mocha's `--grep` option to run a subset of tests by name:
```sh
$ mocha test/transformation.js --grep es7
```
#### Workflow

@@ -46,0 +52,0 @@

@@ -1,1 +0,1 @@

(function(global){var babelHelpers=global.babelHelpers={};babelHelpers.inherits=function(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)subClass.__proto__=superClass};babelHelpers.defaults=function(obj,defaults){var keys=Object.getOwnPropertyNames(defaults);for(var i=0;i<keys.length;i++){var key=keys[i];var value=Object.getOwnPropertyDescriptor(defaults,key);if(value&&value.configurable&&obj[key]===undefined){Object.defineProperty(obj,key,value)}}return obj};babelHelpers.createClass=function(){function defineProperties(target,props){for(var key in props){var prop=props[key];prop.configurable=true;if(prop.value)prop.writable=true}Object.defineProperties(target,props)}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();babelHelpers.createComputedClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var prop=props[i];prop.configurable=true;if(prop.value)prop.writable=true;Object.defineProperty(target,prop.key,prop)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();babelHelpers.applyConstructor=function(Constructor,args){var instance=Object.create(Constructor.prototype);var result=Constructor.apply(instance,args);return result!=null&&(typeof result=="object"||typeof result=="function")?result:instance};babelHelpers.taggedTemplateLiteral=function(strings,raw){return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}))};babelHelpers.taggedTemplateLiteralLoose=function(strings,raw){strings.raw=raw;return strings};babelHelpers.interopRequire=function(obj){return obj&&obj.__esModule?obj["default"]:obj};babelHelpers.toArray=function(arr){return Array.isArray(arr)?arr:Array.from(arr)};babelHelpers.toConsumableArray=function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}else{return Array.from(arr)}};babelHelpers.slicedToArray=function(arr,i){if(Array.isArray(arr)){return arr}else if(Symbol.iterator in Object(arr)){var _arr=[];for(var _iterator=arr[Symbol.iterator](),_step;!(_step=_iterator.next()).done;){_arr.push(_step.value);if(i&&_arr.length===i)break}return _arr}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}};babelHelpers.objectWithoutProperties=function(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target};babelHelpers.hasOwn=Object.prototype.hasOwnProperty;babelHelpers.slice=Array.prototype.slice;babelHelpers.bind=Function.prototype.bind;babelHelpers.defineProperty=function(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})};babelHelpers.asyncToGenerator=function(fn){return function(){var gen=fn.apply(this,arguments);return new Promise(function(resolve,reject){var callNext=step.bind(null,"next");var callThrow=step.bind(null,"throw");function step(key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(callNext,callThrow)}}callNext()})}};babelHelpers.interopRequireWildcard=function(obj){return obj&&obj.__esModule?obj:{"default":obj}};babelHelpers._typeof=function(obj){return obj&&obj.constructor===Symbol?"symbol":typeof obj};babelHelpers._extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};babelHelpers.get=function get(object,property,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent===null){return undefined}else{return get(parent,property,receiver)}}else if("value"in desc&&desc.writable){return desc.value}else{var getter=desc.get;if(getter===undefined){return undefined}return getter.call(receiver)}};babelHelpers.set=function set(object,property,value,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent!==null){return set(parent,property,value,receiver)}}else if("value"in desc&&desc.writable){return desc.value=value}else{var setter=desc.set;if(setter!==undefined){return setter.call(receiver,value)}}};babelHelpers.classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};babelHelpers.objectDestructuringEmpty=function(obj){if(obj==null)throw new TypeError("Cannot destructure undefined")};babelHelpers.temporalUndefined={};babelHelpers.temporalAssertDefined=function(val,name,undef){if(val===undef){throw new ReferenceError(name+" is not defined - temporal dead zone")}return true};babelHelpers.selfGlobal=typeof global==="undefined"?self:global})(typeof global==="undefined"?self:global);
(function(global){var babelHelpers=global.babelHelpers={};babelHelpers.inherits=function(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)subClass.__proto__=superClass};babelHelpers.defaults=function(obj,defaults){var keys=Object.getOwnPropertyNames(defaults);for(var i=0;i<keys.length;i++){var key=keys[i];var value=Object.getOwnPropertyDescriptor(defaults,key);if(value&&value.configurable&&obj[key]===undefined){Object.defineProperty(obj,key,value)}}return obj};babelHelpers.createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if(descriptor.value)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();babelHelpers.createDecoratedClass=function(){function defineProperties(target,descriptors,initializers){for(var i=0;i<descriptors.length;i++){var descriptor=descriptors[i];var decorators=descriptor.decorators;var key=descriptor.key;delete descriptor.key;delete descriptor.decorators;descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor||descriptor.initializer)descriptor.writable=true;if(decorators){for(var f=0;f<decorators.length;f++){var decorator=decorators[f];if(typeof decorator==="function"){descriptor=decorator(target,key,descriptor)||descriptor}else{throw new TypeError("The decorator for method "+descriptor.key+" is of the invalid type "+typeof decorator)}}initializers[key]=descriptor.initializer}Object.defineProperty(target,key,descriptor)}}return function(Constructor,protoProps,staticProps,protoInitializers,staticInitializers){if(protoProps)defineProperties(Constructor.prototype,protoProps,protoInitializers);if(staticProps)defineProperties(Constructor,staticProps,staticInitializers);return Constructor}}();babelHelpers.taggedTemplateLiteral=function(strings,raw){return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}))};babelHelpers.taggedTemplateLiteralLoose=function(strings,raw){strings.raw=raw;return strings};babelHelpers.interopRequire=function(obj){return obj&&obj.__esModule?obj["default"]:obj};babelHelpers.toArray=function(arr){return Array.isArray(arr)?arr:Array.from(arr)};babelHelpers.toConsumableArray=function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}else{return Array.from(arr)}};babelHelpers.slicedToArray=function(arr,i){if(Array.isArray(arr)){return arr}else if(Symbol.iterator in Object(arr)){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"])_i["return"]()}finally{if(_d)throw _e}}return _arr}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}};babelHelpers.slicedToArrayLoose=function(arr,i){if(Array.isArray(arr)){return arr}else if(Symbol.iterator in Object(arr)){var _arr=[];for(var _iterator=arr[Symbol.iterator](),_step;!(_step=_iterator.next()).done;){_arr.push(_step.value);if(i&&_arr.length===i)break}return _arr}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}};babelHelpers.objectWithoutProperties=function(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target};babelHelpers.hasOwn=Object.prototype.hasOwnProperty;babelHelpers.slice=Array.prototype.slice;babelHelpers.bind=Function.prototype.bind;babelHelpers.defineProperty=function(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:key==null||typeof Symbol=="undefined"||key.constructor!==Symbol,configurable:true,writable:true})};babelHelpers.asyncToGenerator=function(fn){return function(){var gen=fn.apply(this,arguments);return new Promise(function(resolve,reject){var callNext=step.bind(null,"next");var callThrow=step.bind(null,"throw");function step(key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(callNext,callThrow)}}callNext()})}};babelHelpers.interopRequireWildcard=function(obj){return obj&&obj.__esModule?obj:{"default":obj}};babelHelpers._typeof=function(obj){return obj&&obj.constructor===Symbol?"symbol":typeof obj};babelHelpers._extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};babelHelpers.get=function get(object,property,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent===null){return undefined}else{return get(parent,property,receiver)}}else if("value"in desc&&desc.writable){return desc.value}else{var getter=desc.get;if(getter===undefined){return undefined}return getter.call(receiver)}};babelHelpers.set=function set(object,property,value,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent!==null){return set(parent,property,value,receiver)}}else if("value"in desc&&desc.writable){return desc.value=value}else{var setter=desc.set;if(setter!==undefined){return setter.call(receiver,value)}}};babelHelpers.classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};babelHelpers.objectDestructuringEmpty=function(obj){if(obj==null)throw new TypeError("Cannot destructure undefined")};babelHelpers.temporalUndefined={};babelHelpers.temporalAssertDefined=function(val,name,undef){if(val===undef){throw new ReferenceError(name+" is not defined - temporal dead zone")}return true};babelHelpers.selfGlobal=typeof global==="undefined"?self:global})(typeof global==="undefined"?self:global);

@@ -12,3 +12,3 @@ "use strict";

opts.sourceMap = "inline";
opts.sourceMaps = "inline";
return new Function(transform(code, opts).code)();

@@ -15,0 +15,0 @@ };

@@ -19,4 +19,6 @@ "use strict";

var fs = _interopRequire(require("fs"));
var _acorn = require("../../acorn");
var acorn = _interopRequireWildcard(_acorn);
var _util = require("../util");

@@ -26,5 +28,8 @@

exports._util = util;
var fs = _interopRequire(require("fs"));
exports.util = util;
exports.canCompile = _util.canCompile;
exports.acorn = _interopRequire(require("acorn-babel"));
exports.acorn = _acorn.acorn;
exports.Transformer = _interopRequire(require("../transformation/transformer"));
exports.transform = _interopRequire(_transformation);

@@ -31,0 +36,0 @@ exports.traverse = _interopRequire(require("../traversal"));

@@ -27,21 +27,4 @@ "use strict";

process.on("exit", save);
process.nextTick(save);
var sigint = (function (_sigint) {
var _sigintWrapper = function sigint() {
return _sigint.apply(this, arguments);
};
_sigintWrapper.toString = function () {
return _sigint.toString();
};
return _sigintWrapper;
})(function () {
process.removeListener("SIGINT", sigint);
save();
process.kill(process.pid, "SIGINT");
});
process.on("SIGINT", sigint);
if (!fs.existsSync(FILENAME)) return;

@@ -48,0 +31,0 @@

@@ -13,3 +13,3 @@ "use strict";

var resolveRc = _interopRequire(require("./resolve-rc"));
var resolveRc = _interopRequire(require("../../tools/resolve-rc"));

@@ -62,2 +62,5 @@ var extend = _interopRequire(require("lodash/object/extend"));

var opts = extend({}, transformOpts);
// this will be done when the file is transformed anyway but we need all
// the options so we can generate the cache key
resolveRc(filename, opts);

@@ -64,0 +67,0 @@

@@ -9,2 +9,6 @@ "use strict";

function ClassDeclaration(node, print) {
if (node.decorators && node.decorators.length) {
print.list(node.decorators);
}
this.push("class");

@@ -52,2 +56,6 @@

function MethodDefinition(node, print) {
if (node.decorators && node.decorators.length) {
print.list(node.decorators);
}
if (node["static"]) {

@@ -54,0 +62,0 @@ this.push("static ");

@@ -8,2 +8,3 @@ "use strict";

exports.UnaryExpression = UnaryExpression;
exports.DoExpression = DoExpression;
exports.UpdateExpression = UpdateExpression;

@@ -14,2 +15,4 @@ exports.ConditionalExpression = ConditionalExpression;

exports.ThisExpression = ThisExpression;
exports.Super = Super;
exports.Decorator = Decorator;
exports.CallExpression = CallExpression;

@@ -45,2 +48,8 @@ exports.EmptyStatement = EmptyStatement;

function DoExpression(node, print) {
this.push("do");
this.space();
print(node.body);
}
function UpdateExpression(node, print) {

@@ -84,2 +93,11 @@ if (node.prefix) {

function Super() {
this.push("super");
}
function Decorator(node, print) {
this.push("@");
print(node.expression);
}
function CallExpression(node, print) {

@@ -181,2 +199,4 @@ print(node.callee);

}
}
}
exports.MetaProperty = MemberExpression;

@@ -36,7 +36,9 @@ "use strict";

if (!kind || kind === "init") {
if (kind === "method" || kind === "init") {
if (value.generator) {
this.push("*");
}
} else {
}
if (kind === "get" || kind === "set") {
this.push(kind + " ");

@@ -43,0 +45,0 @@ }

@@ -8,7 +8,9 @@ "use strict";

exports.ImportSpecifier = ImportSpecifier;
exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
exports.ExportSpecifier = ExportSpecifier;
exports.ExportBatchSpecifier = ExportBatchSpecifier;
exports.ExportDeclaration = ExportDeclaration;
exports.ExportAllDeclaration = ExportAllDeclaration;
exports.ExportNamedDeclaration = ExportNamedDeclaration;
exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
exports.ImportDeclaration = ImportDeclaration;
exports.ImportBatchSpecifier = ImportBatchSpecifier;
exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
exports.__esModule = true;

@@ -21,30 +23,40 @@

function ImportSpecifier(node, print) {
if (t.isSpecifierDefault(node)) {
print(t.getSpecifierName(node));
} else {
return ExportSpecifier.apply(this, arguments);
print(node.imported);
if (node.local && node.local !== node.imported) {
this.push(" as ");
print(node.local);
}
}
function ImportDefaultSpecifier(node, print) {
print(node.local);
}
function ExportSpecifier(node, print) {
print(node.id);
if (node.name) {
print(node.local);
if (node.exported && node.local !== node.exported) {
this.push(" as ");
print(node.name);
print(node.exported);
}
}
function ExportBatchSpecifier() {
this.push("*");
function ExportAllDeclaration(node, print) {
this.push("export * from ");
print(node.source);
this.semicolon();
}
function ExportDeclaration(node, print) {
function ExportNamedDeclaration(node, print) {
this.push("export ");
ExportDeclaration.call(this, node, print);
}
function ExportDefaultDeclaration(node, print) {
this.push("export default ");
ExportDeclaration.call(this, node, print);
}
function ExportDeclaration(node, print) {
var specifiers = node.specifiers;
if (node["default"]) {
this.push("default ");
}
if (node.declaration) {

@@ -54,13 +66,9 @@ print(node.declaration);

} else {
if (specifiers.length === 1 && t.isExportBatchSpecifier(specifiers[0])) {
print(specifiers[0]);
} else {
this.push("{");
if (specifiers.length) {
this.space();
print.join(specifiers, { separator: ", " });
this.space();
}
this.push("}");
this.push("{");
if (specifiers.length) {
this.space();
print.join(specifiers, { separator: ", " });
this.space();
}
this.push("}");

@@ -77,4 +85,2 @@ if (node.source) {

function ImportDeclaration(node, print) {
var _this = this;
this.push("import ");

@@ -90,16 +96,16 @@

each(node.specifiers, function (spec, i) {
if (+i > 0) {
_this.push(", ");
for (var i = 0; i < node.specifiers.length; i++) {
var spec = node.specifiers[i];
if (i > 0) {
this.push(", ");
}
var isDefault = t.isSpecifierDefault(spec);
if (!isDefault && spec.type !== "ImportBatchSpecifier" && !foundImportSpecifier) {
if (!t.isImportDefaultSpecifier(spec) && !t.isImportNamespaceSpecifier(spec) && !foundImportSpecifier) {
foundImportSpecifier = true;
_this.push("{ ");
this.push("{ ");
}
print(spec);
});
}

@@ -117,5 +123,5 @@ if (foundImportSpecifier) {

function ImportBatchSpecifier(node, print) {
function ImportNamespaceSpecifier(node, print) {
this.push("* as ");
print(node.name);
print(node.local);
}

@@ -20,3 +20,2 @@ "use strict";

exports.VariableDeclaration = VariableDeclaration;
exports.PrivateDeclaration = PrivateDeclaration;
exports.VariableDeclarator = VariableDeclarator;

@@ -239,8 +238,2 @@ exports.__esModule = true;

function PrivateDeclaration(node, print) {
this.push("private ");
print.join(node.declarations, { separator: ", " });
this.semicolon();
}
function VariableDeclarator(node, print) {

@@ -247,0 +240,0 @@ print(node.id);

@@ -7,3 +7,2 @@ "use strict";

exports.RestElement = RestElement;
exports.VirtualPropertyExpression = VirtualPropertyExpression;
exports.ObjectExpression = ObjectExpression;

@@ -30,8 +29,2 @@ exports.Property = Property;

function VirtualPropertyExpression(node, print) {
print(node.object);
this.push("::");
print(node.property);
}
function ObjectExpression(node, print) {

@@ -38,0 +31,0 @@ var props = node.properties;

@@ -82,3 +82,2 @@ "use strict";

statements: require("./generators/statements"),
playground: require("./generators/playground"),
classes: require("./generators/classes"),

@@ -85,0 +84,0 @@ methods: require("./generators/methods"),

@@ -20,3 +20,3 @@ "use strict";

if (opts.sourceMap) {
if (opts.sourceMaps) {
this.map = new sourceMap.SourceMapGenerator({

@@ -23,0 +23,0 @@ file: opts.sourceMapName,

@@ -92,3 +92,3 @@ "use strict";

if (endToken && endToken.type.type === "eof") {
if (endToken && endToken.type.label === "eof") {
return 1;

@@ -95,0 +95,0 @@ } else {

@@ -15,11 +15,8 @@ "use strict";

var ary = _interopRequire(require("lodash/function/ary"));
var defs = {
string: chalk.red,
punctuator: chalk.white.bold,
punctuator: chalk.bold,
curly: chalk.green,
parens: chalk.blue.bold,
square: chalk.yellow,
name: chalk.white,
keyword: chalk.cyan,

@@ -32,46 +29,55 @@ number: chalk.magenta,

var newline = /\r\n|[\n\r\u2028\u2029]/;
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
var highlight = function highlight(text) {
var tokenType = function tokenType(match) {
var token = jsTokens.matchToToken(match);
if (token.type === "name" && esutils.keyword.isReservedWordES6(token.value)) {
return "keyword";
}
function getTokenType(match) {
var token = jsTokens.matchToToken(match);
if (token.type === "name" && esutils.keyword.isReservedWordES6(token.value)) {
return "keyword";
}
if (token.type === "punctuator") {
switch (token.value) {
case "{":
case "}":
return "curly";
case "(":
case ")":
return "parens";
case "[":
case "]":
return "square";
}
if (token.type === "punctuator") {
switch (token.value) {
case "{":
case "}":
return "curly";
case "(":
case ")":
return "parens";
case "[":
case "]":
return "square";
}
}
return token.type;
};
return token.type;
}
return text.replace(jsTokens, function (match) {
var type = tokenType(arguments);
if (type in defs) {
var colorize = ary(defs[type], 1);
return match.split(newline).map(colorize).join("\n");
function highlight(text) {
return text.replace(jsTokens, function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return match;
var type = getTokenType(args);
var colorize = defs[type];
if (colorize) {
return args[0].split(NEWLINE).map(function (str) {
return colorize(str);
}).join("\n");
} else {
return args[0];
}
});
};
}
module.exports = function (lines, lineNumber, colNumber) {
var opts = arguments[3] === undefined ? {} : arguments[3];
colNumber = Math.max(colNumber, 0);
if (chalk.supportsColor) {
if (opts.highlightCode && chalk.supportsColor) {
lines = highlight(lines);
}
lines = lines.split(newline);
lines = lines.split(NEWLINE);

@@ -86,3 +92,3 @@ var start = Math.max(lineNumber - 3, 0);

return "\n" + lineNumbers(lines.slice(start, end), {
return lineNumbers(lines.slice(start, end), {
start: start + 1,

@@ -89,0 +95,0 @@ before: " ",

"use strict";
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };

@@ -11,3 +13,3 @@

var acorn = _interopRequire(require("acorn-babel"));
var acorn = _interopRequireWildcard(require("../../acorn"));

@@ -19,14 +21,21 @@ module.exports = function (opts, code, callback) {

var ast = acorn.parse(code, {
allowImportExportEverywhere: opts.allowImportExportEverywhere,
allowReturnOutsideFunction: !opts._anal,
ecmaVersion: opts.experimental ? 7 : 6,
playground: opts.playground,
var parseOpts = {
allowImportExportEverywhere: opts.looseModules,
allowReturnOutsideFunction: opts.looseModules,
ecmaVersion: 6,
strictMode: opts.strictMode,
sourceType: opts.sourceType,
onComment: comments,
locations: true,
features: opts.features || {},
plugins: opts.plugins || {},
onToken: tokens,
ranges: true
});
};
parseOpts.plugins.jsx = true;
parseOpts.plugins.flow = true;
var ast = acorn.parse(code, parseOpts);
estraverse.attachComments(ast, comments, tokens);

@@ -44,8 +53,9 @@

err._babel = true;
var message = "" + opts.filename + ": " + err.message;
var message = err.message = "" + opts.filename + ": " + err.message;
var loc = err.loc;
if (loc) {
var frame = codeFrame(code, loc.line, loc.column + 1);
message += frame;
err.codeFrame = codeFrame(code, loc.line, loc.column + 1, opts);
message += "\n" + err.codeFrame;
}

@@ -59,4 +69,2 @@

}
err.message = message;
}

@@ -63,0 +71,0 @@

@@ -11,3 +11,3 @@ "use strict";

var messages = {
var MESSAGES = {
tailCallReassignmentDeopt: "Function reference has been reassigned so it's probably be dereferenced so we can't optimise this with confidence",

@@ -36,3 +36,3 @@ JSXNamespacedTags: "Namespace tags are not supported. ReactJSX is not XML.",

exports.messages = messages;
exports.MESSAGES = MESSAGES;

@@ -44,3 +44,3 @@ function get(key) {

var msg = messages[key];
var msg = MESSAGES[key];
if (!msg) throw new ReferenceError("Unknown message " + JSON.stringify(key));

@@ -47,0 +47,0 @@

@@ -28,17 +28,8 @@ "use strict";

// Acorn - Same as ImportNamespaceSpecifier but `id` is `name`
def("ImportBatchSpecifier").bases("Specifier").build("name").field("name", def("Identifier"));
def("RestElement").bases("Pattern").build("argument").field("argument", def("expression"));
// Abstract references
def("VirtualPropertyExpression").bases("Expression").build("object", "property").field("object", def("Expression")).field("property", or(def("Identifier"), def("Expression")));
def("ExportDefaultDeclaration").bases("Declaration").build("declaration").field("declaration", or(def("Declaration"), def("Expression"), null));
def("PrivateDeclaration").bases("Declaration").build("declarations").field("declarations", [def("Identifier")]);
def("ExportNamedDeclaration").bases("Declaration").build("declaration").field("declaration", or(def("Declaration"), def("Expression"), null)).field("specifiers", [or(def("ExportSpecifier"))]).field("source", or(def("ModuleSpecifier"), null));
// Playground
def("BindMemberExpression").bases("Expression").build("object", "property", "arguments").field("object", def("Expression")).field("property", or(def("Identifier"), def("Expression"))).field("arguments", [def("Expression")]);
def("BindFunctionExpression").bases("Expression").build("callee", "arguments").field("callee", def("Expression")).field("arguments", [def("Expression")]);
types.finalize();

@@ -22,3 +22,3 @@ "use strict";

var container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body));
var tree = t.program([t.expressionStatement(t.callExpression(container, [util.template("self-global")]))]);
var tree = t.program([t.expressionStatement(t.callExpression(container, [util.template("helper-self-global")]))]);

@@ -63,3 +63,3 @@ body.push(t.variableDeclaration("var", [t.variableDeclarator(namespace, t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), t.objectExpression([])))]));

var key = t.identifier(t.toIdentifier(name));
body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(namespace, key), util.template(name))));
body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(namespace, key), util.template("helper-" + name))));
});

@@ -66,0 +66,0 @@ }

@@ -12,4 +12,7 @@ "use strict";

var cache = {};
var jsons = {};
function exists(filename) {
if (!fs.existsSync) return false;
var cached = cache[filename];

@@ -33,3 +36,5 @@ if (cached != null) return cached;

try {
json = JSON.parse(content);
var _jsons, _content;
json = (_jsons = jsons, _content = content, !_jsons[_content] && (_jsons[_content] = JSON.parse(content)), _jsons[_content]);
} catch (err) {

@@ -36,0 +41,0 @@ err.message = "" + file + ": " + err.message;

@@ -89,3 +89,3 @@ "use strict";

File.helpers = ["inherits", "defaults", "create-class", "create-computed-class", "apply-constructor", "tagged-template-literal", "tagged-template-literal-loose", "interop-require", "to-array", "to-consumable-array", "sliced-to-array", "object-without-properties", "has-own", "slice", "bind", "define-property", "async-to-generator", "interop-require-wildcard", "typeof", "extends", "get", "set", "class-call-check", "object-destructuring-empty", "temporal-undefined", "temporal-assert-defined", "self-global"];
File.helpers = ["inherits", "defaults", "create-class", "create-decorated-class", "tagged-template-literal", "tagged-template-literal-loose", "interop-require", "to-array", "to-consumable-array", "sliced-to-array", "sliced-to-array-loose", "object-without-properties", "has-own", "slice", "bind", "define-property", "async-to-generator", "interop-require-wildcard", "typeof", "extends", "get", "set", "class-call-check", "object-destructuring-empty", "temporal-undefined", "temporal-assert-defined", "self-global"];
File.options = require("./options");

@@ -113,14 +113,19 @@

var val = opts[key];
if (val == null) val = option["default"] || null;
if (!val && option.optional) continue;
if (val == null) val = option["default"] || val;
var optionParser = optionParsers[option.type];
if (optionParser) {
val = optionParser(key, val);
if (optionParser) val = optionParser(key, val);
if (option.alias) {
var _opts = opts;
var _option$alias = option.alias;
if (!_opts[_option$alias]) _opts[_option$alias] = val;
} else {
opts[key] = val;
}
opts[key] = val;
}
if (opts.inputSourceMap) {
opts.sourceMap = true;
opts.sourceMaps = true;
}

@@ -267,2 +272,18 @@

File.prototype.resolveModuleSource = (function (_resolveModuleSource) {
var _resolveModuleSourceWrapper = function resolveModuleSource(_x) {
return _resolveModuleSource.apply(this, arguments);
};
_resolveModuleSourceWrapper.toString = function () {
return _resolveModuleSource.toString();
};
return _resolveModuleSourceWrapper;
})(function (source) {
var resolveModuleSource = this.opts.resolveModuleSource;
if (resolveModuleSource) source = resolveModuleSource(source, this.opts.filename);
return source;
});
File.prototype.addImport = function addImport(source, name, noDefault) {

@@ -274,2 +295,3 @@ if (!name) name = source;

if (!id) {
source = this.resolveModuleSource(source);
id = this.dynamicImportIds[name] = this.scope.generateUidIdentifier(name);

@@ -332,3 +354,3 @@

} else {
var ref = util.template(name);
var ref = util.template("helper-" + name);
ref._compact = true;

@@ -383,3 +405,3 @@ var uid = this.scope.generateUidIdentifier(name);

File.prototype.parse = (function (_parse) {
var _parseWrapper = function parse(_x) {
var _parseWrapper = function parse(_x2) {
return _parse.apply(this, arguments);

@@ -411,2 +433,3 @@ };

var parseOpts = {
highlightCode: opts.highlightCode,
filename: opts.filename,

@@ -424,2 +447,3 @@ plugins: {}

parseOpts.strictMode = features.strict;
parseOpts.sourceType = "module";

@@ -477,5 +501,4 @@ //

var transformer = stack[i].transformer;
if (transformer[key]) {
transformer[key](this);
}
var fn = transformer[key];
if (fn) fn(this);
}

@@ -485,3 +508,3 @@ };

File.prototype.checkNode = (function (_checkNode) {
var _checkNodeWrapper = function checkNode(_x2, _x3) {
var _checkNodeWrapper = function checkNode(_x3, _x4) {
return _checkNode.apply(this, arguments);

@@ -573,7 +596,7 @@ };

if (opts.sourceMap === "inline" || opts.sourceMap === "both") {
if (opts.sourceMaps === "inline" || opts.sourceMaps === "both") {
result.code += "\n" + convertSourceMap.fromObject(result.map).toComment();
}
if (opts.sourceMap === "inline") {
if (opts.sourceMaps === "inline") {
result.map = null;

@@ -580,0 +603,0 @@ }

@@ -9,2 +9,3 @@ "use strict";

exports.boolean = boolean;
exports.booleanString = booleanString;
exports.list = list;

@@ -28,2 +29,6 @@ exports.__esModule = true;

function boolean(key, val) {
return !!val;
}
function booleanString(key, val) {
return util.booleanify(val);

@@ -30,0 +35,0 @@ }

@@ -22,4 +22,8 @@ {

"highlightErrors": {
"description": "ANSI syntax highlight error messages",
"highlightTheme": {
"hidden": true
},
"highlightCode": {
"description": "ANSI syntax highlight code frames",
"type": "boolean",

@@ -54,2 +58,3 @@ "default": true

"type": "transformerList",
"optional": true,
"description": "Whitelist of transformers to ONLY use",

@@ -139,3 +144,8 @@ "shorthand": "l"

"sourceMap": {
"type": "string",
"alias": "sourceMaps",
"hidden": true
},
"sourceMaps": {
"type": "booleanString",
"default": false,

@@ -142,0 +152,0 @@ "shorthand": "s"

@@ -41,4 +41,3 @@ "use strict";

nodes.push(buildAssignment(exploded.ref, opts.build(exploded.uid, node.right)));
return t.toSequenceExpression(nodes, scope);
return nodes;
};

@@ -45,0 +44,0 @@

@@ -43,4 +43,4 @@ "use strict";

return t.toSequenceExpression(nodes, scope);
return nodes;
};
};

@@ -40,3 +40,3 @@ "use strict";

exports.JSXNamespacedName = function (node, parent, scope, file) {
throw file.errorWithNode(node, messages.get("JSXNamespacedTags"));
throw this.errorWithNode(messages.get("JSXNamespacedTags"));
};

@@ -263,4 +263,4 @@

exports.ExportDeclaration = function (node, parent, scope, file) {
if (node["default"] && react.isCreateClass(node.declaration)) {
exports.ExportDefaultDeclaration = function (node, parent, scope, file) {
if (react.isCreateClass(node.declaration)) {
addDisplayName(file.opts.basename, node.declaration);

@@ -267,0 +267,0 @@ }

@@ -71,3 +71,3 @@ "use strict";

var inheritNode = node;
if (t.isMethodDefinition(node)) node = node.value;
if (t.isMethodDefinition(node) || t.isClassProperty(node)) node = node.value;

@@ -74,0 +74,0 @@ var prop = t.property("init", t.identifier(key), node);

@@ -16,3 +16,3 @@ "use strict";

function isIllegalBareSuper(node, parent) {
if (!isSuper(node, parent)) return false;
if (!t.isSuper(node)) return false;
if (t.isMemberExpression(parent, { computed: false })) return false;

@@ -23,6 +23,2 @@ if (t.isCallExpression(parent, { callee: node })) return false;

function isSuper(node, parent) {
return t.isIdentifier(node, { name: "super" }) && t.isReferenced(node, parent);
}
var visitor = {

@@ -52,3 +48,3 @@ enter: function enter(node, parent, scope, state) {

if (self.isLoose) callback = self.looseHandle;
return callback.call(self, getThisReference, node, parent);
return callback.call(self, this, getThisReference);
}

@@ -182,10 +178,11 @@ };

ReplaceSupers.prototype.looseHandle = function looseHandle(getThisReference, node, parent) {
if (t.isIdentifier(node, { name: "super" })) {
ReplaceSupers.prototype.looseHandle = function looseHandle(path, getThisReference) {
var node = path.node;
if (path.isSuper()) {
this.hasSuper = true;
return this.getLooseSuperProperty(node, parent);
} else if (t.isCallExpression(node)) {
return this.getLooseSuperProperty(node, path.parent);
} else if (path.isCallExpression()) {
var callee = node.callee;
if (!t.isMemberExpression(callee)) return;
if (callee.object.name !== "super") return;
if (!t.isSuper(callee.object)) return;

@@ -203,3 +200,3 @@ // super.test(); -> objectRef.prototype.MethodName.call(this);

ReplaceSupers.prototype.specHandle = function specHandle(getThisReference, node, parent) {
ReplaceSupers.prototype.specHandle = function specHandle(path, getThisReference) {
var methodNode = this.methodNode;

@@ -211,4 +208,7 @@ var property;

var parent = path.parent;
var node = path.node;
if (isIllegalBareSuper(node, parent)) {
throw this.file.errorWithNode(node, messages.get("classesIllegalBareSuper"));
throw path.errorWithNode(messages.get("classesIllegalBareSuper"));
}

@@ -218,3 +218,3 @@

var callee = node.callee;
if (isSuper(callee, node)) {
if (t.isSuper(callee)) {
// super(); -> _get(Object.getPrototypeOf(objectRef), "MethodName", this).call(this);

@@ -232,3 +232,3 @@ property = methodNode.key;

}
} else if (t.isMemberExpression(callee) && isSuper(callee.object, callee)) {
} else if (t.isMemberExpression(callee) && t.isSuper(callee.object)) {
// super.test(); -> _get(Object.getPrototypeOf(objectRef.prototype), "test", this).call(this);

@@ -239,7 +239,7 @@ property = callee.property;

}
} else if (t.isMemberExpression(node) && isSuper(node.object, node)) {
} else if (t.isMemberExpression(node) && t.isSuper(node.object)) {
// super.name; -> _get(Object.getPrototypeOf(objectRef.prototype), "name", this);
property = node.property;
computed = node.computed;
} else if (t.isAssignmentExpression(node) && isSuper(node.left.object, node.left) && methodNode.kind === "set") {
} else if (t.isAssignmentExpression(node) && t.isSuper(node.left.object) && methodNode.kind === "set") {
// super.name = "val"; -> _set(Object.getPrototypeOf(objectRef.prototype), "name", this);

@@ -246,0 +246,0 @@ this.hasSuper = true;

@@ -11,2 +11,4 @@ "use strict";

var traverse = _interopRequire(require("../../traversal"));
var extend = _interopRequire(require("lodash/object/extend"));

@@ -62,3 +64,3 @@

formatter.hasLocalImports = true;
extend(formatter.localImports, t.getBindingIdentifiers(node));
extend(formatter.localImports, this.getBindingIdentifiers());
formatter.bumpImportOccurences(node);

@@ -69,13 +71,13 @@ }

var exportsVisitor = {
var exportsVisitor = traverse.explode({
ExportDeclaration: {
enter: function enter(node, parent, scope, formatter) {
var declar = node.declaration;
formatter.hasLocalImports = true;
if (declar && t.isStatement(declar)) {
extend(formatter.localExports, t.getBindingIdentifiers(declar));
var declar = this.get("declaration");
if (declar.isStatement()) {
extend(formatter.localExports, declar.getBindingIdentifiers());
}
if (!node["default"]) {
if (!t.isExportDefaultDeclaration(node)) {
formatter.hasNonDefaultExports = true;

@@ -89,3 +91,3 @@ }

}
};
});

@@ -116,3 +118,3 @@ var DefaultFormatter = (function () {

DefaultFormatter.prototype.doDefaultExportInterop = function doDefaultExportInterop(node) {
return node["default"] && !this.noInteropRequireExport && !this.hasNonDefaultExports;
return t.isExportDefaultDeclaration(node) && !this.noInteropRequireExport && !this.hasNonDefaultExports;
};

@@ -127,11 +129,13 @@

occurs[source] += node.specifiers.length;
if (node.specifiers) {
occurs[source] += node.specifiers.length;
}
};
DefaultFormatter.prototype.getLocalExports = function getLocalExports() {
this.file.scope.traverse(this.file.ast, exportsVisitor, this);
this.file.path.traverse(exportsVisitor, this);
};
DefaultFormatter.prototype.getLocalImports = function getLocalImports() {
this.file.scope.traverse(this.file.ast, importsVisitor, this);
this.file.path.traverse(importsVisitor, this);
};

@@ -141,3 +145,3 @@

if (this.hasLocalImports) {
this.file.scope.traverse(this.file.ast, remapVisitor, this);
this.file.path.traverse(remapVisitor, this);
}

@@ -231,2 +235,7 @@ };

DefaultFormatter.prototype.exportAllDeclaration = function exportAllDeclaration(node, nodes) {
var ref = this.getExternalReference(node, nodes);
nodes.push(this.buildExportsWildcard(ref, node));
};
DefaultFormatter.prototype.exportSpecifier = function exportSpecifier(specifier, node, nodes) {

@@ -236,19 +245,14 @@ if (node.source) {

if (t.isExportBatchSpecifier(specifier)) {
// export * from "foo";
nodes.push(this.buildExportsWildcard(ref, node));
if (specifier.local.name === "default" && !this.noInteropRequireExport) {
// importing a default so we need to normalize it
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
} else {
if (t.isSpecifierDefault(specifier) && !this.noInteropRequireExport) {
// importing a default so we need to normalize it
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
} else {
ref = t.memberExpression(ref, t.getSpecifierId(specifier));
}
ref = t.memberExpression(ref, specifier.local);
}
// export { foo } from "test";
nodes.push(this.buildExportsAssignment(t.getSpecifierName(specifier), ref, node));
}
// export { foo } from "test";
nodes.push(this.buildExportsAssignment(specifier.exported, ref, node));
} else {
// export { foo };
nodes.push(this.buildExportsAssignment(t.getSpecifierName(specifier), specifier.id, node));
nodes.push(this.buildExportsAssignment(specifier.exported, specifier.local, node));
}

@@ -274,3 +278,3 @@ };

if (node["default"]) {
if (t.isExportDefaultDeclaration(node)) {
id = t.identifier("default");

@@ -277,0 +281,0 @@ }

"use strict";
module.exports = require("./_strict")(require("./amd"));
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var AMDFormatter = _interopRequire(require("./amd"));
var buildStrict = _interopRequire(require("./_strict"));
module.exports = buildStrict(AMDFormatter);

@@ -97,3 +97,2 @@ "use strict";

AMDFormatter.prototype.importSpecifier = function importSpecifier(specifier, node, nodes) {
var key = t.getSpecifierName(specifier);
var ref = this.getExternalReference(node);

@@ -104,11 +103,13 @@

this.ids[node.source.value] = ref;
} else if (t.isImportBatchSpecifier(specifier)) {} else if (!includes(this.file.dynamicImported, node) && t.isSpecifierDefault(specifier) && !this.noInteropRequireImport) {
} else if (t.isImportNamespaceSpecifier(specifier)) {} else if (!includes(this.file.dynamicImported, node) && t.isSpecifierDefault(specifier) && !this.noInteropRequireImport) {
// import foo from "foo";
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
} else {
// import {foo} from "foo";
ref = t.memberExpression(ref, t.getSpecifierId(specifier), false);
// import { foo } from "foo";
var imported = specifier.imported;
if (t.isSpecifierDefault(specifier)) imported = t.identifier("default");
ref = t.memberExpression(ref, imported);
}
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(key, ref)]));
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(specifier.local, ref)]));
};

@@ -115,0 +116,0 @@

"use strict";
module.exports = require("./_strict")(require("./common"));
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var CommonFormatter = _interopRequire(require("./common"));
var buildStrict = _interopRequire(require("./_strict"));
module.exports = buildStrict(CommonFormatter);

@@ -44,3 +44,3 @@ "use strict";

CommonJSFormatter.prototype.importSpecifier = function importSpecifier(specifier, node, nodes) {
var variableName = t.getSpecifierName(specifier);
var variableName = specifier.local;

@@ -60,4 +60,3 @@ var ref = this.getExternalReference(node, nodes);

} else {
if (specifier.type === "ImportBatchSpecifier") {
if (t.isImportNamespaceSpecifier(specifier)) {
if (!this.noInteropRequireImport) {

@@ -71,3 +70,3 @@ ref = t.callExpression(this.file.addHelper("interop-require-wildcard"), [ref]);

// import { foo } from "foo";
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(variableName, t.memberExpression(ref, t.getSpecifierId(specifier)))]));
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(variableName, t.memberExpression(ref, specifier.imported))]));
}

@@ -74,0 +73,0 @@ }

@@ -19,2 +19,4 @@ "use strict";

IgnoreFormatter.prototype.exportAllDeclaration = function exportAllDeclaration() {};
IgnoreFormatter.prototype.importDeclaration = function importDeclaration() {};

@@ -21,0 +23,0 @@

@@ -62,3 +62,3 @@ "use strict";

if (parent.init === node) {
return t.toSequenceExpression(nodes, scope);
return nodes;
}

@@ -65,0 +65,0 @@ }

"use strict";
module.exports = require("./_strict")(require("./umd"));
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var UMDFormatter = _interopRequire(require("./umd"));
var buildStrict = _interopRequire(require("./_strict"));
module.exports = buildStrict(UMDFormatter);

@@ -9,2 +9,4 @@ "use strict";

var traverse = _interopRequire(require("../traversal"));
/**

@@ -26,3 +28,3 @@ * This class is responsible for traversing over the provided `File`s

TransformerPass.prototype.canRun = function canRun() {
TransformerPass.prototype.canTransform = function canTransform() {
var transformer = this.transformer;

@@ -42,12 +44,9 @@

var whitelist = opts.whitelist;
if (whitelist.length) return includes(whitelist, key);
if (whitelist) return includes(whitelist, key);
// optional
if (transformer.optional && !includes(opts.optional, key)) return false;
// experimental
if (transformer.experimental && !opts.experimental) return false;
if (transformer.metadata.experimental && opts.experimental) return true;
// playground
if (transformer.playground && !opts.playground) return false;
// optional
if (transformer.metadata.optional && !includes(opts.optional, key)) return false;

@@ -73,3 +72,3 @@ return true;

file.scope.traverse(file.ast, this.handlers, file);
traverse(file.ast, this.handlers, file.scope, file);

@@ -76,0 +75,0 @@ this.ran = true;

"use strict";
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };

@@ -17,2 +19,6 @@

var acorn = _interopRequireWildcard(require("../../acorn"));
var File = _interopRequire(require("./file"));
var each = _interopRequire(require("lodash/collection/each"));

@@ -39,2 +45,4 @@

this.manipulateOptions = take("manipulateOptions");
this.metadata = take("metadata") || {};
this.parser = take("parser");
this.check = take("check");

@@ -44,7 +52,2 @@ this.post = take("post");

this.experimental = !!take("experimental");
this.playground = !!take("playground");
this.secondPass = !!take("secondPass");
this.optional = !!take("optional");
this.handlers = this.normalize(transformer);

@@ -91,2 +94,6 @@

Transformer.prototype.buildPass = function buildPass(file) {
if (!(file instanceof File)) {
throw new Error("Multiple versions of babel are interacting, this is either due to a version mismatch in a plugin or it was resolved incorrectly");
}
return new TransformerPass(file, this);

@@ -93,0 +100,0 @@ };

@@ -17,7 +17,7 @@ "use strict";

node._aliasFunction = "arrow";
node.expression = false;
node.type = "FunctionExpression";
node.shadow = true;
return node;
}

@@ -13,2 +13,3 @@ "use strict";

if (!this.isReferencedIdentifier()) return;
if (t.isFor(parent) && parent.left === node) return;

@@ -27,3 +28,3 @@ var declared = state.letRefs[node.name];

if (parent._ignoreBlockScopingTDZ) return;
this.parentPath.node = t.sequenceExpression([assert, parent]);
this.parentPath.replaceWith(t.sequenceExpression([assert, parent]));
} else {

@@ -35,5 +36,7 @@ return t.logicalExpression("&&", assert, node);

var optional = true;
var metadata = {
optional: true
};
exports.optional = optional;
exports.metadata = metadata;

@@ -44,3 +47,3 @@ function BlockStatement(node, parent, scope, file) {

scope.traverse(node, visitor, {
this.traverse(visitor, {
letRefs: letRefs,

@@ -47,0 +50,0 @@ file: file

@@ -67,3 +67,3 @@ "use strict";

if (isLetInitable(node) && file.transformers["es6.blockScopingTDZ"].canRun()) {
if (isLetInitable(node) && file.transformers["es6.blockScopingTDZ"].canTransform()) {
var nodes = [node];

@@ -135,3 +135,3 @@

if (this.isFunction()) {
scope.traverse(node, letReferenceFunctionVisitor, state);
this.traverse(letReferenceFunctionVisitor, state);
return this.skip();

@@ -198,3 +198,3 @@ }

state.ignoreLabeless = true;
scope.traverse(node, loopVisitor, state);
this.traverse(loopVisitor, state);
state.ignoreLabeless = false;

@@ -381,3 +381,3 @@ }

var fn = t.functionExpression(null, params, t.blockStatement(block.body));
fn._aliasFunction = true;
fn.shadow = true;

@@ -402,3 +402,3 @@ // replace the current block body with the one we're going to build

fn.async = true;
call = t.awaitExpression(call, true);
call = t.awaitExpression(call);
}

@@ -405,0 +405,0 @@

@@ -25,2 +25,6 @@ "use strict";

var each = _interopRequire(require("lodash/collection/each"));
var has = _interopRequire(require("lodash/object/has"));
var t = _interopRequireWildcard(require("../../../types"));

@@ -37,3 +41,3 @@

function ClassExpression(node, parent, scope, file) {
return new ClassTransformer(node, parent, scope, file).run();
return new ClassTransformer(this, file).run();
}

@@ -56,7 +60,8 @@

enter: function enter(node, parent, scope, state) {
if (t.isIdentifier(node.callee, { name: "super" })) {
if (this.get("callee").isSuper()) {
state.hasBareSuper = true;
state.bareSuper = this;
if (!state.hasSuper) {
throw state.file.errorWithNode(node, "super call is only allowed in derived constructor");
throw this.errorWithNode("super call is only allowed in derived constructor");
}

@@ -70,3 +75,3 @@ }

if (state.hasSuper && !state.hasBareSuper) {
throw state.file.errorWithNode(node, "'this' is not allowed before super()");
throw this.errorWithNode("'this' is not allowed before super()");
}

@@ -83,12 +88,13 @@ }

function ClassTransformer(node, parent, scope, file) {
function ClassTransformer(path, file) {
_classCallCheck(this, ClassTransformer);
this.parent = parent;
this.scope = scope;
this.node = node;
this.parent = path.parent;
this.scope = path.scope;
this.node = path.node;
this.path = path;
this.file = file;
this.hasInstanceMutators = false;
this.hasStaticMutators = false;
this.hasInstanceDescriptors = false;
this.hasStaticDescriptors = false;

@@ -98,8 +104,13 @@ this.instanceMutatorMap = {};

this.instancePropBody = [];
this.staticPropBody = [];
this.body = [];
this.hasConstructor = false;
this.className = node.id;
this.classRef = node.id || scope.generateUidIdentifier("class");
this.hasDecorators = false;
this.className = this.node.id;
this.classRef = this.node.id || this.scope.generateUidIdentifier("class");
this.superName = node.superClass || t.identifier("Function");
this.hasSuper = !!node.superClass;
this.superName = this.node.superClass || t.identifier("Function");
this.hasSuper = !!this.node.superClass;

@@ -124,8 +135,7 @@ this.isLoose = file.isLoose("es6.classes");

var body = this.body = [];
var body = this.body;
//
var constructorBody = t.blockStatement([t.expressionStatement(t.callExpression(file.addHelper("class-call-check"), [t.thisExpression(), classRef]))]);
var constructorBody = this.constructorBody = t.blockStatement([]);
var constructor;

@@ -163,2 +173,17 @@

constructorBody.body.unshift(t.expressionStatement(t.callExpression(file.addHelper("class-call-check"), [t.thisExpression(), classRef])));
//
var decorators = this.node.decorators;
if (decorators) {
for (var i = 0; i < decorators.length; i++) {
var decorator = decorators[i];
body.push(util.template("class-decorator", {
DECORATOR: decorator.expression,
CLASS_REF: classRef
}, true));
}
}
if (this.className) {

@@ -176,2 +201,4 @@ // named class with only a constructor

body = body.concat(this.staticPropBody);
//

@@ -188,3 +215,64 @@

ClassTransformer.prototype.pushToMap = function pushToMap(node, enumerable) {
var kind = arguments[2] === undefined ? "value" : arguments[2];
var mutatorMap;
if (node["static"]) {
this.hasStaticDescriptors = true;
mutatorMap = this.staticMutatorMap;
} else {
this.hasInstanceDescriptors = true;
mutatorMap = this.instanceMutatorMap;
}
var alias = t.toKeyAlias(node);
//
var map = {};
if (has(mutatorMap, alias)) map = mutatorMap[alias];
mutatorMap[alias] = map;
//
var _map = map;
if (!_map._inherits) _map._inherits = [];
map._inherits.push(node);
map._key = node.key;
if (enumerable) {
map.enumerable = t.literal(true);
}
if (node.computed) {
map._computed = true;
}
if (node.decorators) {
var _map2;
this.hasDecorators = true;
var decorators = (_map2 = map, !_map2.decorators && (_map2.decorators = t.arrayExpression([])), _map2.decorators);
decorators.elements = decorators.elements.concat(node.decorators.map(function (dec) {
return dec.expression;
}));
}
if (map.value || map.initializer) {
throw this.file.errorWithNode(node, "Key conflict with sibling node");
}
if (node.kind === "get") kind = "get";
if (node.kind === "set") kind = "set";
map[kind] = node.value;
};
/**
* Description
*/
ClassTransformer.prototype.buildBody = function buildBody() {
var constructorBody = this.constructorBody;
var constructor = this.constructor;

@@ -196,7 +284,9 @@ var className = this.className;

var classBodyPaths = this.path.get("body").get("body");
for (var i = 0; i < classBody.length; i++) {
var node = classBody[i];
if (t.isMethodDefinition(node)) {
var isConstructor = !node.computed && t.isIdentifier(node.key, { name: "constructor" }) || t.isLiteral(node.key, { value: "constructor" });
if (isConstructor) this.verifyConstructor(node);
var isConstructor = node.kind === "constructor";
if (isConstructor) this.verifyConstructor(classBodyPaths[i]);

@@ -220,5 +310,2 @@ var replaceSupers = new ReplaceSupers({

}
} else if (t.isPrivateDeclaration(node)) {
this.closure = true;
body.unshift(node);
} else if (t.isClassProperty(node)) {

@@ -229,7 +316,7 @@ this.pushProperty(node);

// we have no constructor, we have a super, and the super doesn't appear to be falsy
if (!this.hasConstructor && this.hasSuper && t.evaluateTruthy(superName, this.scope) !== false) {
// we have no constructor, but we're a derived class
if (!this.hasConstructor && this.hasSuper) {
var helperName = "class-super-constructor-call";
if (this.isLoose) helperName += "-loose";
constructor.body.body.push(util.template(helperName, {
constructorBody.body.push(util.template(helperName, {
CLASS_NAME: className,

@@ -240,11 +327,22 @@ SUPER_NAME: this.superName

//
this.placePropertyInitializers();
//
if (this.userConstructor) {
constructorBody.body = constructorBody.body.concat(this.userConstructor.body.body);
t.inherits(this.constructor, this.userConstructor);
t.inherits(this.constructorBody, this.userConstructor.body);
}
var instanceProps;
var staticProps;
var classHelper = "create-class";
if (this.hasDecorators) classHelper = "create-decorated-class";
if (this.hasInstanceMutators) {
if (this.hasInstanceDescriptors) {
instanceProps = defineMap.toClassObject(this.instanceMutatorMap);
}
if (this.hasStaticMutators) {
if (this.hasStaticDescriptors) {
staticProps = defineMap.toClassObject(this.staticMutatorMap);

@@ -254,12 +352,28 @@ }

if (instanceProps || staticProps) {
if (defineMap.hasComputed(this.instanceMutatorMap) || defineMap.hasComputed(this.staticMutatorMap)) {
if (instanceProps) instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
if (staticProps) staticProps = defineMap.toComputedObjectFromClass(staticProps);
classHelper = "create-computed-class";
if (instanceProps) instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
if (staticProps) staticProps = defineMap.toComputedObjectFromClass(staticProps);
var nullNode = t.literal(null);
// (Constructor, instanceDescriptors, staticDescriptors, instanceInitializers, staticInitializers)
var args = [this.classRef, nullNode, nullNode, nullNode, nullNode];
if (instanceProps) args[1] = instanceProps;
if (staticProps) args[2] = staticProps;
if (this.instanceInitializersId) {
args[3] = this.instanceInitializersId;
body.unshift(this.buildObjectAssignment(this.instanceInitializersId));
}
if (!instanceProps) instanceProps = t.literal(null);
if (this.staticInitializersId) {
args[4] = this.staticInitializersId;
body.unshift(this.buildObjectAssignment(this.staticInitializersId));
}
var args = [this.classRef, instanceProps];
if (staticProps) args.push(staticProps);
var lastNonNullIndex = 0;
for (var i = 0; i < args.length; i++) {
if (args[i] !== nullNode) lastNonNullIndex = i;
}
args = args.slice(0, lastNonNullIndex + 1);

@@ -270,2 +384,6 @@ body.push(t.expressionStatement(t.callExpression(this.file.addHelper(classHelper), args)));

ClassTransformer.prototype.buildObjectAssignment = function buildObjectAssignment(id) {
return t.variableDeclaration("var", [t.variableDeclarator(id, t.objectExpression([]))]);
};
/**

@@ -275,7 +393,26 @@ * Description

ClassTransformer.prototype.verifyConstructor = function verifyConstructor(node) {
return; // enable this for the next major
ClassTransformer.prototype.placePropertyInitializers = function placePropertyInitializers() {
var body = this.instancePropBody;
if (body.length) {
// todo: check for scope conflicts and shift into a method
if (this.hasSuper) {
if (this.hasConstructor) {
this.bareSuper.insertAfter(body);
} else {
this.constructorBody.body = this.constructorBody.body.concat(body);
}
} else {
this.constructorBody.body = body.concat(this.constructorBody.body);
}
}
};
/**
* Description
*/
ClassTransformer.prototype.verifyConstructor = function verifyConstructor(path) {
var state = {
hasBareSuper: false,
bareSuper: null,
hasSuper: this.hasSuper,

@@ -285,6 +422,8 @@ file: this.file

traverse(node, verifyConstructorVisitor, this.scope, state);
path.traverse(verifyConstructorVisitor, state);
this.bareSuper = state.bareSuper;
if (!state.hasBareSuper && this.hasSuper) {
throw this.file.errorWithNode(node, "Derived constructor must call super()");
throw path.errorWithNode("Derived constructor must call super()");
}

@@ -298,7 +437,3 @@ };

ClassTransformer.prototype.pushMethod = function pushMethod(node) {
var methodName = node.key;
var kind = node.kind;
if (kind === "") {
if (node.kind === "method") {
nameMethod.property(node, this.file, this.scope);

@@ -311,3 +446,3 @@

if (!node["static"]) classRef = t.memberExpression(classRef, t.identifier("prototype"));
methodName = t.memberExpression(classRef, methodName, node.computed);
var methodName = t.memberExpression(classRef, node.key, node.computed);

@@ -319,15 +454,5 @@ var expr = t.expressionStatement(t.assignmentExpression("=", methodName, node.value));

}
kind = "value";
}
var mutatorMap = this.instanceMutatorMap;
if (node["static"]) {
this.hasStaticMutators = true;
mutatorMap = this.staticMutatorMap;
} else {
this.hasInstanceMutators = true;
}
defineMap.push(mutatorMap, methodName, kind, node.computed, node);
this.pushToMap(node);
};

@@ -340,12 +465,36 @@

ClassTransformer.prototype.pushProperty = function pushProperty(node) {
if (!node.value) return;
if (!node.value && !node.decorators) return;
var key;
if (node["static"]) {
key = t.memberExpression(this.classRef, node.key);
this.body.push(t.expressionStatement(t.assignmentExpression("=", key, node.value)));
if (node.decorators) {
var body = [];
if (node.value) body.push(t.returnStatement(node.value));
node.value = t.functionExpression(null, [], t.blockStatement(body));
this.pushToMap(node, true, "initializer");
if (node["static"]) {
var _ref;
this.staticPropBody.push(util.template("call-static-decorator", {
INITIALIZERS: (_ref = this, !_ref.staticInitializersId && (_ref.staticInitializersId = this.scope.generateUidIdentifier("staticInitializers")), _ref.staticInitializersId),
CONSTRUCTOR: this.classRef,
KEY: node.key }, true));
} else {
var _ref2;
this.instancePropBody.push(util.template("call-instance-decorator", {
INITIALIZERS: (_ref2 = this, !_ref2.instanceInitializersId && (_ref2.instanceInitializersId = this.scope.generateUidIdentifier("instanceInitializers")), _ref2.instanceInitializersId),
KEY: node.key
}, true));
}
} else {
key = t.memberExpression(t.thisExpression(), node.key);
this.constructor.body.body.unshift(t.expressionStatement(t.assignmentExpression("=", key, node.value)));
if (node["static"]) {
// can just be added to the static map
this.pushToMap(node, true);
} else {
// add this to the instancePropBody which will be added after the super call in a derived constructor
// or at the start of a constructor for a non-derived constructor
this.instancePropBody.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.thisExpression(), node.key), node.value)));
}
}

@@ -359,12 +508,8 @@ };

ClassTransformer.prototype.pushConstructor = function pushConstructor(method) {
if (method.kind) {
throw this.file.errorWithNode(method, messages.get("classesIllegalConstructorKind"));
}
var construct = this.constructor;
var fn = method.value;
this.userConstructor = fn;
this.hasConstructor = true;
t.inherits(construct, fn);
t.inheritsComments(construct, method);

@@ -376,3 +521,2 @@

t.inherits(construct.body, fn.body);
construct.body.body = construct.body.body.concat(fn.body.body);
};

@@ -379,0 +523,0 @@

@@ -50,3 +50,3 @@ "use strict";

function Scopable(node, parent, scope, file) {
scope.traverse(node, visitor, {
this.traverse(visitor, {
constants: scope.getAllBindingsOfKind("const"),

@@ -53,0 +53,0 @@ file: file

@@ -126,16 +126,8 @@ "use strict";

var nodes = [];
var ref = scope.generateUidIdentifier("ref");
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(ref, expr.right)]));
var destructuring = new DestructuringTransformer({
operator: expr.operator,
file: file,
scope: scope,
nodes: nodes
});
destructuring.init(expr.left, ref);
file: file });
return nodes;
return destructuring.init(expr.left, expr.right);
}

@@ -150,3 +142,3 @@

var nodes = [];
nodes.push(t.assignmentExpression("=", ref, node.right));
nodes.push(t.expressionStatement(t.assignmentExpression("=", ref, node.right)));

@@ -161,5 +153,5 @@ var destructuring = new DestructuringTransformer({

nodes.push(ref);
nodes.push(t.expressionStatement(ref));
return t.toSequenceExpression(nodes, scope);
return nodes;
}

@@ -232,3 +224,3 @@

var hasRest = function hasRest(pattern) {
function hasRest(pattern) {
for (var i = 0; i < pattern.elements.length; i++) {

@@ -240,2 +232,11 @@ if (t.isRestElement(pattern.elements[i])) {

return false;
}
var arrayUnpackVisitor = {
enter: function enter(node, parent, scope, state) {
if (this.isReferencedIdentifier() && state.bindings[node.name]) {
state.deopt = true;
this.stop();
}
}
};

@@ -249,3 +250,4 @@

this.operator = opts.operator;
this.nodes = opts.nodes;
this.arrays = {};
this.nodes = opts.nodes || [];
this.scope = opts.scope;

@@ -291,2 +293,10 @@ this.file = opts.file;

DestructuringTransformer.prototype.toArray = function toArray(node, count) {
if (this.file.isLoose("es6.destructuring") || t.isIdentifier(node) && this.arrays[node.name]) {
return node;
} else {
return this.scope.toArray(node, count);
}
};
DestructuringTransformer.prototype.pushAssignmentPattern = function pushAssignmentPattern(pattern, valueRef) {

@@ -399,3 +409,7 @@ // we need to assign the current value of the assignment to avoid evaluating

return true;
// deopt on reference to left side identifiers
var bindings = t.getBindingIdentifiers(pattern);
var state = { deopt: false, bindings: bindings };
this.scope.traverse(arr, arrayUnpackVisitor, state);
return !state.deopt;
};

@@ -437,3 +451,3 @@

var toArray = this.scope.toArray(arrayRef, count);
var toArray = this.toArray(arrayRef, count);

@@ -446,4 +460,4 @@ if (t.isIdentifier(toArray)) {

arrayRef = this.scope.generateUidBasedOnNode(arrayRef);
this.arrays[arrayRef.name] = true;
this.nodes.push(this.buildVariableDeclaration(arrayRef, toArray));
this.scope.assignTypeGeneric(arrayRef.name, "Array");
}

@@ -462,3 +476,3 @@

if (t.isRestElement(elem)) {
elemRef = this.scope.toArray(arrayRef);
elemRef = this.toArray(arrayRef);

@@ -484,6 +498,9 @@ if (i > 0) {

if (!t.isArrayExpression(ref) && !t.isMemberExpression(ref) && !t.isIdentifier(ref)) {
var key = this.scope.generateUidBasedOnNode(ref);
this.nodes.push(this.buildVariableDeclaration(key, ref));
ref = key;
var shouldMemoise = true;
if (!t.isArrayExpression(ref) && !t.isMemberExpression(ref)) {
var memo = this.scope.generateMemoisedReference(ref, true);
if (memo) {
this.nodes.push(this.buildVariableDeclaration(memo, ref));
ref = memo;
}
}

@@ -494,2 +511,4 @@

this.push(pattern, ref);
return this.nodes;
};

@@ -496,0 +515,0 @@

@@ -6,2 +6,3 @@ "use strict";

exports.ForOfStatement = ForOfStatement;
exports._ForOfStatementArray = _ForOfStatementArray;
exports.__esModule = true;

@@ -20,2 +21,6 @@

function ForOfStatement(node, parent, scope, file) {
if (this.get("right").isArrayExpression()) {
return _ForOfStatementArray.call(this, node, scope, file);
}
var callback = spec;

@@ -45,9 +50,42 @@ if (file.isLoose("es6.forOf")) callback = loose;

// todo: find out why this is necessary? #538
loop._scopeInfo = node._scopeInfo;
if (build.replaceParent) this.parentPath.node = build.node;
if (build.replaceParent) this.parentPath.replaceWithMultiple(build.node);
return build.node;
}
function _ForOfStatementArray(node, scope, file) {
var nodes = [];
var right = node.right;
if (!t.isIdentifier(right) || !scope.hasBinding(right.name)) {
var uid = scope.generateUidIdentifier("arr");
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, right)]));
right = uid;
}
var iterationKey = scope.generateUidIdentifier("i");
var loop = util.template("for-of-array", {
BODY: node.body,
KEY: iterationKey,
ARR: right
});
t.inherits(loop, node);
t.ensureBlock(loop);
var iterationValue = t.memberExpression(right, iterationKey, true);
var left = node.left;
if (t.isVariableDeclaration(left)) {
left.declarations[0].init = iterationValue;
loop.body.body.unshift(left);
} else {
loop.body.body.unshift(t.expressionStatement(t.assignmentExpression("=", left, iterationValue)));
}
nodes.push(loop);
return nodes;
}
var loose = function loose(node, parent, scope, file) {

@@ -54,0 +92,0 @@ var left = node.left;

@@ -6,3 +6,5 @@ "use strict";

exports.ImportDeclaration = ImportDeclaration;
exports.ExportDeclaration = ExportDeclaration;
exports.ExportAllDeclaration = ExportAllDeclaration;
exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
exports.ExportNamedDeclaration = ExportNamedDeclaration;
exports.__esModule = true;

@@ -14,2 +16,10 @@

function keepBlockHoist(node, nodes) {
if (node._blockHoist) {
for (var i = 0; i < nodes.length; i++) {
nodes[i]._blockHoist = node._blockHoist;
}
}
}
function ImportDeclaration(node, parent, scope, file) {

@@ -37,8 +47,21 @@ // flow type

function ExportDeclaration(node, parent, scope, file) {
function ExportAllDeclaration(node, parent, scope, file) {
var nodes = [];
file.moduleFormatter.exportAllDeclaration(node, nodes, parent);
keepBlockHoist(node, nodes);
return nodes;
}
function ExportDefaultDeclaration(node, parent, scope, file) {
var nodes = [];
file.moduleFormatter.exportDeclaration(node, nodes, parent);
keepBlockHoist(node, nodes);
return nodes;
}
function ExportNamedDeclaration(node, parent, scope, file) {
// flow type
if (t.isTypeAlias(node.declaration)) return;
if (this.get("declaration").isTypeAlias()) return;
var nodes = [];
var i;

@@ -55,3 +78,3 @@ if (node.declaration) {

} else if (node.specifiers) {
for (i = 0; i < node.specifiers.length; i++) {
for (var i = 0; i < node.specifiers.length; i++) {
file.moduleFormatter.exportSpecifier(node.specifiers[i], node, nodes, parent);

@@ -61,9 +84,5 @@ }

if (node._blockHoist) {
for (i = 0; i < nodes.length; i++) {
nodes[i]._blockHoist = node._blockHoist;
}
}
keepBlockHoist(node, nodes);
return nodes;
}

@@ -7,3 +7,2 @@ "use strict";

exports.check = check;
exports.ObjectExpression = ObjectExpression;

@@ -16,6 +15,5 @@ exports.__esModule = true;

function check(node) {
return t.isIdentifier(node, { name: "super" });
}
var check = t.isSuper;
exports.check = check;
function Property(node, scope, getObjectRef, file) {

@@ -22,0 +20,0 @@ if (!node.method) return;

@@ -5,5 +5,9 @@ "use strict";

var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
exports.check = check;
exports.__esModule = true;
var callDelegate = _interopRequire(require("../../helpers/call-delegate"));
var util = _interopRequireWildcard(require("../../../util"));

@@ -43,3 +47,3 @@

var argsIdentifier = t.identifier("arguments");
argsIdentifier._ignoreAliasFunctions = true;
argsIdentifier._shadowedFunctionLiteral = true;

@@ -62,16 +66,17 @@ var lastNonDefaultParam = 0;

for (var i = 0; i < node.params.length; i++) {
var param = node.params[i];
var params = this.get("params");
for (var i = 0; i < params.length; i++) {
var param = params[i];
if (!t.isAssignmentPattern(param)) {
if (!t.isRestElement(param)) {
if (!param.isAssignmentPattern()) {
if (!param.isRestElement()) {
lastNonDefaultParam = i + 1;
}
if (!t.isIdentifier(param)) {
scope.traverse(param, iifeVisitor, state);
if (!param.isIdentifier()) {
param.traverse(iifeVisitor, state);
}
if (file.transformers["es6.blockScopingTDZ"].canRun() && t.isIdentifier(param)) {
pushDefNode(param, t.identifier("undefined"), i);
if (file.transformers["es6.blockScopingTDZ"].canTransform() && param.isIdentifier()) {
pushDefNode(param.node, t.identifier("undefined"), i);
}

@@ -82,4 +87,4 @@

var left = param.left;
var right = param.right;
var left = param.get("left");
var right = param.get("right");

@@ -91,10 +96,10 @@ var placeholder = scope.generateUidIdentifier("x");

if (!state.iife) {
if (t.isIdentifier(right) && scope.hasOwnBinding(right.name)) {
if (right.isIdentifier() && scope.hasOwnBinding(right.node.name)) {
state.iife = true;
} else {
scope.traverse(right, iifeVisitor, state);
right.traverse(iifeVisitor, state);
}
}
pushDefNode(left, right, i);
pushDefNode(left.node, right.node, i);
}

@@ -106,7 +111,3 @@

if (state.iife) {
var container = t.functionExpression(null, [], node.body, node.generator);
container._aliasFunction = true;
body.push(t.returnStatement(t.callExpression(container, [])));
body.push(callDelegate(node));
node.body = t.blockStatement(body);

@@ -113,0 +114,0 @@ } else {

@@ -29,3 +29,3 @@ "use strict";

state.noOptimise = true;
scope.traverse(node, memberExpressionOptimisationVisitor, state);
this.traverse(memberExpressionOptimisationVisitor, state);
state.noOptimise = false;

@@ -79,3 +79,3 @@ return this.skip();

// otherwise `arguments` will be remapped in arrow functions
argsId._ignoreAliasFunctions = true;
argsId._shadowedFunctionLiteral = true;

@@ -105,3 +105,3 @@ // support patterns

scope.traverse(node, memberExpressionOptimisationVisitor, state);
this.traverse(memberExpressionOptimisationVisitor, state);

@@ -112,3 +112,3 @@ // we only have shorthands and there's no other references

var candidate = state.candidates[i];
candidate.node = argsId;
candidate.replaceWith(argsId);
optimizeMemberExpression(candidate.parent, node.params.length);

@@ -142,4 +142,2 @@ }

scope.assignTypeGeneric(rest.name, "Array");
var loop = util.template("rest", {

@@ -152,5 +150,6 @@ ARGUMENTS: argsId,

KEY: key,
LEN: len });
LEN: len
});
loop._blockHoist = node.params.length + 1;
node.body.body.unshift(loop);
};

@@ -105,4 +105,2 @@ "use strict";

var body = [];
var container = t.functionExpression(null, [], t.blockStatement(body));
container._aliasFunction = true;

@@ -121,5 +119,5 @@ //

body.push(t.returnStatement(objId));
body.push(t.expressionStatement(objId));
return t.callExpression(container, []);
return body;
}

@@ -17,3 +17,7 @@ "use strict";

function getSpreadLiteral(spread, scope) {
return scope.toArray(spread.argument, true);
if (scope.file.isLoose("es6.spread")) {
return spread.argument;
} else {
return scope.toArray(spread.argument, true);
}
}

@@ -99,4 +103,4 @@

if (t.isMemberExpression(callee)) {
var temp = scope.generateTempBasedOnNode(callee.object);
if (this.get("callee").isMemberExpression()) {
var temp = scope.generateMemoisedReference(callee.object);
if (temp) {

@@ -120,23 +124,9 @@ callee.object = t.assignmentExpression("=", temp, callee.object);

var nativeType = t.isIdentifier(node.callee) && includes(t.NATIVE_TYPE_NAMES, node.callee.name);
var nodes = build(args, scope);
if (nativeType) {
nodes.unshift(t.arrayExpression([t.literal(null)]));
}
var context = t.arrayExpression([t.literal(null)]);
var first = nodes.shift();
args = t.callExpression(t.memberExpression(context, t.identifier("concat")), nodes);
if (nodes.length) {
args = t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes);
} else {
args = first;
}
if (nativeType) {
return t.newExpression(t.callExpression(t.memberExpression(file.addHelper("bind"), t.identifier("apply")), [node.callee, args]), []);
} else {
return t.callExpression(file.addHelper("apply-constructor"), [node.callee, args]);
}
return t.newExpression(t.callExpression(t.memberExpression(file.addHelper("bind"), t.identifier("apply")), [node.callee, args]), []);
}

@@ -10,5 +10,7 @@ "use strict";

var optional = true;
var metadata = {
optional: true
};
exports.optional = optional;
exports.metadata = metadata;

@@ -20,3 +22,3 @@ function UnaryExpression(node, parent, scope, file) {

var call = t.callExpression(file.addHelper("typeof"), [node.argument]);
if (t.isIdentifier(node.argument)) {
if (this.get("argument").isIdentifier()) {
var undefLiteral = t.literal("undefined");

@@ -23,0 +25,0 @@ return t.conditionalExpression(t.binaryExpression("===", t.unaryExpression("typeof", node.argument), undefLiteral), undefLiteral, call);

@@ -22,3 +22,3 @@ "use strict";

exports.Function = function (node, parent, scope, file) {
var tailCall = new TailCallTransformer(node, scope, file);
var tailCall = new TailCallTransformer(this, scope, file);
tailCall.run();

@@ -35,7 +35,7 @@ };

if (this.isIfStatement()) {
if (t.isReturnStatement(node.alternate)) {
if (this.get("alternate").isReturnStatement()) {
t.ensureBlock(node, "alternate");
}
if (t.isReturnStatement(node.consequent)) {
if (this.get("consequent").isReturnStatement()) {
t.ensureBlock(node, "consequent");

@@ -101,3 +101,3 @@ }

var TailCallTransformer = (function () {
function TailCallTransformer(node, scope, file) {
function TailCallTransformer(path, scope, file) {
_classCallCheck(this, TailCallTransformer);

@@ -109,8 +109,9 @@

this.needsThis = false;
this.ownerId = node.id;
this.ownerId = path.node.id;
this.vars = [];
this.scope = scope;
this.path = path;
this.file = file;
this.node = node;
this.node = path.node;
}

@@ -169,4 +170,4 @@

// perform optimisations
var ownerIdInfo = this.scope.getBindingInfo(this.ownerId.name);
return ownerIdInfo && ownerIdInfo.reassigned;
var ownerIdInfo = this.scope.getBinding(this.ownerId.name);
return ownerIdInfo && !ownerIdInfo.constant;
};

@@ -184,3 +185,3 @@

// traverse the function and look for tail recursion
scope.traverse(node, firstPass, this);
this.path.traverse(firstPass, this);

@@ -196,6 +197,6 @@ if (!this.hasTailRecursion) return;

scope.traverse(node, secondPass, this);
this.path.traverse(secondPass, this);
if (!this.needsThis || !this.needsArguments) {
scope.traverse(node, thirdPass, this);
this.path.traverse(thirdPass, this);
}

@@ -202,0 +203,0 @@

@@ -12,6 +12,14 @@ "use strict";

var buildBinaryExpression = function buildBinaryExpression(left, right) {
return t.binaryExpression("+", left, right);
var buildBinaryExpression = function buildBinaryExpression(left, right, file) {
return t.binaryExpression("+", left, coerce(right, file));
};
function coerce(node, file) {
if (file.isLoose("es7.templateLiterals") || t.isLiteral(node) && typeof node.value === "string") {
return node;
} else {
return t.callExpression(t.identifier("String"), [node]);
}
}
function check(node) {

@@ -22,4 +30,4 @@ return t.isTemplateLiteral(node) || t.isTaggedTemplateExpression(node);

function TaggedTemplateExpression(node, parent, scope, file) {
var quasi = node.quasi;
var args = [];
var quasi = node.quasi;

@@ -47,3 +55,3 @@ var strings = [];

function TemplateLiteral(node) {
function TemplateLiteral(node, parent, scope, file) {
var nodes = [];

@@ -66,6 +74,6 @@ var i;

var root = buildBinaryExpression(nodes.shift(), nodes.shift());
var root = buildBinaryExpression(nodes.shift(), nodes.shift(), file);
for (i = 0; i < nodes.length; i++) {
root = buildBinaryExpression(root, nodes[i]);
root = buildBinaryExpression(root, nodes[i], file);
}

@@ -72,0 +80,0 @@

@@ -18,5 +18,8 @@ "use strict";

var experimental = true;
var metadata = {
experimental: true,
optional: true
};
exports.experimental = experimental;
exports.metadata = metadata;

@@ -32,3 +35,3 @@ function ComprehensionExpression(node, parent, scope, file) {

var container = t.functionExpression(null, [], t.blockStatement(body), true);
container._aliasFunction = true;
container.shadow = true;

@@ -48,3 +51,3 @@ body.push(buildComprehension(node, function () {

});
container.callee._aliasFunction = true;
container.callee.shadow = true;

@@ -51,0 +54,0 @@ var block = container.callee.body;

@@ -7,3 +7,2 @@ "use strict";

exports.__esModule = true;
// https://github.com/rwaldron/exponentiation-operator

@@ -15,5 +14,2 @@

var experimental = true;
exports.experimental = experimental;
var MATH_POW = t.memberExpression(t.identifier("Math"), t.identifier("pow"));

@@ -20,0 +16,0 @@

@@ -12,8 +12,11 @@ "use strict";

var experimental = true;
var metadata = {
experimental: true,
optional: true
};
exports.experimental = experimental;
exports.metadata = metadata;
function manipulateOptions(opts) {
if (opts.whitelist.length) opts.whitelist.push("es6.destructuring");
if (opts.whitelist) opts.whitelist.push("es6.destructuring");
}

@@ -20,0 +23,0 @@

"use strict";
module.exports = {
"es7.classProperties": require("./es7/class-properties"),
"es7.asyncFunctions": require("./es7/async-functions"),
"es7.decorators": require("./es7/decorators"),
strict: require("./other/strict"),

@@ -14,14 +18,8 @@

"spec.blockScopedFunctions": require("./spec/block-scoped-functions"),
// needs to be before `_aliasFunction`
// needs to be before `_shadowFunctions`
"es6.arrowFunctions": require("./es6/arrow-functions"),
"playground.malletOperator": require("./playground/mallet-operator"),
"playground.methodBinding": require("./playground/method-binding"),
"playground.memoizationOperator": require("./playground/memoization-operator"),
"playground.objectGetterMemoization": require("./playground/object-getter-memoization"),
"spec.blockScopedFunctions": require("./spec/block-scoped-functions"),
reactCompat: require("./other/react-compat"),
flow: require("./other/flow"),
react: require("./other/react"),

@@ -32,3 +30,3 @@

// needs to be before `regenerator` due to generator comprehensions
// needs to be before `_aliasFunction`
// needs to be before `_shadowFunctions`
"es7.comprehensions": require("./es7/comprehensions"),

@@ -49,5 +47,6 @@

// needs to be before `_aliasFunction` due to define property closure
// needs to be before `_shadowFunctions` due to define property closure
"es6.properties.computed": require("./es6/properties.computed"),
"optimisation.flow.forOf": require("./optimisation/flow.for-of"),
"es6.forOf": require("./es6/for-of"),

@@ -57,3 +56,2 @@

"es6.regex.unicode": require("./es6/regex.unicode"),
"es7.abstractReferences": require("./es7/abstract-references"),

@@ -74,3 +72,3 @@ "es6.constants": require("./es6/constants"),

// needs to be before `_aliasFunction` due to block scopes sometimes being wrapped in a
// needs to be before `_shadowFunctions` due to block scopes sometimes being wrapped in a
// closure

@@ -102,4 +100,6 @@ "es6.blockScoping": require("./es6/block-scoping"),

_aliasFunctions: require("./internal/alias-functions"),
_shadowFunctions: require("./internal/shadow-functions"),
"es7.doExpressions": require("./es7/do-expressions"),
"es6.symbols": require("./es6/symbols"),

@@ -121,3 +121,4 @@ "spec.undefinedToVoid": require("./spec/undefined-to-void"),

flow: require("./other/flow"),
_cleanUp: require("./internal/cleanup")
};

@@ -30,3 +30,3 @@ "use strict";

var nodePriorities = groupBy(node.body, function (bodyNode) {
var priority = bodyNode._blockHoist;
var priority = bodyNode && bodyNode._blockHoist;
if (priority == null) priority = 1;

@@ -33,0 +33,0 @@ if (priority === true) priority = 2;

@@ -12,5 +12,7 @@ "use strict";

var secondPass = true;
var metadata = {
secondPass: true
};
exports.secondPass = secondPass;
exports.metadata = metadata;

@@ -17,0 +19,0 @@ function BlockStatement(node, parent, scope, file) {

@@ -15,3 +15,3 @@ "use strict";

if (!file.transformers["es6.modules"].canRun()) return;
if (!file.transformers["es6.modules"].canTransform()) return;

@@ -18,0 +18,0 @@ if (file.moduleFormatter.transform) {

@@ -7,3 +7,4 @@ "use strict";

exports.ImportDeclaration = ImportDeclaration;
exports.ExportDeclaration = ExportDeclaration;
exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
exports.ExportNamedDeclaration = ExportNamedDeclaration;
exports.__esModule = true;

@@ -23,14 +24,38 @@ // in this transformer we have to split up classes and function declarations

function ImportDeclaration(node, parent, scope, file) {
var resolveModuleSource = file.opts.resolveModuleSource;
if (node.source && resolveModuleSource) {
node.source.value = resolveModuleSource(node.source.value, file.opts.filename);
if (node.source) {
node.source.value = file.resolveModuleSource(node.source.value);
}
}
function ExportDeclaration(node, parent, scope) {
function ExportDefaultDeclaration(node, parent, scope) {
ImportDeclaration.apply(this, arguments);
// flow type
if (node.isType) return;
var declar = node.declaration;
var getDeclar = function getDeclar() {
declar._ignoreUserWhitespace = true;
return declar;
};
if (t.isClassDeclaration(declar)) {
// export default class Foo {};
node.declaration = declar.id;
return [getDeclar(), node];
} else if (t.isClassExpression(declar)) {
// export default class {};
var temp = scope.generateUidIdentifier("default");
declar = t.variableDeclaration("var", [t.variableDeclarator(temp, declar)]);
node.declaration = temp;
return [getDeclar(), node];
} else if (t.isFunctionDeclaration(declar)) {
// export default function Foo() {}
node._blockHoist = 2;
node.declaration = declar.id;
return [getDeclar(), node];
}
}
function ExportNamedDeclaration(node, parent, scope) {
ImportDeclaration.apply(this, arguments);
var declar = node.declaration;

@@ -43,37 +68,23 @@

if (node["default"]) {
if (t.isClassDeclaration(declar)) {
// export default class Foo {};
this.node = [getDeclar(), node];
node.declaration = declar.id;
} else if (t.isClassExpression(declar)) {
// export default class {};
var temp = scope.generateUidIdentifier("default");
declar = t.variableDeclaration("var", [t.variableDeclarator(temp, declar)]);
node.declaration = temp;
return [getDeclar(), node];
} else if (t.isFunctionDeclaration(declar)) {
// export default function Foo() {}
node._blockHoist = 2;
node.declaration = declar.id;
return [getDeclar(), node];
if (t.isClassDeclaration(declar)) {
// export class Foo {}
node.specifiers = [t.exportSpecifier(declar.id, declar.id)];
node.declaration = null;
return [getDeclar(), node];
} else if (t.isFunctionDeclaration(declar)) {
// export function Foo() {}
node.specifiers = [t.exportSpecifier(declar.id, declar.id)];
node.declaration = null;
node._blockHoist = 2;
return [getDeclar(), node];
} else if (t.isVariableDeclaration(declar)) {
// export var foo = "bar";
var specifiers = [];
var bindings = this.get("declaration").getBindingIdentifiers();
for (var key in bindings) {
var id = bindings[key];
specifiers.push(t.exportSpecifier(id, id));
}
} else {
if (t.isFunctionDeclaration(declar)) {
// export function Foo() {}
node.specifiers = [t.importSpecifier(declar.id, declar.id)];
node.declaration = null;
node._blockHoist = 2;
return [getDeclar(), node];
} else if (t.isVariableDeclaration(declar)) {
// export var foo = "bar";
var specifiers = [];
var bindings = t.getBindingIdentifiers(declar);
for (var key in bindings) {
var id = bindings[key];
specifiers.push(t.exportSpecifier(id, id));
}
return [declar, t.exportDeclaration(null, specifiers)];
}
return [declar, t.exportNamedDeclaration(null, specifiers)];
}
}

@@ -11,3 +11,3 @@ "use strict";

function Program(program, parent, scope, file) {
if (file.transformers.strict.canRun()) {
if (file.transformers.strict.canTransform()) {
var directive = file.get("existingStrictDirective");

@@ -14,0 +14,0 @@

@@ -6,2 +6,3 @@ "use strict";

exports.ForOfStatement = ForOfStatement;
exports.MethodDefinition = MethodDefinition;
exports.Property = Property;

@@ -15,2 +16,8 @@ exports.BlockStatement = BlockStatement;

var metadata = {
readOnly: true
};
exports.metadata = metadata;
function ForOfStatement(node, parent, scope, file) {

@@ -26,2 +33,18 @@ var left = node.left;

function MethodDefinition(node) {
if (node.kind !== "constructor") {
// get constructor() {}
var isConstructor = !node.computed && t.isIdentifier(node.key, { name: "constructor" });
// get ["constructor"]() {}
if (!isConstructor) isConstructor = t.isLiteral(node.key, { value: "constructor" });
if (isConstructor) {
throw this.errorWithNode(messages.get("classesIllegalConstructorKind"));
}
}
Property.apply(this, arguments);
}
function Property(node, parent, scope, file) {

@@ -40,4 +63,2 @@ if (node.kind === "set") {

exports.MethodDefinition = Property;
function BlockStatement(node) {

@@ -44,0 +65,0 @@ for (var i = 0; i < node.body.length; i++) {

@@ -10,5 +10,7 @@ "use strict";

exports.manipulateOptions = require("./bluebird-coroutines").manipulateOptions;
var optional = true;
var metadata = {
optional: true
};
exports.optional = optional;
exports.metadata = metadata;
exports.Function = function (node, parent, scope, file) {

@@ -15,0 +17,0 @@ if (!node.async || node.generator) return;

@@ -15,9 +15,11 @@ "use strict";

function manipulateOptions(opts) {
opts.experimental = true;
opts.optional.push("es7.asyncFunctions");
opts.blacklist.push("regenerator");
}
var optional = true;
var metadata = {
optional: true
};
exports.optional = optional;
exports.metadata = metadata;
exports.Function = function (node, parent, scope, file) {

@@ -24,0 +26,0 @@ if (!node.async || node.generator) return;

@@ -44,3 +44,3 @@ "use strict";

function ExportDeclaration(node) {
if (t.isTypeAlias(node.declaration)) this.remove();
if (this.get("declaration").isTypeAlias()) this.remove();
}

@@ -16,5 +16,7 @@ "use strict";

var optional = true;
var metadata = {
optional: true
};
exports.optional = optional;
exports.metadata = metadata;
require("../../helpers/build-react-transformer")(exports, {

@@ -21,0 +23,0 @@ pre: function pre(state) {

@@ -23,3 +23,3 @@ "use strict";

var isSymboliterator = t.buildMatchMemberExpression("Symbol.iterator");
var isSymbolIterator = t.buildMatchMemberExpression("Symbol.iterator");

@@ -60,3 +60,3 @@ var coreHas = function coreHas(node) {

prop = callee.property;
if (!isSymboliterator(prop)) return false;
if (!isSymbolIterator(prop)) return false;

@@ -73,3 +73,3 @@ return util.template("corejs-iterator", {

var left = node.left;
if (!isSymboliterator(left)) return;
if (!isSymbolIterator(left)) return;

@@ -84,12 +84,15 @@ return util.template("corejs-is-iterator", {

var optional = true;
var metadata = {
optional: true,
react: true
};
exports.optional = optional;
exports.metadata = metadata;
function manipulateOptions(opts) {
if (opts.whitelist.length) opts.whitelist.push("es6.modules");
if (opts.whitelist) opts.whitelist.push("es6.modules");
}
function Program(node, parent, scope, file) {
scope.traverse(node, astVisitor, file);
this.traverse(astVisitor, file);
}

@@ -96,0 +99,0 @@

@@ -27,2 +27,3 @@ "use strict";

exports.FunctionDeclaration = FunctionExpression;
exports.Class = FunctionExpression;

@@ -29,0 +30,0 @@ function ThisExpression() {

"use strict";
exports.__esModule = true;
exports.FunctionExpression = require("../../helpers/name-method").bare;
var _helpersNameMethod = require("../../helpers/name-method");
exports.FunctionExpression = _helpersNameMethod.bare;
exports.ArrowFunctionExpression = _helpersNameMethod.bare;

@@ -29,7 +29,8 @@ "use strict";

var secondPass = true;
exports.secondPass = secondPass;
var optional = true;
var metadata = {
secondPass: true,
optional: true
};
exports.optional = optional;
exports.metadata = metadata;

@@ -41,3 +42,3 @@ function AssignmentExpression(node, parent, scope, file) {

var left = node.left.object;
var temp = scope.generateTempBasedOnNode(node.left.object);
var temp = scope.generateMemoisedReference(left);

@@ -48,3 +49,3 @@ nodes.push(t.expressionStatement(t.assignmentExpression("=", temp, left)));

return t.toSequenceExpression(nodes);
return nodes;
}

@@ -51,0 +52,0 @@

@@ -10,5 +10,8 @@ "use strict";

var optional = true;
var metadata = {
optional: true,
react: true
};
exports.optional = optional;
exports.metadata = metadata;

@@ -15,0 +18,0 @@ function Identifier(node, parent) {

@@ -27,8 +27,10 @@ "use strict";

var optional = true;
var metadata = {
optional: true
};
exports.optional = optional;
exports.metadata = metadata;
function ConditionalExpression(node, parent, scope) {
var evaluateTest = t.evaluateTruthy(node.test, scope);
var evaluateTest = this.get("test").evaluateTruthy();
if (evaluateTest === true) {

@@ -45,5 +47,4 @@ return node.consequent;

var alternate = node.alternate;
var test = node.test;
var evaluateTest = t.evaluateTruthy(test, scope);
var evaluateTest = this.get("test").evaluateTruthy();

@@ -50,0 +51,0 @@ // we can check if a test will be truthy 100% and if so then we can inline

@@ -10,5 +10,7 @@ "use strict";

var optional = true;
var metadata = {
optional: true
};
exports.optional = optional;
exports.metadata = metadata;
var match = t.buildMatchMemberExpression("process.env");

@@ -18,3 +20,3 @@

if (match(node.object)) {
var key = t.toComputedKey(node, node.property);
var key = this.toComputedKey();
if (t.isLiteral(key)) {

@@ -21,0 +23,0 @@ return t.valueToNode(process.env[key.value]);

@@ -11,8 +11,10 @@ "use strict";

var optional = true;
var metadata = {
optional: true
};
exports.optional = optional;
exports.metadata = metadata;
function Expression(node, parent, scope) {
var res = t.evaluate(node, scope);
var res = this.evaluate();
if (res.confident) return t.valueToNode(res.value);

@@ -19,0 +21,0 @@ }

@@ -10,10 +10,10 @@ "use strict";

var isConsole = t.buildMatchMemberExpression("console", true);
var metadata = {
optional: true
};
var optional = true;
exports.metadata = metadata;
exports.optional = optional;
function CallExpression(node, parent) {
if (isConsole(node.callee)) {
if (this.get("callee").matchesPattern("console", true)) {
if (t.isExpressionStatement(parent)) {

@@ -20,0 +20,0 @@ this.parentPath.remove();

@@ -10,5 +10,7 @@ "use strict";

var optional = true;
var metadata = {
optional: true
};
exports.optional = optional;
exports.metadata = metadata;

@@ -15,0 +17,0 @@ function ExpressionStatement(node) {

@@ -26,3 +26,3 @@ "use strict";

function CallExpression(node, parent, scope, file) {
if (t.isIdentifier(node.callee, { name: "require" }) && node.arguments.length === 1) {
if (this.get("callee").isIdentifier({ name: "require" }) && node.arguments.length === 1) {
check(node.arguments[0], file);

@@ -29,0 +29,0 @@ }

@@ -14,5 +14,7 @@ "use strict";

var optional = true;
var metadata = {
optional: true
};
exports.optional = optional;
exports.metadata = metadata;

@@ -19,0 +21,0 @@ function Identifier(node, parent, scope, file) {

@@ -11,4 +11,2 @@ "use strict";

var flatten = _interopRequire(require("lodash/array/flatten"));
var compact = _interopRequire(require("lodash/array/compact"));

@@ -22,3 +20,2 @@

this.shouldFlatten = false;
this.parentPath = parentPath;

@@ -30,37 +27,51 @@ this.scope = scope;

TraversalContext.prototype.flatten = function flatten() {
this.shouldFlatten = true;
TraversalContext.prototype.create = function create(node, obj, key) {
return TraversalPath.get(this.parentPath, this, node, obj, key);
};
TraversalContext.prototype.visitNode = function visitNode(node, obj, key) {
var iteration = TraversalPath.get(this.parentPath, this, node, obj, key);
return iteration.visit();
};
TraversalContext.prototype.visitMultiple = function visitMultiple(nodes, node, key) {
// nothing to traverse!
if (nodes.length === 0) return false;
TraversalContext.prototype.visit = function visit(node, key) {
var nodes = node[key];
if (!nodes) return;
var visited = [];
if (!Array.isArray(nodes)) {
return this.visitNode(node, node, key);
}
var queue = this.queue = [];
var stop = false;
// nothing to traverse!
if (nodes.length === 0) {
return;
// build up initial queue
for (var i = 0; i < nodes.length; i++) {
if (nodes[i]) queue.push(this.create(node, nodes, i));
}
for (var i = 0; i < nodes.length; i++) {
if (nodes[i] && this.visitNode(node, nodes, i)) {
return true;
// visit the queue
for (var i = 0; i < queue.length; i++) {
var path = queue[i];
if (visited.indexOf(path.node) >= 0) continue;
visited.push(path.node);
if (path.visit()) {
stop = true;
break;
}
}
if (this.shouldFlatten) {
node[key] = flatten(node[key]);
// clear context from queued paths
for (var i = 0; i < queue.length; i++) {}
if (t.FLATTENABLE_KEYS.indexOf(key) >= 0) {
// we can safely compact this
node[key] = compact(node[key]);
}
return stop;
};
TraversalContext.prototype.visitSingle = function visitSingle(node, key) {
return this.create(node, node, key).visit();
};
TraversalContext.prototype.visit = function visit(node, key) {
var nodes = node[key];
if (!nodes) return;
if (Array.isArray(nodes)) {
return this.visitMultiple(nodes, node, key);
} else {
return this.visitSingle(node, key);
}

@@ -72,2 +83,4 @@ };

module.exports = TraversalContext;
module.exports = TraversalContext;
//queue[i].clearContext();

@@ -15,3 +15,3 @@ "use strict";

function traverse(parent, opts, scope, state) {
function traverse(parent, opts, scope, state, parentPath) {
if (!parent) return;

@@ -32,6 +32,6 @@

for (var i = 0; i < parent.length; i++) {
traverse.node(parent[i], opts, scope, state);
traverse.node(parent[i], opts, scope, state, parentPath);
}
} else {
traverse.node(parent, opts, scope, state);
traverse.node(parent, opts, scope, state, parentPath);
}

@@ -52,22 +52,10 @@ }

var CLEAR_KEYS = ["trailingComments", "leadingComments", "extendedRange", "_declarations", "_scopeInfo", "_paths", "tokens", "range", "start", "end", "loc", "raw"];
function clearNode(node) {
node._declarations = null;
node.extendedRange = null;
node._scopeInfo = null;
node._paths = null;
node.tokens = null;
node.range = null;
node.start = null;
node.end = null;
node.loc = null;
node.raw = null;
if (Array.isArray(node.trailingComments)) {
clearComments(node.trailingComments);
for (var i = 0; i < CLEAR_KEYS.length; i++) {
var key = CLEAR_KEYS[i];
if (node[key] != null) node[key] = null;
}
if (Array.isArray(node.leadingComments)) {
clearComments(node.leadingComments);
}
for (var key in node) {

@@ -74,0 +62,0 @@ var val = node[key];

@@ -25,2 +25,4 @@ "use strict";

var extend = _interopRequire(require("lodash/object/extend"));
var Scope = _interopRequire(require("../scope"));

@@ -30,2 +32,28 @@

var hoistVariablesVisitor = {
enter: function enter(node, parent, scope) {
if (this.isFunction()) {
return this.skip();
}
if (this.isVariableDeclaration() && node.kind === "var") {
var bindings = this.getBindingIdentifiers();
for (var key in bindings) {
scope.push({ id: bindings[key] });
}
var exprs = [];
for (var i = 0; i < node.declarations.length; i++) {
var declar = node.declarations[i];
if (declar.init) {
exprs.push(t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init)));
}
}
return exprs;
}
}
};
var TraversalPath = (function () {

@@ -76,6 +104,65 @@ function TraversalPath(parent, container) {

TraversalPath.prototype.insertBefore = function insertBefore(node) {};
TraversalPath.prototype.queueNode = function queueNode(path) {
if (this.context) {
this.context.queue.push(path);
}
};
TraversalPath.prototype.insertAfter = function insertAfter(node) {};
TraversalPath.prototype.insertBefore = function insertBefore(nodes) {
this.checkNodes(nodes);
if (this.isPreviousType("Expression")) {
if (this.node) nodes.push(this.node);
this.replaceExpressionWithStatements(nodes);
} else {
throw new Error("no idea what to do with this");
}
};
TraversalPath.prototype._containerInsertAfter = function _containerInsertAfter(nodes) {
this.updateSiblingKeys(this.key + 1, nodes.length);
for (var i = 0; i < nodes.length; i++) {
var to = this.key + 1 + i;
this.container.splice(to, 0, nodes[i]);
if (this.context) {
this.queueNode(this.context.create(this.parent, this.container, to));
}
}
};
TraversalPath.prototype.insertAfter = function insertAfter(nodes) {
this.checkNodes(nodes);
if (this.isPreviousType("Statement")) {
if (Array.isArray(this.container)) {
this._containerInsertAfter(nodes);
} else if (includes(t.STATEMENT_OR_BLOCK_KEYS, this.key) && !t.isBlockStatement(this.container)) {
this.container[this.key] = t.blockStatement(nodes);
} else {
throw new Error("no idea what to do with this");
}
} else if (this.isPreviousType("Expression")) {
if (this.node) {
var temp = this.scope.generateTemp();
nodes.unshift(t.expressionStatement(t.assignmentExpression("=", temp, this.node)));
nodes.push(t.expressionStatement(temp));
}
this.replaceExpressionWithStatements(nodes);
} else {
throw new Error("no idea what to do with this");
}
};
TraversalPath.prototype.updateSiblingKeys = function updateSiblingKeys(fromIndex, incrementBy) {
var paths = this.container._paths;
for (var i = 0; i < paths.length; i++) {
var path = paths[i];
if (path.key >= fromIndex) {
path.key += incrementBy;
}
}
};
TraversalPath.prototype.setData = function setData(key, val) {

@@ -95,5 +182,10 @@ return this.data[key] = val;

TraversalPath.prototype.clearContext = function clearContext() {
this.context = null;
};
TraversalPath.prototype.setContext = function setContext(parentPath, context, key, file) {
this.shouldSkip = false;
this.shouldStop = false;
this.removed = false;

@@ -110,8 +202,18 @@ this.parentPath = parentPath || this.parentPath;

this.setScope(file);
this.type = this.node && this.node.type;
};
TraversalPath.prototype._remove = function _remove() {
if (Array.isArray(this.container)) {
this.container.splice(this.key, 1);
this.updateSiblingKeys(this.key, -1);
} else {
this.container[this.key] = null;
}
};
TraversalPath.prototype.remove = function remove() {
this._refresh(this.node, []);
this.container[this.key] = null;
this.flatten();
this._remove();
this.removed = true;
};

@@ -128,13 +230,2 @@

TraversalPath.prototype.flatten = function flatten() {
this.context.flatten();
};
TraversalPath.prototype._refresh = function _refresh(oldNode, newNodes) {};
TraversalPath.prototype.refresh = function refresh() {
var node = this.node;
this._refresh(node, [node]);
};
TraversalPath.prototype.errorWithNode = function errorWithNode(msg) {

@@ -149,2 +240,122 @@ var Error = arguments[1] === undefined ? SyntaxError : arguments[1];

TraversalPath.prototype.replaceInline = function replaceInline(nodes) {
if (Array.isArray(nodes)) {
if (Array.isArray(this.container)) {
this._verifyNodeList(nodes);
this._containerInsertAfter(nodes);
return this.remove();
} else {
return this.replaceWithMultiple(nodes);
}
} else {
return this.replaceWith(nodes);
}
};
TraversalPath.prototype._verifyNodeList = function _verifyNodeList(nodes) {
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (!node) throw new Error("Node list has falsy node with the index of " + i);
}
};
TraversalPath.prototype.replaceWithMultiple = function replaceWithMultiple(nodes) {
this._verifyNodeList(nodes);
t.inheritsComments(nodes[0], this.node);
this.container[this.key] = null;
this.insertAfter(nodes);
if (!this.node) this.remove();
};
TraversalPath.prototype.replaceWith = function replaceWith(replacement, arraysAllowed) {
if (this.removed) {
throw new Error("You can't replace this node, we've already removed it");
}
if (!replacement) {
throw new Error("You passed `path.replaceWith()` a falsy node, use `path.remove()` instead");
}
if (Array.isArray(replacement)) {
if (arraysAllowed) {
return this.replaceWithMultiple(replacement);
} else {
throw new Error("Don't use `path.replaceWith()` with an array of nodes, use `path.replaceWithMultiple()`");
}
}
if (this.isPreviousType("Expression") && t.isStatement(replacement)) {
return this.replaceExpressionWithStatements([replacement]);
}
var oldNode = this.node;
if (oldNode) t.inheritsComments(replacement, oldNode);
// replace the node
this.container[this.key] = replacement;
this.type = replacement.type;
// potentially create new scope
this.setScope();
this.checkNodes([replacement]);
};
TraversalPath.prototype.checkNodes = function checkNodes(nodes) {
var scope = this.scope;
var file = scope && scope.file;
if (!file) return;
for (var i = 0; i < nodes.length; i++) {
file.checkNode(nodes[i], scope);
}
};
TraversalPath.prototype.getLastStatements = function getLastStatements() {
var paths = [];
var add = function add(path) {
if (path) paths = paths.concat(path.getLastStatements());
};
if (this.isIfStatement()) {
add(this.get("consequent"));
add(this.get("alternate"));
} else if (this.isDoExpression()) {
add(this.get("body"));
} else if (this.isProgram() || this.isBlockStatement()) {
add(this.get("body").pop());
} else {
paths.push(this);
}
return paths;
};
TraversalPath.prototype.replaceExpressionWithStatements = function replaceExpressionWithStatements(nodes) {
var toSequenceExpression = t.toSequenceExpression(nodes, this.scope);
if (toSequenceExpression) {
return this.replaceWith(toSequenceExpression);
} else {
var container = t.functionExpression(null, [], t.blockStatement(nodes));
container.shadow = true;
// add implicit returns to all ending expression statements
var last = this.getLastStatements();
for (var i = 0; i < last.length; i++) {
var lastNode = last[i];
if (lastNode.isExpressionStatement()) {
lastNode.replaceWith(t.returnStatement(lastNode.node.expression));
}
}
this.replaceWith(t.callExpression(container, []));
this.traverse(hoistVariablesVisitor);
return this.node;
}
};
TraversalPath.prototype.call = function call(key) {

@@ -159,6 +370,3 @@ var node = this.node;

var replacement = fn.call(this, node, this.parent, this.scope, this.state);
if (replacement) {
this.node = replacement;
}
if (replacement) this.replaceWith(replacement, true);
};

@@ -199,13 +407,33 @@

TraversalPath.prototype.getSibling = function getSibling(key) {
return TraversalPath.get(this.parentPath, null, this.parent, this.container, key, this.file);
};
TraversalPath.prototype.get = function get(key) {
var _this = this;
var node = this.node;
var container = node[key];
if (Array.isArray(container)) {
return container.map(function (_, i) {
return TraversalPath.get(_this, _this.context, node, container, i);
});
var parts = key.split(".");
if (parts.length === 1) {
// "foo.bar"
var node = this.node;
var container = node[key];
if (Array.isArray(container)) {
return container.map(function (_, i) {
return TraversalPath.get(_this, null, node, container, i);
});
} else {
return TraversalPath.get(this, null, node, node, key);
}
} else {
return TraversalPath.get(this, this.context, node, node, key);
// "foo"
var path = this;
for (var i = 0; i > parts.length; i++) {
var part = parts[i];
if (part === ".") {
path = path.parentPath;
} else {
path = path.get(parts[i]);
}
}
return path;
}

@@ -357,2 +585,6 @@ };

TraversalPath.prototype.isPreviousType = function isPreviousType(type) {
return t.isType(this.type, type);
};
TraversalPath.prototype.isTypeGeneric = function isTypeGeneric(genericName) {

@@ -453,38 +685,10 @@ var opts = arguments[1] === undefined ? {} : arguments[1];

get: function () {
return this.container[this.key];
if (this.removed) {
return null;
} else {
return this.container[this.key];
}
},
set: function (replacement) {
if (!replacement) return this.remove();
var oldNode = this.node;
var isArray = Array.isArray(replacement);
var replacements = isArray ? replacement : [replacement];
// inherit comments from original node to the first replacement node
var inheritTo = replacements[0];
if (inheritTo) t.inheritsComments(inheritTo, oldNode);
// replace the node
this.container[this.key] = replacement;
// potentially create new scope
this.setScope();
var file = this.scope && this.scope.file;
if (file) {
for (var i = 0; i < replacements.length; i++) {
file.checkNode(replacements[i], this.scope);
}
}
// we're replacing a statement or block node with an array of statements so we better
// ensure that it's a block
if (isArray) {
if (includes(t.STATEMENT_OR_BLOCK_KEYS, this.key) && !t.isBlockStatement(this.container)) {
t.ensureBlock(this.container, this.key);
}
this.flatten();
// TODO: duplicate internal path metadata across the new node paths
}
throw new Error("Don't use `path.node = newNode;`, use `path.replaceWith(newNode)` or `path.replaceWithMultiple([newNode])`");
}

@@ -512,5 +716,3 @@ }

// todo
// otherwise it's a request for a destructuring declarator and i'm not
// ready to resolve those just yet

@@ -17,2 +17,4 @@ "use strict";

var Binding = _interopRequire(require("./binding"));
var globals = _interopRequire(require("globals"));

@@ -32,6 +34,8 @@

enter: function enter(node, parent, scope, state) {
var _this = this;
if (t.isFor(node)) {
each(t.FOR_INIT_KEYS, function (key) {
var declar = node[key];
if (t.isVar(declar)) state.scope.registerBinding("var", declar);
var declar = _this.get(key);
if (declar.isVar()) state.scope.registerBinding("var", declar);
});

@@ -42,3 +46,3 @@ }

// declared within are accessible
if (t.isFunction(node)) return this.skip();
if (this.isFunction()) return this.skip();

@@ -49,9 +53,9 @@ // function identifier doesn't belong to this scope

// delegate block scope handling to the `blockVariableVisitor`
if (t.isBlockScoped(node)) return;
if (this.isBlockScoped()) return;
// this will be hit again once we traverse into it after this iteration
if (t.isExportDeclaration(node) && t.isDeclaration(node.declaration)) return;
if (this.isExportDeclaration() && t.isDeclaration(node.declaration)) return;
// we've ran into a declaration!
if (t.isDeclaration(node)) state.scope.registerDeclaration(node);
if (this.isDeclaration()) state.scope.registerDeclaration(this);
}

@@ -66,4 +70,8 @@ };

state.addGlobal(node);
} else if (t.isAssignmentExpression(node) || t.isUpdateExpression(node) || t.isUnaryExpression(node) && node.operator === "delete") {
scope.registerBindingReassignment(node);
} else if (t.isAssignmentExpression(node)) {
scope.registerConstantViolation(this.get("left"), this.get("right"));
} else if (t.isUpdateExpression(node)) {
scope.registerConstantViolation(this.get("argument"), null);
} else if (t.isUnaryExpression(node) && node.operator === "delete") {
scope.registerConstantViolation(this.get("left"), null);
}

@@ -75,4 +83,4 @@ }

enter: function enter(node, parent, scope, state) {
if (t.isFunctionDeclaration(node) || t.isBlockScoped(node)) {
state.registerDeclaration(node);
if (this.isFunctionDeclaration() || this.isBlockScoped()) {
state.registerDeclaration(this);
} else if (t.isScope(node, parent)) {

@@ -91,10 +99,16 @@ this.skip();

function Scope(block, parentBlock, parent, file) {
function Scope(path, parent, file) {
_classCallCheck(this, Scope);
var cached = path.getData("scope");
if (cached) {
return cached;
} else {}
this.parent = parent;
this.file = parent ? parent.file : file;
this.parentBlock = parentBlock;
this.block = block;
this.parentBlock = path.parent;
this.block = path.node;
this.path = path;

@@ -133,6 +147,3 @@ this.crawl();

var id = this.generateUidIdentifier(name);
this.push({
key: id.name,
id: id
});
this.push({ id: id });
return id;

@@ -146,5 +157,3 @@ };

Scope.prototype.generateUidIdentifier = function generateUidIdentifier(name) {
var id = t.identifier(this.generateUid(name));
this.getFunctionParent().registerBinding("uid", id);
return id;
return t.identifier(this.generateUid(name));
};

@@ -164,3 +173,4 @@

i++;
} while (this.hasBinding(uid) || this.hasGlobal(uid));
} while (this.hasBinding(uid) || this.hasGlobal(uid) || this.hasUid(uid));
this.getFunctionParent().uids[uid] = true;
return uid;

@@ -175,2 +185,15 @@ };

/**
* Description
*/
Scope.prototype.hasUid = function hasUid(name) {
var scope = this;
do {
if (scope.uids[name]) return true;
scope = scope.parent;
} while (scope);
return false;
};
/*

@@ -213,2 +236,7 @@ * Description

add(node.callee);
} else if (t.isObjectExpression(node) || t.isObjectPattern(node)) {
for (var i = 0; i < node.properties.length; i++) {
var prop = node.properties[i];
add(prop.key || prop.argument);
}
}

@@ -229,4 +257,4 @@ });

Scope.prototype.generateTempBasedOnNode = function generateTempBasedOnNode(node) {
if (t.isThisExpression(node)) {
Scope.prototype.generateMemoisedReference = function generateMemoisedReference(node, dontPush) {
if (t.isThisExpression(node) || t.isSuper(node)) {
return null;

@@ -240,6 +268,3 @@ }

var id = this.generateUidBasedOnNode(node);
this.push({
key: id.name,
id: id
});
if (!dontPush) this.push({ id: id });
return id;

@@ -259,3 +284,3 @@ };

if (local.kind === "let" || local.kind === "const" || local.kind === "module") {
if (local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param") {
throw this.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError);

@@ -272,3 +297,3 @@ }

var info = this.getBindingInfo(oldName);
var info = this.getBinding(oldName);
if (!info) return;

@@ -284,3 +309,3 @@

} else if (t.isDeclaration(node)) {
var ids = t.getBindingIdentifiers(node);
var ids = this.getBindingIdentifiers();
for (var name in ids) {

@@ -307,103 +332,8 @@ if (name === oldName) ids[name].name = newName;

Scope.prototype.inferType = function inferType(node) {
var target;
if (t.isVariableDeclarator(node)) {
target = node.init;
}
if (t.isArrayExpression(target)) {
return t.genericTypeAnnotation(t.identifier("Array"));
}
if (t.isObjectExpression(target)) {
return;
}
if (t.isLiteral(target)) {
return;
}
if (t.isCallExpression(target) && t.isIdentifier(target.callee)) {
var funcInfo = this.getBindingInfo(target.callee.name);
if (funcInfo) {
var funcNode = funcInfo.node;
return !funcInfo.reassigned && t.isFunction(funcNode) && node.returnType;
}
}
if (t.isIdentifier(target)) {
return;
}
};
/**
* Description
*/
Scope.prototype.isTypeGeneric = function isTypeGeneric(name, genericName) {
var info = this.getBindingInfo(name);
if (!info) return false;
var type = info.typeAnnotation;
return t.isGenericTypeAnnotation(type) && t.isIdentifier(type.id, { name: genericName });
};
/**
* Description
*/
Scope.prototype.assignTypeGeneric = function assignTypeGeneric(name, type) {
this.assignType(name, t.genericTypeAnnotation(t.identifier(type)));
};
/**
* Description
*/
Scope.prototype.assignType = function assignType(name, type) {
var info = this.getBindingInfo(name);
if (!info) return;
info.typeAnnotation = type;
};
/**
* Description
*/
Scope.prototype.getTypeAnnotation = function getTypeAnnotation(id, node) {
var info = {
annotation: null,
inferred: false
};
var type;
if (id.typeAnnotation) {
type = id.typeAnnotation;
}
if (!type) {
info.inferred = true;
type = this.inferType(node);
}
if (type) {
if (t.isTypeAnnotation(type)) type = type.typeAnnotation;
info.annotation = type;
}
return info;
};
/**
* Description
*/
Scope.prototype.toArray = function toArray(node, i) {
var file = this.file;
if (t.isIdentifier(node) && this.isTypeGeneric(node.name, "Array")) {
return node;
if (t.isIdentifier(node)) {
var binding = this.getBinding(node.name);
if (binding && binding.isTypeGeneric("Array", { inference: false })) return node;
}

@@ -426,2 +356,3 @@

helperName = "sliced-to-array";
if (this.file.isLoose("es6.forOf")) helperName += "-loose";
}

@@ -435,29 +366,17 @@ return t.callExpression(file.addHelper(helperName), args);

Scope.prototype.refreshDeclaration = function refreshDeclaration(node) {
if (t.isBlockScoped(node)) {
this.getBlockParent().registerDeclaration(node);
} else if (t.isVariableDeclaration(node, { kind: "var" })) {
this.getFunctionParent().registerDeclaration(node);
} else if (node === this.block) {
this.recrawl();
}
};
/**
* Description
*/
Scope.prototype.registerDeclaration = function registerDeclaration(node) {
Scope.prototype.registerDeclaration = function registerDeclaration(path) {
var node = path.node;
if (t.isFunctionDeclaration(node)) {
this.registerBinding("hoisted", node);
this.registerBinding("hoisted", path);
} else if (t.isVariableDeclaration(node)) {
for (var i = 0; i < node.declarations.length; i++) {
this.registerBinding(node.kind, node.declarations[i]);
var declarations = path.get("declarations");
for (var i = 0; i < declarations.length; i++) {
this.registerBinding(node.kind, declarations[i]);
}
} else if (t.isClassDeclaration(node)) {
this.registerBinding("let", node);
this.registerBinding("let", path);
} else if (t.isImportDeclaration(node) || t.isExportDeclaration(node)) {
this.registerBinding("module", node);
this.registerBinding("module", path);
} else {
this.registerBinding("unknown", node);
this.registerBinding("unknown", path);
}

@@ -470,14 +389,12 @@ };

Scope.prototype.registerBindingReassignment = function registerBindingReassignment(node) {
var ids = t.getBindingIdentifiers(node);
Scope.prototype.registerConstantViolation = function registerConstantViolation(left, right) {
var ids = left.getBindingIdentifiers();
for (var name in ids) {
var info = this.getBindingInfo(name);
if (info) {
info.reassigned = true;
if (info.typeAnnotationInferred) {
// destroy the inferred typeAnnotation
info.typeAnnotation = null;
}
var binding = this.getBinding(name);
if (!binding) continue;
if (right) {
var rightType = right.typeAnnotation;
if (rightType && binding.isCompatibleWithType(rightType)) continue;
}
binding.reassign();
}

@@ -490,6 +407,6 @@ };

Scope.prototype.registerBinding = function registerBinding(kind, node) {
Scope.prototype.registerBinding = function registerBinding(kind, path) {
if (!kind) throw new ReferenceError("no `kind`");
var ids = t.getBindingIdentifiers(node);
var ids = path.getBindingIdentifiers();

@@ -501,13 +418,8 @@ for (var name in ids) {

var typeInfo = this.getTypeAnnotation(id, node);
this.bindings[name] = {
typeAnnotationInferred: typeInfo.inferred,
typeAnnotation: typeInfo.annotation,
reassigned: false,
this.bindings[name] = new Binding({
identifier: id,
scope: this,
node: node,
path: path,
kind: kind
};
});
}

@@ -543,3 +455,3 @@ };

Scope.prototype.recrawl = function recrawl() {
this.block._scopeInfo = null;
this.path.setData("scopeInfo", null);
this.crawl();

@@ -553,16 +465,13 @@ };

Scope.prototype.crawl = function crawl() {
var block = this.block;
var i;
var path = this.path;
//
var info = block._scopeInfo;
if (info) {
extend(this, info);
return;
}
var info = this.block._scopeInfo;
if (info) return extend(this, info);
info = block._scopeInfo = {
info = this.block._scopeInfo = {
bindings: object(),
globals: object()
globals: object(),
uids: object()
};

@@ -574,11 +483,10 @@

if (t.isLoop(block)) {
for (i = 0; i < t.FOR_INIT_KEYS.length; i++) {
var node = block[t.FOR_INIT_KEYS[i]];
if (t.isBlockScoped(node)) this.registerBinding("let", node);
if (path.isLoop()) {
for (var i = 0; i < t.FOR_INIT_KEYS.length; i++) {
var node = path.get(t.FOR_INIT_KEYS[i]);
if (node.isBlockScoped()) this.registerBinding("let", node);
}
if (t.isBlockStatement(block.body)) {
block = block.body;
}
var body = path.get("body");
if (body.isBlockStatement()) path = path.get("body");
}

@@ -588,5 +496,5 @@

if (t.isFunctionExpression(block) && block.id) {
if (!t.isProperty(this.parentBlock, { method: true })) {
this.registerBinding("var", block.id);
if (path.isFunctionExpression() && path.has("id")) {
if (!t.isProperty(path.parent, { method: true })) {
this.registerBinding("var", path.get("id"));
}

@@ -597,4 +505,4 @@ }

if (t.isClass(block) && block.id) {
this.registerBinding("var", block.id);
if (path.isClass() && path.has("id")) {
this.registerBinding("var", path.get("id"));
}

@@ -604,7 +512,8 @@

if (t.isFunction(block)) {
for (i = 0; i < block.params.length; i++) {
this.registerBinding("param", block.params[i]);
if (path.isFunction()) {
var params = path.get("params");
for (var i = 0; i < params.length; i++) {
this.registerBinding("param", params[i]);
}
this.traverse(block.body, blockVariableVisitor, this);
this.traverse(path.get("body").node, blockVariableVisitor, this);
}

@@ -614,4 +523,4 @@

if (t.isBlockStatement(block) || t.isProgram(block)) {
this.traverse(block, blockVariableVisitor, this);
if (path.isBlockStatement() || path.isProgram()) {
this.traverse(path.node, blockVariableVisitor, this);
}

@@ -621,4 +530,4 @@

if (t.isCatchClause(block)) {
this.registerBinding("let", block.param);
if (path.isCatchClause()) {
this.registerBinding("let", path.get("param"));
}

@@ -628,4 +537,4 @@

if (t.isComprehensionExpression(block)) {
this.registerBinding("let", block);
if (path.isComprehensionExpression()) {
this.registerBinding("let", path);
}

@@ -635,5 +544,5 @@

if (t.isProgram(block) || t.isFunction(block)) {
this.traverse(block, functionVariableVisitor, {
blockId: block.id,
if (path.isProgram() || path.isFunction()) {
this.traverse(path.node, functionVariableVisitor, {
blockId: path.get("id").node,
scope: this

@@ -645,4 +554,4 @@ });

if (t.isProgram(block)) {
this.traverse(block, programReferenceVisitor, this);
if (path.isProgram()) {
this.traverse(path.node, programReferenceVisitor, this);
}

@@ -750,3 +659,3 @@ };

Scope.prototype.getBindingInfo = function getBindingInfo(name) {
Scope.prototype.getBinding = function getBinding(name) {
var scope = this;

@@ -773,3 +682,3 @@

Scope.prototype.getBindingIdentifier = function getBindingIdentifier(name) {
var info = this.getBindingInfo(name);
var info = this.getBinding(name);
return info && info.identifier;

@@ -791,40 +700,2 @@ };

Scope.prototype.getOwnImmutableBindingValue = function getOwnImmutableBindingValue(name) {
return this._immutableBindingInfoToValue(this.getOwnBindingInfo(name));
};
/**
* Description
*/
Scope.prototype.getImmutableBindingValue = function getImmutableBindingValue(name) {
return this._immutableBindingInfoToValue(this.getBindingInfo(name));
};
Scope.prototype._immutableBindingInfoToValue = function _immutableBindingInfoToValue(info) {
if (!info) return;
// can't guarantee this value is the same
if (info.reassigned) return;
var node = info.node;
if (t.isVariableDeclarator(node)) {
if (t.isIdentifier(node.id)) {
node = node.init;
} else {
// otherwise it's probably a destructuring like:
// var { foo } = "foo";
return;
}
}
if (t.isImmutable(node)) {
return node;
}
};
/**
* Description
*/
Scope.prototype.hasOwnBinding = function hasOwnBinding(name) {

@@ -842,2 +713,3 @@ return !!this.getOwnBindingInfo(name);

if (this.parentHasBinding(name)) return true;
if (this.uids[name]) return true;
if (includes(Scope.globals, name)) return true;

@@ -869,3 +741,3 @@ if (includes(Scope.contextVariables, name)) return true;

Scope.prototype.removeBinding = function removeBinding(name) {
var info = this.getBindingInfo(name);
var info = this.getBinding(name);
if (info) info.scope.removeOwnBinding(name);

@@ -877,2 +749,4 @@ };

module.exports = Scope;
module.exports = Scope;
//path.setData("scope", this);
{
"ExpressionStatement": ["Statement"],
"BreakStatement": ["Statement"],
"ContinueStatement": ["Statement"],
"DebuggerStatement": ["Statement"],
"DoWhileStatement": ["Statement", "Loop", "While", "Scopable"],
"IfStatement": ["Statement"],
"ReturnStatement": ["Statement"],
"SwitchStatement": ["Statement"],
"ThrowStatement": ["Statement"],
"TryStatement": ["Statement"],
"WhileStatement": ["Statement", "Loop", "While", "Scopable"],
"WithStatement": ["Statement"],
"EmptyStatement": ["Statement"],
"LabeledStatement": ["Statement"],
"VariableDeclaration": ["Statement", "Declaration"],
"ExportDeclaration": ["Statement", "Declaration", "ModuleDeclaration"],
"ImportDeclaration": ["Statement", "Declaration", "ModuleDeclaration"],
"PrivateDeclaration": ["Statement", "Declaration"],
"ExpressionStatement": ["Statement"],
"BreakStatement": ["Statement"],
"ContinueStatement": ["Statement"],
"DebuggerStatement": ["Statement"],
"DoWhileStatement": ["Statement", "Loop", "While", "Scopable"],
"IfStatement": ["Statement"],
"ReturnStatement": ["Statement"],
"SwitchStatement": ["Statement"],
"ThrowStatement": ["Statement"],
"TryStatement": ["Statement"],
"WhileStatement": ["Statement", "Loop", "While", "Scopable"],
"WithStatement": ["Statement"],
"EmptyStatement": ["Statement"],
"LabeledStatement": ["Statement"],
"VariableDeclaration": ["Statement", "Declaration"],
"ExportAllDeclaration": ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
"ExportDefaultDeclaration": ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
"ExportNamedDeclaration": ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
"ImportDeclaration": ["Statement", "Declaration", "ModuleDeclaration"],

@@ -55,10 +56,10 @@ "ArrowFunctionExpression": ["Scopable", "Function", "Expression"],

"AwaitExpression": ["Expression"],
"BindFunctionExpression": ["Expression"],
"BindMemberExpression": ["Expression"],
"CallExpression": ["Expression"],
"ComprehensionExpression": ["Expression", "Scopable"],
"ConditionalExpression": ["Expression"],
"DoExpression": ["Expression"],
"Identifier": ["Expression"],
"Literal": ["Expression"],
"MemberExpression": ["Expression"],
"MetaProperty": ["Expression"],
"NewExpression": ["Expression"],

@@ -69,4 +70,4 @@ "ObjectExpression": ["Expression"],

"ThisExpression": ["Expression"],
"Super": ["Expression"],
"UpdateExpression": ["Expression"],
"VirtualPropertyExpression": ["Expression"],
"JSXEmptyExpression": ["Expression"],

@@ -73,0 +74,0 @@ "JSXMemberExpression": ["Expression"],

@@ -52,3 +52,4 @@ {

"body": null,
"generator": false
"generator": false,
"async": false
},

@@ -84,4 +85,4 @@

"ImportSpecifier": {
"id": null,
"name": null
"local": null,
"imported": null
},

@@ -88,0 +89,0 @@

@@ -78,3 +78,3 @@ "use strict";

function toComputedKey(node) {
var key = arguments[1] === undefined ? node.key : arguments[1];
var key = arguments[1] === undefined ? node.key || node.property : arguments[1];
return (function () {

@@ -89,28 +89,70 @@ if (!node.computed) {

function toSequenceExpression(nodes, scope) {
var exprs = [];
var declars = [];
var bailed = false;
each(nodes, function (node) {
if (t.isExpression(node)) {
exprs.push(node);
}if (t.isExpressionStatement(node)) {
exprs.push(node.expression);
} else if (t.isVariableDeclaration(node)) {
each(node.declarations, function (declar) {
scope.push({
kind: node.kind,
id: declar.id
var result = convert(nodes);
if (bailed) return;
for (var i = 0; i < declars.length; i++) {
scope.push(declars[i]);
}
return result;
function convert(nodes) {
var ensureLastUndefined = false;
var exprs = [];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (t.isExpression(node)) {
exprs.push(node);
} else if (t.isExpressionStatement(node)) {
exprs.push(node.expression);
} else if (t.isVariableDeclaration(node)) {
if (node.kind !== "var") return bailed = true; // bailed
each(node.declarations, function (declar) {
var bindings = t.getBindingIdentifiers(declar);
for (var key in bindings) {
declars.push({
kind: node.kind,
id: bindings[key]
});
}
if (declar.init) {
exprs.push(t.assignmentExpression("=", declar.id, declar.init));
}
});
exprs.push(t.assignmentExpression("=", declar.id, declar.init));
});
} else if (t.isIfStatement(node)) {
return t.conditionalExpression(node.test, node.consequent ? t.toSequenceExpression([node.consequent]) : t.identifier("undefined"), node.alternate ? t.toSequenceExpression([node.alternate]) : t.identifier("undefined"));
} else if (t.isBlockStatement(node)) {
return t.toSequenceExpression(node.body);
ensureLastUndefined = true;
continue;
} else if (t.isIfStatement(node)) {
var consequent = node.consequent ? convert([node.consequent]) : t.identifier("undefined");
var alternate = node.alternate ? convert([node.alternate]) : t.identifier("undefined");
if (!consequent || !alternate) return bailed = true;
exprs.push(t.conditionalExpression(node.test, consequent, alternate));
} else if (t.isBlockStatement(node)) {
exprs.push(convert(node.body));
} else {
// bailed, we can't understand this
return bailed = true;
}
ensureLastUndefined = false;
}
});
if (exprs.length === 1) {
return exprs[0];
} else {
return t.sequenceExpression(exprs);
if (ensureLastUndefined) {
exprs.push(t.identifier("undefined"));
}
//
if (exprs.length === 1) {
return exprs[0];
} else {
return t.sequenceExpression(exprs);
}
}

@@ -117,0 +159,0 @@ }

@@ -13,2 +13,3 @@ "use strict";

exports.is = is;
exports.isType = isType;

@@ -154,21 +155,19 @@ /*

var typeMatches = type === node.type;
var matches = isType(node.type, type);
if (!matches) return false;
if (!typeMatches && !skipAliasCheck) {
var aliases = t.FLIPPED_ALIAS_KEYS[type];
if (typeof aliases !== "undefined") {
typeMatches = aliases.indexOf(node.type) > -1;
}
if (typeof opts === "undefined") {
return true;
} else {
return t.shallowEqual(node, opts);
}
}
if (!typeMatches) {
return false;
}
function isType(nodeType, targetType) {
if (nodeType === targetType) return true;
if (typeof opts !== "undefined") {
return t.shallowEqual(node, opts);
}
var aliases = t.FLIPPED_ALIAS_KEYS[targetType];
if (aliases) return aliases.indexOf(nodeType) > -1;
return true;
return false;
}

@@ -321,5 +320,7 @@

function inheritsComments(child, parent) {
each(COMMENT_KEYS, function (key) {
child[key] = uniq(compact([].concat(child[key], parent[key])));
});
if (child && parent) {
each(COMMENT_KEYS, function (key) {
child[key] = uniq(compact([].concat(child[key], parent[key])));
});
}
return child;

@@ -329,2 +330,4 @@ }

function inherits(child, parent) {
if (!child || !parent) return child;
child._declarations = parent._declarations;

@@ -348,5 +351,4 @@ child._scopeInfo = parent._scopeInfo;

exports.__esModule = true;
assign(t, require("./evaluators"));
assign(t, require("./retrievers"));
assign(t, require("./validators"));
assign(t, require("./converters"));

@@ -19,14 +19,2 @@ "use strict";

exports.getLastStatements = getLastStatements;
/**
* Description
*/
exports.getSpecifierName = getSpecifierName;
/**
* Description
*/
exports.getSpecifierId = getSpecifierId;
exports.__esModule = true;

@@ -50,4 +38,2 @@

ids[id.name] = id;
} else if (t.isImportSpecifier(id)) {
search.push(id.name || id.id);
} else if (t.isExportDeclaration(id)) {

@@ -71,3 +57,5 @@ if (t.isDeclaration(node.declaration)) {

AssignmentExpression: ["left"],
ImportBatchSpecifier: ["name"],
ImportSpecifier: ["local"],
ImportNamespaceSpecifier: ["local"],
ImportDefaultSpecifier: ["local"],
VariableDeclarator: ["id"],

@@ -85,3 +73,2 @@ FunctionDeclaration: ["id"],

AssignmentPattern: ["left"],
PrivateDeclaration: ["declarations"],
ComprehensionExpression: ["blocks"],

@@ -107,3 +94,3 @@ ImportDeclaration: ["specifiers"],

add(node.body[node.body.length - 1]);
} else if (node) {
} else if (t.isLoop()) {} else if (node) {
nodes.push(node);

@@ -113,14 +100,2 @@ }

return nodes;
}
function getSpecifierName(specifier) {
return specifier.name || specifier.id;
}
function getSpecifierId(specifier) {
if (specifier["default"]) {
return t.identifier("default");
} else {
return specifier.id;
}
}

@@ -70,100 +70,93 @@ "use strict";

function isReferenced(node, parent) {
// yes: PARENT[NODE]
// yes: NODE.child
// no: parent.CHILD
if (t.isMemberExpression(parent)) {
if (parent.property === node && parent.computed) {
return true;
} else if (parent.object === node) {
return true;
} else {
switch (parent.type) {
// yes: PARENT[NODE]
// yes: NODE.child
// no: parent.CHILD
case "MemberExpression":
if (parent.property === node && parent.computed) {
return true;
} else if (parent.object === node) {
return true;
} else {
return false;
}
// no: new.NODE
// no: NODE.target
case "MetaProperty":
return false;
}
}
// yes: { [NODE]: "" }
// no: { NODE: "" }
if (t.isProperty(parent) && parent.key === node) {
return parent.computed;
}
// yes: { [NODE]: "" }
// no: { NODE: "" }
case "Property":
if (parent.key === node) {
return parent.computed;
}
// no: var NODE = init;
// yes: var id = NODE;
if (t.isVariableDeclarator(parent)) {
return parent.id !== node;
}
// no: var NODE = init;
// yes: var id = NODE;
case "VariableDeclarator":
return parent.id !== node;
// no: function NODE() {}
// no: function foo(NODE) {}
if (t.isFunction(parent)) {
for (var i = 0; i < parent.params.length; i++) {
var param = parent.params[i];
if (param === node) return false;
}
// no: function NODE() {}
// no: function foo(NODE) {}
case "ArrowFunctionExpression":
case "FunctionDeclaration":
case "FunctionExpression":
for (var i = 0; i < parent.params.length; i++) {
var param = parent.params[i];
if (param === node) return false;
}
return parent.id !== node;
}
return parent.id !== node;
// no: export { foo as NODE };
if (t.isExportSpecifier(parent, { name: node })) {
return false;
}
// no: export { foo as NODE };
case "ExportSpecifier":
return parent.exported !== node;
// no: import { NODE as foo } from "foo";
if (t.isImportSpecifier(parent, { id: node })) {
return false;
}
// no: import { NODE as foo } from "foo";
case "ImportSpecifier":
return parent.imported !== node;
// no: class NODE {}
if (t.isClass(parent)) {
return parent.id !== node;
}
// no: class NODE {}
case "ClassDeclaration":
case "ClassExpression":
return parent.id !== node;
// yes: class { [NODE](){} }
if (t.isMethodDefinition(parent)) {
return parent.key === node && parent.computed;
}
// yes: class { [NODE](){} }
case "MethodDefinition":
return parent.key === node && parent.computed;
// no: NODE: for (;;) {}
if (t.isLabeledStatement(parent)) {
return false;
}
// no: NODE: for (;;) {}
case "LabeledStatement":
return false;
// no: try {} catch (NODE) {}
if (t.isCatchClause(parent)) {
return parent.param !== node;
}
// no: try {} catch (NODE) {}
case "CatchClause":
return parent.param !== node;
// no: function foo(...NODE) {}
if (t.isRestElement(parent)) {
return false;
}
// no: function foo(...NODE) {}
case "RestElement":
return false;
// no: [NODE = foo] = [];
// yes: [foo = NODE] = [];
if (t.isAssignmentPattern(parent)) {
return parent.right === node;
}
// no: [NODE = foo] = [];
// yes: [foo = NODE] = [];
case "AssignmentPattern":
return parent.right === node;
// no: [NODE] = [];
// no: ({ NODE }) = [];
if (t.isPattern(parent)) {
return false;
}
// no: [NODE] = [];
// no: ({ NODE }) = [];
case "ObjectPattern":
case "ArrayPattern":
return false;
// no: import NODE from "bar";
if (t.isImportSpecifier(parent)) {
return false;
}
// no: import NODE from "bar";
case "ImportSpecifier":
return false;
// no: import * as NODE from "foo";
if (t.isImportBatchSpecifier(parent)) {
return false;
// no: import * as NODE from "foo";
case "ImportNamespaceSpecifier":
return false;
}
// no: class Foo { private NODE; }
if (t.isPrivateDeclaration(parent)) {
return false;
}
return true;

@@ -193,3 +186,3 @@ }

function isSpecifierDefault(specifier) {
return specifier["default"] || t.isIdentifier(specifier.id) && specifier.id.name === "default";
return t.isImportDefaultSpecifier(specifier) || t.isIdentifier(specifier.imported || specifier.exported, { name: "default" });
}

@@ -196,0 +189,0 @@

{
"ArrayExpression": ["elements"],
"ArrayPattern": ["elements", "typeAnnotation"],
"ArrowFunctionExpression": ["params", "defaults", "rest", "body", "returnType"],
"ArrowFunctionExpression": ["params", "body", "returnType"],
"AssignmentExpression": ["left", "right"],

@@ -9,4 +9,2 @@ "AssignmentPattern": ["left", "right"],

"BinaryExpression": ["left", "right"],
"BindFunctionExpression": ["callee", "arguments"],
"BindMemberExpression": ["object", "property", "arguments"],
"BlockStatement": ["body"],

@@ -23,8 +21,11 @@ "BreakStatement": ["label"],

"ContinueStatement": ["label"],
"Decorator": ["expression"],
"DebuggerStatement": [],
"DoWhileStatement": ["body", "test"],
"DoExpression": ["body"],
"EmptyStatement": [],
"ExportBatchSpecifier": [],
"ExportDeclaration": ["declaration", "specifiers", "source"],
"ExportSpecifier": ["id", "name"],
"ExportAllDeclaration": ["source"],
"ExportDefaultDeclaration": ["declaration"],
"ExportNamedDeclaration": ["declaration", "specifiers", "source"],
"ExportSpecifier": ["local", "exported"],
"ExpressionStatement": ["expression"],

@@ -35,9 +36,10 @@ "File": ["program"],

"ForStatement": ["init", "test", "update", "body"],
"FunctionDeclaration": ["id", "params", "defaults", "rest", "body", "returnType", "typeParameters"],
"FunctionExpression": ["id", "params", "defaults", "rest", "body", "returnType", "typeParameters"],
"FunctionDeclaration": ["id", "params", "body", "returnType", "typeParameters"],
"FunctionExpression": ["id", "params", "body", "returnType", "typeParameters"],
"Identifier": ["typeAnnotation"],
"IfStatement": ["test", "consequent", "alternate"],
"ImportBatchSpecifier": ["id"],
"ImportDefaultSpecifier": ["local"],
"ImportNamespaceSpecifier": ["local"],
"ImportDeclaration": ["specifiers", "source"],
"ImportSpecifier": ["id", "name"],
"ImportSpecifier": ["imported", "local"],
"LabeledStatement": ["label", "body"],

@@ -47,2 +49,3 @@ "Literal": [],

"MemberExpression": ["object", "property"],
"MetaProperty": ["meta", "property"],
"MethodDefinition": ["key", "value"],

@@ -52,3 +55,2 @@ "NewExpression": ["callee", "arguments"],

"ObjectPattern": ["properties", "typeAnnotation"],
"PrivateDeclaration": ["declarations"],
"Program": ["body"],

@@ -61,2 +63,3 @@ "Property": ["key", "value"],

"SpreadProperty": ["argument"],
"Super": [],
"SwitchCase": ["test", "consequent"],

@@ -74,3 +77,2 @@ "SwitchStatement": ["discriminant", "cases"],

"VariableDeclarator": ["id", "init"],
"VirtualPropertyExpression": ["object", "property"],
"WhileStatement": ["test", "body"],

@@ -103,3 +105,3 @@ "WithStatement": ["object", "body"],

"TypeAnnotation": ["typeAnnotation"],
"TypeCastExpression": ["expression"],
"TypeCastExpression": ["expression", "typeAnnotation"],
"TypeParameterDeclaration": ["params"],

@@ -106,0 +108,0 @@ "TypeParameterInstantiation": ["params"],

@@ -22,2 +22,4 @@ "use strict";

var escapeRegExp = _interopRequire(require("lodash/string/escapeRegExp"));
var buildDebug = _interopRequire(require("debug/node"));

@@ -31,2 +33,4 @@

var minimatch = _interopRequire(require("minimatch"));
var contains = _interopRequire(require("lodash/collection/contains"));

@@ -84,4 +88,4 @@

if (!val) return new RegExp(/.^/);
if (Array.isArray(val)) val = val.join("|");
if (isString(val)) return new RegExp(val);
if (Array.isArray(val)) val = new RegExp(val.map(escapeRegExp).join("|"), "i");
if (isString(val)) return minimatch.makeRe(val, { nocase: true });
if (isRegExp(val)) return val;

@@ -91,7 +95,12 @@ throw new TypeError("illegal type for regexify");

function arrayify(val) {
function arrayify(val, mapFn) {
if (!val) return [];
if (isBoolean(val)) return [val];
if (isString(val)) return list(val);
if (Array.isArray(val)) return val;
if (isBoolean(val)) return arrayify([val], mapFn);
if (isString(val)) return arrayify(list(val), mapFn);
if (Array.isArray(val)) {
if (mapFn) val = val.map(mapFn);
return val;
}
throw new TypeError("illegal type for arrayify");

@@ -113,3 +122,3 @@ }

this.skip();
return nodes[node.name];
this.replaceInline(nodes[node.name]);
}

@@ -145,3 +154,3 @@ }

function parseTemplate(loc, code) {
var ast = parse({ filename: loc }, code).program;
var ast = parse({ filename: loc, looseModules: true }, code).program;
ast = traverse.removeProperties(ast);

@@ -148,0 +157,0 @@ return ast;

{
"name": "babel-core",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "4.7.16",
"version": "5.0.0-beta2",
"author": "Sebastian McKenzie <sebmck@gmail.com>",

@@ -26,3 +26,2 @@ "homepage": "https://babeljs.io/",

"dependencies": {
"acorn-babel": "0.11.1-38",
"ast-types": "~0.7.0",

@@ -44,2 +43,3 @@ "chalk": "^1.0.0",

"lodash": "^3.2.0",
"minimatch": "^2.0.3",
"output-file-sync": "^1.1.0",

@@ -46,0 +46,0 @@ "path-is-absolute": "^1.0.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc