Compare commits

...

52 Commits

Author SHA1 Message Date
Sebastian McKenzie
55dfb423ee v3.6.4 2015-02-14 13:26:59 +11:00
Sebastian McKenzie
9d1bc4817d fix flow module type stripping 2015-02-14 13:24:39 +11:00
Sebastian McKenzie
fc8666e7a4 3.6.3 2015-02-14 13:22:18 +11:00
Sebastian McKenzie
07b6881d67 add support for flow type casts and module types 2015-02-14 13:22:13 +11:00
Sebastian McKenzie
1f208a06db v3.6.3 2015-02-14 13:01:17 +11:00
Sebastian McKenzie
b5c9c84542 update bin/6to5 tests to reflect new source location 2015-02-14 12:59:31 +11:00
Sebastian McKenzie
492555bb4e fix linting errors 2015-02-14 12:54:44 +11:00
Sebastian McKenzie
53d88c0f63 upgrade acorn-6to5 2015-02-14 12:53:54 +11:00
Sebastian McKenzie
8a5da57162 use default property on 6to5-runtime modules - fixes #774 2015-02-14 00:59:34 +11:00
Sebastian McKenzie
1627e2f47e use sourceFileName instead of sourceMapName - fixes #775 2015-02-14 00:44:32 +11:00
Sebastian McKenzie
e195d6ca55 use relative location when generating the sourceMapName in bin/6to5 for directories - fixes #775 2015-02-13 23:08:47 +11:00
Sebastian McKenzie
71d5d4fb2c remove MemberExpression from binding identifier collection 2015-02-13 21:10:23 +11:00
Sebastian McKenzie
dfe13cda0d 3.6.2 2015-02-13 21:08:14 +11:00
Sebastian McKenzie
a4c6660d21 v3.6.2 2015-02-13 21:07:45 +11:00
Sebastian McKenzie
9676666e7c 3.6.1 2015-02-13 21:05:56 +11:00
Sebastian McKenzie
388133642d add support for UnaryExpression to getBindingIdentifiers and add it as a reassignment in the scope tracking 2015-02-13 21:05:52 +11:00
Sebastian McKenzie
23b5eeb72f use Symbol.iterator in for symbol detection and add the conversion of it to the selfContained transformer - @zloirock 2015-02-13 21:05:21 +11:00
Sebastian McKenzie
db36c3a7c2 v3.6.1 2015-02-13 20:50:37 +11:00
Sebastian McKenzie
e841b88cbc fix 6to5-node test collisions 2015-02-13 20:48:52 +11:00
Sebastian McKenzie
3d874f2479 update sliceToArray helper, again... 2015-02-13 20:45:43 +11:00
Sebastian McKenzie
228719102a update sliceToArray tests 2015-02-13 20:39:37 +11:00
Sebastian McKenzie
c6ce1a248c better slicedToArray helper 2015-02-13 20:38:28 +11:00
Sebastian McKenzie
ba9b85f64b only use functions returnType if it hasn't been reassigned 2015-02-13 20:36:43 +11:00
Sebastian McKenzie
56c868efee fix incorrect generateUid references in File 2015-02-13 18:27:53 +11:00
Sebastian McKenzie
1f3c3832ba fix linting errors 2015-02-13 18:25:34 +11:00
Sebastian McKenzie
3b04a8c648 fix linting errors 2015-02-13 18:24:24 +11:00
Sebastian McKenzie
2270057b54 add 3.6.1 changelog 2015-02-13 18:23:46 +11:00
Sebastian McKenzie
c3206aa9a4 move File::generateUid to Scope and add return type inferrence 2015-02-13 18:21:28 +11:00
Sebastian McKenzie
1912d1b26a remove ExportSpecifier from t.getBindingIdentifiers as it has none 2015-02-13 18:19:27 +11:00
Sebastian McKenzie
9208e7e594 update common standard import test 2015-02-13 17:47:46 +11:00
Sebastian McKenzie
ce332b3384 fix module binding resolution - fixes #762 2015-02-13 17:37:35 +11:00
Sebastian McKenzie
a567531f77 ignore member expressions in constants transformer - fixes #770 2015-02-13 17:18:42 +11:00
Sebastian McKenzie
9cce72def0 update tests that use the toSlicedArray helper 2015-02-13 17:04:18 +11:00
Sebastian McKenzie
2d8581c6dc Merge branch 'master' of github.com:6to5/6to5
Conflicts:
	lib/6to5/transformation/transformers/minification/dead-code-elimination.js
2015-02-13 16:54:09 +11:00
Sebastian McKenzie
14a000396a add error message to the sliced-to-array helper on a non-iterable param - fixes #766 2015-02-13 16:50:03 +11:00
Sebastian McKenzie
4c41f5a22f bump acorn-6to5 and 6to5 devDependency 2015-02-13 15:09:28 +11:00
Sebastian McKenzie
6be2a6e02a add extra note to minification dead code elimination transformer 2015-02-13 15:09:17 +11:00
Sebastian McKenzie
0a4fc16ca0 add type inferrence that expires when a binding is reassigned 2015-02-13 15:08:58 +11:00
Sebastian McKenzie
25d8377411 normalise JSX attribute strings 2015-02-13 15:08:39 +11:00
Brian Donovan
14267a788d Fix a typo. 2015-02-12 19:12:09 -08:00
Sebastian McKenzie
ba5c5760b1 Merge pull request #769 from 6to5/if-truthy-minification-returns-consequent
Return the consequent if the test is truthy.
2015-02-13 14:08:32 +11:00
Brian Donovan
49904b3ab3 Fix a small grammar issue. 2015-02-12 19:07:54 -08:00
Brian Donovan
a212f035e4 Return the consequent if the test is truthy. 2015-02-12 19:06:06 -08:00
Brian Donovan
ea471a6a17 Fix a few typos. 2015-02-12 18:47:08 -08:00
Brian Donovan
f5bae0b696 Remove redundant variable. 2015-02-12 18:46:53 -08:00
Brian Donovan
9ec9e13aeb Update the jsdoc to indicate that key is optional. 2015-02-12 18:36:36 -08:00
Brian Donovan
0b042b2681 Use the posessive form of "its", not a contraction of "it is". 2015-02-12 18:36:02 -08:00
Brian Donovan
83b4d12884 Correct a jsdoc comment parameter name. 2015-02-12 18:35:35 -08:00
Brian Donovan
98d555498d Remove unused variable. 2015-02-12 18:29:14 -08:00
Sebastian McKenzie
fdc05cb977 Merge pull request #767 from 6to5/templates-should-not-recurse
Ensure that templates do not recurse.
2015-02-13 11:13:30 +11:00
Brian Donovan
928ebda5bc Ensure that templates do not recurse.
Closes #765.
2015-02-12 16:10:13 -08:00
Sebastian McKenzie
0a2003af66 3.6.0 2015-02-12 21:59:37 +11:00
68 changed files with 299 additions and 168 deletions

View File

@@ -11,6 +11,31 @@
_Note: Gaps between patch versions are faulty/broken releases._
## 3.6.4
* **New Feature**
* Add support for flow type casts and module types.
## 3.6.3
* **Internal**
* Upgrade `acorn-6to5`.
## 3.6.2
* **Polish**
* Use better iterator detection in `slicedToArray` helper and add support for it to the `selfContained` transformer.
## 3.6.1
* **Bug Fix**
* Multiline JSX string literals are now supported.
* Fix scope tracking import specifiers incorrectly.
* Fix templates incorrectly recursing into their replacements.
* **Internal**
* Type inferrence now extends to function return types.
* Upgrade `acorn-6to5`.
## 3.6.0
* **New Feature**
@@ -19,6 +44,7 @@ _Note: Gaps between patch versions are faulty/broken releases._
* Completely reimplemented scope tracking, can now track types and optimise certain helpers based on it.
* Extremely fast tail recursion optimisation implementation. Thanks [@RReverser](https://github.com/RReverser)!
* **Internal**
* `kexec` has been removed as an optional dependency and must be user installed.
* Upgrade `regenerator-6to5`.
* Upgrade `acorn-6to5`.
* Upgrade `core-js`.

View File

@@ -16,7 +16,9 @@ module.exports = function (commander, filenames, opts) {
var dest = path.join(commander.outDir, relative);
var data = util.compile(src, { sourceMapName: dest });
var data = util.compile(src, {
sourceFileName: path.relative(dest + "/..", src)
});
if (commander.sourceMaps) {
var mapLoc = dest + ".map";

View File

@@ -21,7 +21,7 @@ exports.addSourceMappingUrl = function (code, loc) {
};
exports.transform = function (filename, code, opts) {
opts = _.extend(opts || {}, index.opts);
opts = _.defaults(opts || {}, index.opts);
opts.filename = filename;
var result;

View File

@@ -30,6 +30,7 @@ exports.ObjectTypeIndexer =
exports.ObjectTypeProperty =
exports.QualifiedTypeIdentifier =
exports.UnionTypeAnnotation =
exports.TypeCastExpression =
exports.VoidTypeAnnotation = function () {
// todo: implement these once we have a `--keep-types` option
};

View File

@@ -18,9 +18,10 @@ var each = require("lodash/collection/each");
var t = require("../types");
function File(opts) {
this.dynamicImportIds = {};
this.dynamicImported = [];
this.dynamicImports = [];
this.dynamicImportedNoDefault = [];
this.dynamicImportIds = {};
this.dynamicImported = [];
this.dynamicImports = [];
this.dynamicData = {};
this.data = {};
@@ -273,17 +274,19 @@ File.prototype.get = function (key) {
}
};
File.prototype.addImport = function (source, name) {
File.prototype.addImport = function (source, name, noDefault) {
name = name || source;
var id = this.dynamicImportIds[name];
if (!id) {
id = this.dynamicImportIds[name] = this.generateUidIdentifier(name);
id = this.dynamicImportIds[name] = this.scope.generateUidIdentifier(name);
var specifiers = [t.importSpecifier(t.identifier("default"), id)];
var declar = t.importDeclaration(specifiers, t.literal(source));
declar._blockHoist = 3;
this.dynamicImported.push(declar);
if (noDefault) this.dynamicImportedNoDefault.push(declar);
this.moduleFormatter.importSpecifier(specifiers[0], declar, this.dynamicImports);
}
@@ -312,7 +315,7 @@ File.prototype.addHelper = function (name) {
} else {
var ref = util.template(name);
ref._compact = true;
var uid = this.generateUidIdentifier(name);
var uid = this.scope.generateUidIdentifier(name);
this.scope.push({
key: name,
id: uid,
@@ -443,30 +446,3 @@ File.prototype.generate = function () {
return result;
};
File.prototype.generateUid = function (name, scope) {
name = t.toIdentifier(name).replace(/^_+/, "");
scope = scope || this.scope;
var uid;
var i = 0;
do {
uid = this._generateUid(name, i);
i++;
} while (scope.hasBinding(uid) || scope.hasGlobal(uid));
return uid;
};
File.prototype.generateUidIdentifier = function (name, scope) {
scope = scope || this.scope;
var id = t.identifier(this.generateUid(name, scope));
scope.getFunctionParent().registerBinding("uid", id);
return id;
};
File.prototype._generateUid = function (name, i) {
var id = name;
if (i > 1) id += i;
return "_" + id;
};

View File

@@ -46,6 +46,11 @@ module.exports = function (exports, opts) {
exports.JSXAttribute = {
exit: function (node) {
var value = node.value || t.literal(true);
if (t.isLiteral(value) && isString(value.value)) {
value.value = value.value.replace(/\n\s+/g, " ");
}
return t.inherits(t.property("init", node.name, value), node);
}
};

View File

@@ -143,7 +143,7 @@ ReplaceSupers.prototype.getThisReference = function () {
if (this.topLevelThisReference) {
return this.topLevelThisReference;
} else {
var ref = this.topLevelThisReference = this.file.generateUidIdentifier("this");
var ref = this.topLevelThisReference = this.scope.generateUidIdentifier("this");
this.methodNode.value.body.body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(this.topLevelThisReference, t.thisExpression())
]));

View File

@@ -9,8 +9,9 @@ var util = require("../../util");
var t = require("../../types");
function DefaultFormatter(file) {
this.file = file;
this.ids = object();
this.scope = file.scope;
this.file = file;
this.ids = object();
this.hasNonDefaultExports = false;
@@ -212,9 +213,6 @@ DefaultFormatter.prototype.checkExportIdentifier = function (node) {
};
DefaultFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
var inherits = false;
if (node.specifiers.length === 1) inherits = node;
if (node.source) {
var ref = this.getExternalReference(node, nodes);

View File

@@ -4,10 +4,10 @@ module.exports = AMDFormatter;
var DefaultFormatter = require("./_default");
var CommonFormatter = require("./common");
var util = require("../../util");
var t = require("../../types");
var includes = require("lodash/collection/includes");
var values = require("lodash/object/values");
var util = require("../../util");
var t = require("../../types");
function AMDFormatter() {
CommonFormatter.apply(this, arguments);
@@ -70,7 +70,7 @@ AMDFormatter.prototype.getModuleName = function () {
};
AMDFormatter.prototype._getExternalReference = function (node) {
return this.file.generateUidIdentifier(node.source.value);
return this.scope.generateUidIdentifier(node.source.value);
};
AMDFormatter.prototype.importDeclaration = function (node) {
@@ -81,12 +81,12 @@ AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
var key = t.getSpecifierName(specifier);
var ref = this.getExternalReference(node);
if (includes(this.file.dynamicImported, node)) {
if (includes(this.file.dynamicImportedNoDefault, node)) {
// Prevent unnecessary renaming of dynamic imports.
this.ids[node.source.value] = ref;
} else if (t.isImportBatchSpecifier(specifier)) {
// import * as bar from "foo";
} else if (t.isSpecifierDefault(specifier) && !this.noInteropRequireImport) {
} 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 {

View File

@@ -31,8 +31,8 @@ CommonJSFormatter.prototype.importSpecifier = function (specifier, node, nodes)
// import foo from "foo";
if (t.isSpecifierDefault(specifier)) {
if (!includes(this.file.dynamicImported, node)) {
if (this.noInteropRequireImport) {
if (!includes(this.file.dynamicImportedNoDefault, node)) {
if (this.noInteropRequireImport || includes(this.file.dynamicImported, node)) {
ref = t.memberExpression(ref, t.identifier("default"));
} else {
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
@@ -93,7 +93,7 @@ CommonJSFormatter.prototype._getExternalReference = function (node, nodes) {
var call = t.callExpression(t.identifier("require"), [node.source]);
if (this.localImportOccurences[source] > 1) {
var uid = this.file.generateUidIdentifier(source);
var uid = this.scope.generateUidIdentifier(source);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(uid, call)
]));

View File

@@ -12,7 +12,7 @@ var each = require("lodash/collection/each");
var map = require("lodash/collection/map");
function SystemFormatter(file) {
this.exportIdentifier = file.generateUidIdentifier("export");
this.exportIdentifier = file.scope.generateUidIdentifier("export");
this.noInteropRequireExport = true;
this.noInteropRequireImport = true;
@@ -29,7 +29,7 @@ SystemFormatter.prototype._addImportSource = function (node, exportNode) {
};
SystemFormatter.prototype.buildExportsWildcard = function (objectIdentifier, node) {
var leftIdentifier = this.file.generateUidIdentifier("key");
var leftIdentifier = this.scope.generateUidIdentifier("key");
var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);
var left = t.variableDeclaration("var", [

View File

@@ -0,0 +1 @@
CORE_ID.$for.isIterable(VALUE);

View File

@@ -0,0 +1,2 @@
var helpers = exports.default = {};
exports.__esModule = true;

View File

@@ -1,12 +1,14 @@
(function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
} 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");
}
});

View File

@@ -55,6 +55,8 @@ Transformer.prototype.normalize = function (transformer) {
return;
}
if (type === "enter" || type === "exit") return;
if (isFunction(fns)) fns = { enter: fns };
if (!isObject(fns)) return;

View File

@@ -35,7 +35,7 @@ exports.ClassExpression = function (node, parent, scope, file) {
* @param {Node} node
* @param {File} file
* @param {Scope} scope
* @param {Boolean} closure
* @param {Boolean} isStatement
*/
function ClassTransformer(node, file, scope, isStatement) {
@@ -99,8 +99,7 @@ ClassTransformer.prototype.run = function () {
closureArgs.push(superName);
if (!t.isIdentifier(superName)) {
var superRef = this.scope.generateUidBasedOnNode(superName, this.file);
superName = superRef;
superName = this.scope.generateUidBasedOnNode(superName, this.file);
}
closureParams.push(superName);
@@ -207,7 +206,7 @@ ClassTransformer.prototype.buildBody = function () {
};
/**
* Push a method to it's respective mutatorMap.
* Push a method to its respective mutatorMap.
*
* @param {Node} node MethodDefinition
*/

View File

@@ -18,7 +18,7 @@ exports.ForOfStatement = function (node, parent, scope, file) {
// inherit comments from the original loop
t.inheritsComments(loop, node);
// ensure that it's a block so we can take all it's statemetns
// ensure that it's a block so we can take all its statements
t.ensureBlock(node);
// add the value declaration to the new loop body

View File

@@ -12,6 +12,7 @@ module.exports = {
"playground.objectGetterMemoization": require("./playground/object-getter-memoization"),
reactCompat: require("./other/react-compat"),
flow: require("./other/flow"),
react: require("./other/react"),
_modules: require("./internal/modules"),
@@ -86,11 +87,12 @@ module.exports = {
_declarations: require("./internal/declarations"),
_aliasFunctions: require("./internal/alias-functions"),
_moduleFormatter: require("./internal/module-formatter"),
"spec.typeofSymbol": require("./spec/typeof-symbol"),
"spec.undefinedToVoid": require("./spec/undefined-to-void"),
_moduleFormatter: require("./internal/module-formatter"),
"es3.propertyLiterals": require("./es3/property-literals"),
"es3.memberExpressionLiterals": require("./es3/member-expression-literals"),

View File

@@ -2,11 +2,9 @@
var useStrict = require("../../helpers/use-strict");
exports.post = function (file) {
exports.Program = function (program, parent, scope, file) {
if (!file.transformers["es6.modules"].canRun()) return;
var program = file.ast.program;
useStrict.wrap(program, function () {
program.body = file.dynamicImports.concat(program.body);
});

View File

@@ -3,7 +3,8 @@ var t = require("../../../types");
exports.optional = true;
exports.ExpressionStatement = function (node) {
// remove consequenceless expressions such as local variables and literals
// remove consequence-less expressions such as local variables and literals
// note: will remove directives
//
// var foo = true; foo; -> var foo = true;
// "foo"; ->
@@ -33,7 +34,7 @@ exports.IfStatement = {
//
if (t.isLiteral(test) && test.value) {
return alternate;
return consequent;
}
// we can check if a test will be falsy 100% and if so we can inline the
@@ -66,8 +67,7 @@ exports.IfStatement = {
// if (foo) {} else { bar; } -> if (!foo) { bar; }
//
if (t.blockStatement(consequent) && !consequent.body.length &&
t.isBlockStatement(alternate) && alternate.body.length) {
if (t.blockStatement(consequent) && !consequent.body.length && t.isBlockStatement(alternate) && alternate.body.length) {
node.consequent = node.alternate;
node.alternate = null;
node.test = t.unaryExpression("!", test, true);

View File

@@ -15,7 +15,7 @@ exports.Function = function (node, parent, scope, file) {
return remapAsyncToGenerator(
node,
t.memberExpression(file.addImport("bluebird"), t.identifier("coroutine")),
t.memberExpression(file.addImport("bluebird", null, true), t.identifier("coroutine")),
scope
);
};

View File

@@ -0,0 +1,13 @@
var t = require("../../../types");
exports.TypeCastExpression = function (node) {
return node.expression;
};
exports.ImportDeclaration = function (node) {
if (node.isType) this.remove();
};
exports.ExportDeclaration = function (node) {
if (t.isTypeAlias(node.declaration)) this.remove();
};

View File

@@ -40,20 +40,34 @@ var astVisitor = {
} else if (t.isCallExpression(node)) {
// arr[Symbol.iterator]() -> _core.$for.getIterator(arr)
if (node.arguments.length) return;
var callee = node.callee;
if (!t.isMemberExpression(callee)) return;
if (!callee.computed) return;
if (node.arguments.length) return false;
if (!t.isMemberExpression(callee)) return false;
if (!callee.computed) return false;
prop = callee.property;
if (!t.isIdentifier(prop.object, { name: "Symbol" })) return;
if (!t.isIdentifier(prop.property, { name: "iterator" })) return;
if (!t.isIdentifier(prop.object, { name: "Symbol" })) return false;
if (!t.isIdentifier(prop.property, { name: "iterator" })) return false;
return util.template("corejs-iterator", {
CORE_ID: file.get("coreIdentifier"),
VALUE: callee.object
});
} else if (t.isBinaryExpression(node)) {
// Symbol.iterator in arr -> core.$for.isIterable(arr)
if (node.operator !== "in") return;
var left = node.left;
if (!t.isMemberExpression(left)) return;
if (!t.isIdentifier(left.object, { name: "Symbol" })) return;
if (!t.isIdentifier(left.property, { name: "iterator" })) return;
return util.template("corejs-is-iterator", {
CORE_ID: file.get("coreIdentifier"),
VALUE: node.right
});
}
}
};
@@ -64,8 +78,8 @@ exports.manipulateOptions = function (opts) {
if (opts.whitelist.length) opts.whitelist.push("es6.modules");
};
exports.post = function (file) {
file.scope.traverse(file.ast, astVisitor, file);
exports.Program = function (node, parent, scope, file) {
scope.traverse(node, astVisitor, file);
};
exports.pre = function (file) {
@@ -83,7 +97,7 @@ exports.pre = function (file) {
};
exports.Identifier = function (node, parent, scope, file) {
if (node.name === "regeneratorRuntime" && t.isReferenced(node, parent)) {
if (t.isReferencedIdentifier(node, parent, { name: "regeneratorRuntime" })) {
return file.get("regeneratorIdentifier");
}
};

View File

@@ -3,8 +3,7 @@
var useStrict = require("../../helpers/use-strict");
var t = require("../../../types");
exports.post = function (file) {
var program = file.ast.program;
exports.Program = function (program) {
if (!useStrict.has(program)) {
program.body.unshift(t.expressionStatement(t.literal("use strict")));
}

View File

@@ -26,7 +26,7 @@ exports.BindMemberExpression = function (node, parent, scope) {
}
};
exports.BindFunctionExpression = function (node, parent, scope, file) {
exports.BindFunctionExpression = function (node, parent, scope) {
var buildCall = function (args) {
var param = scope.generateUidIdentifier("val");
return t.functionExpression(null, [param], t.blockStatement([
@@ -34,7 +34,7 @@ exports.BindFunctionExpression = function (node, parent, scope, file) {
]));
};
var temp = scope.generateTemp(file, "args");
var temp = scope.generateTemp("args");
return t.sequenceExpression([
t.assignmentExpression("=", temp, t.arrayExpression(node.arguments)),

View File

@@ -109,7 +109,7 @@ TraversalPath.prototype.call = function (key) {
if (!node) return;
var opts = this.opts;
var fn = opts[key];
var fn = opts[key] || opts;
if (opts[node.type]) fn = opts[node.type][key] || fn;
var replacement = fn.call(this, node, this.parent, this.scope, this.state);

View File

@@ -50,12 +50,11 @@ Scope.prototype.traverse = function (node, opts, state) {
/**
* Description
*
* @param {File} file
* @param {String} [name="temp"]
*/
Scope.prototype.generateTemp = function (file, name) {
var id = file.generateUidIdentifier(name || "temp", this);
Scope.prototype.generateTemp = function (name) {
var id = this.generateUidIdentifier(name || "temp");
this.push({
key: id.name,
id: id
@@ -70,7 +69,33 @@ Scope.prototype.generateTemp = function (file, name) {
*/
Scope.prototype.generateUidIdentifier = function (name) {
return this.file.generateUidIdentifier(name, this);
var id = t.identifier(this.generateUid(name));
this.getFunctionParent().registerBinding("uid", id);
return id;
};
/**
* Description
*
* @param {String} name
*/
Scope.prototype.generateUid = function (name) {
name = t.toIdentifier(name).replace(/^_+/, "");
var uid;
var i = 0;
do {
uid = this._generateUid(name, i);
i++;
} while (this.hasBinding(uid) || this.hasGlobal(uid));
return uid;
};
Scope.prototype._generateUid = function (name, i) {
var id = name;
if (i > 1) id += i;
return "_" + id;
};
/*
@@ -111,7 +136,7 @@ Scope.prototype.generateUidBasedOnNode = function (parent) {
var id = parts.join("$");
id = id.replace(/^_/, "") || "ref";
return this.file.generateUidIdentifier(id, this);
return this.generateUidIdentifier(id);
};
/**
@@ -141,7 +166,7 @@ Scope.prototype.checkBlockScopedCollisions = function (kind, name, id) {
if (kind === "param") return;
if (kind === "hoisted" && local.kind === "let") return;
if (local.kind === "let" || local.kind === "const") {
if (local.kind === "let" || local.kind === "const" || local.kind === "module") {
throw this.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
}
};
@@ -185,16 +210,28 @@ Scope.prototype.inferType = function (node) {
target = node.init;
}
if (t.isCallExpression(target)) {
// todo: resolve this to a return type
if (t.isArrayExpression(target)) {
return t.genericTypeAnnotation(t.identifier("Array"));
}
if (t.isMemberExpression(target)) {
// todo: crawl this and find the correct type, bail on anything that we cannot possibly be 100% confident on
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)) {
// todo
return;
}
};
@@ -217,7 +254,12 @@ Scope.prototype.assignType = function (name, type) {
info.identifier.typeAnnotation = info.typeAnnotation = type;
};
Scope.prototype.getTypeAnnotation = function (key, id, node) {
Scope.prototype.getTypeAnnotation = function (name, id, node) {
var info = {
annotation: null,
inferred: false
};
var type;
if (id.typeAnnotation) {
@@ -225,13 +267,16 @@ Scope.prototype.getTypeAnnotation = function (key, id, node) {
}
if (!type) {
info.inferred = true;
type = this.inferType(node);
}
if (type) {
if (t.isTypeAnnotation(type)) type = type.typeAnnotation;
return type;
info.annotation = type;
}
return info;
};
Scope.prototype.toArray = function (node, i) {
@@ -284,7 +329,14 @@ Scope.prototype.registerBindingReassignment = function (node) {
var ids = t.getBindingIdentifiers(node);
for (var name in ids) {
var info = this.getBindingInfo(name);
if (info) info.reassigned = true;
if (info) {
info.reassigned = true;
if (info.typeAnnotationInferred) {
// destroy the inferred typeAnnotation
info.typeAnnotation = null;
}
}
}
};
@@ -298,12 +350,16 @@ Scope.prototype.registerBinding = function (kind, node) {
this.checkBlockScopedCollisions(kind, name, id);
var typeInfo = this.getTypeAnnotation(name, id, node);
this.bindings[name] = {
typeAnnotation: this.getTypeAnnotation(name, id, node),
reassigned: false,
identifier: id,
scope: this,
kind: kind
typeAnnotationInferred: typeInfo.inferred,
typeAnnotation: typeInfo.annotation,
reassigned: false,
identifier: id,
scope: this,
node: node,
kind: kind
};
}
};
@@ -362,7 +418,7 @@ var programReferenceVisitor = {
state.addGlobal(node);
} else if (t.isLabeledStatement(node)) {
state.addGlobal(node);
} else if (t.isAssignmentExpression(node) || t.isUpdateExpression(node)) {
} else if (t.isAssignmentExpression(node) || t.isUpdateExpression(node) || (t.isUnaryExpression(node) && node.operator === "delete")) {
scope.registerBindingReassignment(node);
}
}

View File

@@ -22,6 +22,9 @@
"FunctionDeclaration": ["Statement", "Declaration", "Scopable", "Function"],
"FunctionExpression": ["Scopable", "Function", "Expression"],
"ImportSpecifier": ["ModuleSpecifier"],
"ExportSpecifier": ["ModuleSpecifier"],
"BlockStatement": ["Statement", "Scopable"],
"Program": ["Scopable"],
"CatchClause": ["Scopable"],

View File

@@ -403,7 +403,7 @@ t.toIdentifier = function (name) {
* Description
*
* @param {Object} node
* @param {String} key
* @param {String=} key
*/
t.ensureBlock = function (node, key) {
@@ -418,7 +418,7 @@ t.ensureBlock = function (node, key) {
* For example, given the match `React.createClass` it would match the
* parsed nodes of `React.createClass` and `React["createClass"]`.
*
* @param {String} match Dot delimetered string
* @param {String} match Dot-delimited string
* @param {Boolean} [allowPartial] Allow a partial match
* @returns {Function}
*/
@@ -590,6 +590,8 @@ t.getBindingIdentifiers = function (node) {
if (t.isIdentifier(id)) {
ids[id.name] = id;
} else if (t.isImportSpecifier(id)) {
search.push(id.name || id.id);
} else if (t.isExportDeclaration(id)) {
if (t.isDeclaration(node.declaration)) {
search.push(node.declaration);
@@ -606,14 +608,12 @@ t.getBindingIdentifiers = function (node) {
};
t.getBindingIdentifiers.keys = {
UnaryExpression: ["argument"],
AssignmentExpression: ["left"],
ImportBatchSpecifier: ["name"],
ImportSpecifier: ["name", "id"],
ExportSpecifier: ["name", "id"],
VariableDeclarator: ["id"],
FunctionDeclaration: ["id"],
ClassDeclaration: ["id"],
MemberExpression: ["object"],
SpreadElement: ["argument"],
RestElement: ["argument"],
UpdateExpression: ["argument"],

View File

@@ -92,6 +92,7 @@
"TypeofTypeAnnotation": [],
"TypeAlias": [],
"TypeAnnotation": [],
"TypeCastExpression": ["expression"],
"TypeParameterDeclaration": [],
"TypeParameterInstantiation": [],
"ObjectTypeAnnotation": [],

View File

@@ -88,6 +88,7 @@ var templateVisitor = {
node = node.expression;
}
if (t.isIdentifier(node) && has(nodes, node.name)) {
this.skip();
return nodes[node.name];
}
}
@@ -108,6 +109,8 @@ exports.template = function (name, nodes, keepExpression) {
traverse(template, templateVisitor, null, nodes);
}
if (template.body.length > 1) return template.body;
var node = template.body[0];
if (!keepExpression && t.isExpressionStatement(node)) {

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "3.6.0",
"version": "3.6.4",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://6to5.org/",
"repository": "6to5/6to5",
@@ -33,7 +33,7 @@
"test": "make test"
},
"dependencies": {
"acorn-6to5": "0.11.1-29",
"acorn-6to5": "0.11.1-31",
"ast-types": "~0.6.1",
"chalk": "^0.5.1",
"chokidar": "0.12.6",
@@ -58,7 +58,7 @@
"useragent": "^2.1.5"
},
"devDependencies": {
"6to5": "3.5.3",
"6to5": "3.6.0",
"browserify": "8.1.1",
"chai": "1.10.0",
"esvalid": "1.1.0",

View File

@@ -1,7 +1,7 @@
{
"name": "6to5-runtime",
"description": "6to5 selfContained runtime",
"version": "3.5.3",
"version": "3.6.3",
"repository": "6to5/6to5",
"author": "Sebastian McKenzie <sebmck@gmail.com>"
}

View File

@@ -2,6 +2,7 @@
var buildHelpers = require("../lib/6to5/build-helpers");
var transform = require("../lib/6to5/transformation");
var util = require("../lib/6to5/util");
var fs = require("fs");
var t = require("../lib/6to5/types");
var _ = require("lodash");
@@ -16,8 +17,14 @@ var writeFile = function (filename, content) {
fs.writeFileSync(filename, content);
};
var readFile = function (filename) {
return fs.readFileSync(require.resolve(filename), "utf8");
var readFile = function (filename, defaultify) {
var file = fs.readFileSync(require.resolve(filename), "utf8");
if (defaultify) {
file += '\nmodule.exports = { "default": module.exports, __esModule: true };\n';
}
return file;
};
var updatePackage = function () {
@@ -37,10 +44,10 @@ var selfContainify = function (code) {
};
var buildHelpers2 = function () {
var body = [];
var body = util.template("self-contained-helpers-head");
var tree = t.program(body);
buildHelpers(body, t.identifier("exports"));
buildHelpers(body, t.identifier("helpers"));
return transform.fromAst(tree, null, {
optional: ["selfContained"]
@@ -48,7 +55,7 @@ var buildHelpers2 = function () {
};
writeFile("helpers.js", buildHelpers2());
writeFile("core-js.js", readFile("core-js/library"));
writeFile("regenerator/index.js", readFile("regenerator-6to5/runtime-module"));
writeFile("core-js.js", readFile("core-js/library", true));
writeFile("regenerator/index.js", readFile("regenerator-6to5/runtime-module", true));
writeFile("regenerator/runtime.js", selfContainify(readFile("regenerator-6to5/runtime")));
updatePackage();

View File

@@ -1,3 +1,3 @@
{
"args": ["foo"]
"args": ["bar"]
}

View File

@@ -1,4 +1,4 @@
var foo = () => console.log("foo");
foo();
import "./bar";
import "./bar2";

View File

@@ -1,3 +1,3 @@
{
"args": ["foo"]
"args": ["foo2"]
}

View File

@@ -5,4 +5,4 @@ var _classCallCheck = function (instance, Constructor) { if (!(instance instance
var Test = function Test() {
_classCallCheck(this, Test);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9iYXIvYmFyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7SUFBTSxJQUFJLFlBQUosSUFBSTt3QkFBSixJQUFJIiwiZmlsZSI6InNyYy9iYXIvYmFyLmpzIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgVGVzdCB7XG5cbn0iXX0=
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXIvYmFyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7SUFBTSxJQUFJLFlBQUosSUFBSTt3QkFBSixJQUFJIiwiZmlsZSI6InNyYy9iYXIvYmFyLmpzIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgVGVzdCB7XG5cbn0iXX0=

View File

@@ -3,4 +3,4 @@
arr.map(function (x) {
return x * MULTIPLIER;
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9mb28uanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxHQUFHLENBQUMsR0FBRyxDQUFDLFVBQUEsQ0FBQztTQUFJLENBQUMsR0FBRyxVQUFVO0NBQUEsQ0FBQyxDQUFDIiwiZmlsZSI6InNyYy9mb28uanMiLCJzb3VyY2VzQ29udGVudCI6WyJhcnIubWFwKHggPT4geCAqIE1VTFRJUExJRVIpOyJdfQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9mb28uanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxHQUFHLENBQUMsR0FBRyxDQUFDLFVBQUEsQ0FBQztTQUFJLENBQUMsR0FBRyxVQUFVO0NBQUEsQ0FBQyxDQUFDIiwiZmlsZSI6InNyYy9mb28uanMiLCJzb3VyY2VzQ29udGVudCI6WyJhcnIubWFwKHggPT4geCAqIE1VTFRJUExJRVIpOyJdfQ==

View File

@@ -1 +1 @@
{"version":3,"sources":["src/bar/bar.js"],"names":[],"mappings":";;;;IAAM,IAAI,YAAJ,IAAI;wBAAJ,IAAI","file":"src/bar/bar.js","sourcesContent":["class Test {\n\n}"]}
{"version":3,"sources":["../../src/bar/bar.js"],"names":[],"mappings":";;;;IAAM,IAAI,YAAJ,IAAI;wBAAJ,IAAI","file":"src/bar/bar.js","sourcesContent":["class Test {\n\n}"]}

View File

@@ -1 +1 @@
{"version":3,"sources":["src/foo.js"],"names":[],"mappings":";;AAAA,GAAG,CAAC,GAAG,CAAC,UAAA,CAAC;SAAI,CAAC,GAAG,UAAU;CAAA,CAAC,CAAC","file":"src/foo.js","sourcesContent":["arr.map(x => x * MULTIPLIER);"]}
{"version":3,"sources":["../src/foo.js"],"names":[],"mappings":";;AAAA,GAAG,CAAC,GAAG,CAAC,UAAA,CAAC;SAAI,CAAC,GAAG,UAAU;CAAA,CAAC,CAAC","file":"src/foo.js","sourcesContent":["arr.map(x => x * MULTIPLIER);"]}

View File

@@ -0,0 +1,2 @@
const x = {};
x.key = "value";

View File

@@ -0,0 +1,4 @@
"use strict";
var x = {};
x.key = "value";

View File

@@ -1,6 +1,6 @@
"use strict";
var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { 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; } };
var _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"); } };
var _ref = ["hello", [", ", "junk"], ["world"]];
@@ -11,4 +11,4 @@ var b = _ref$1[0];
var _ref$2 = _slicedToArray(_ref[2], 1);
var c = _ref$2[0];
var d = _ref[3];
var d = _ref[3];

View File

@@ -1,6 +1,6 @@
"use strict";
var _temp, _temp2;
var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { 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; } };
var _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"); } };
console.log((_temp = [123], _temp2 = _slicedToArray(_temp, 1), x = _temp2[0], _temp));
console.log((_temp = [123], _temp2 = _slicedToArray(_temp, 1), x = _temp2[0], _temp));

View File

@@ -1,6 +1,6 @@
"use strict";
var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { 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; } };
var _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"); } };
var _ref = f();
@@ -8,4 +8,4 @@ var _ref2 = _slicedToArray(_ref, 2);
a = _ref2[0];
b = _ref2[1];
;
;

View File

@@ -1,6 +1,6 @@
"use strict";
var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { 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; } };
var _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"); } };
var _ref = ["foo", "hello", [", ", "junk"], ["world"]];
@@ -11,4 +11,4 @@ var b = _ref$2[0];
var _ref$3 = _slicedToArray(_ref[3], 1);
var c = _ref$3[0];
var d = _ref[4];
var d = _ref[4];

View File

@@ -1,6 +1,6 @@
"use strict";
var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { 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; } };
var _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"); } };
for (var _ref in obj) {
var _ref2 = _slicedToArray(_ref, 2);
@@ -8,4 +8,4 @@ for (var _ref in obj) {
var name = _ref2[0];
var value = _ref2[1];
print("Name: " + name + ", Value: " + value);
}
}

View File

@@ -1,6 +1,6 @@
"use strict";
var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { 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; } };
var _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"); } };
for (var _iterator = test.expectation.registers[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
var _step$value = _slicedToArray(_step.value, 3);
@@ -8,4 +8,4 @@ for (var _iterator = test.expectation.registers[Symbol.iterator](), _step; !(_st
var name = _step$value[0];
var before = _step$value[1];
var after = _step$value[2];
}
}

View File

@@ -1,6 +1,6 @@
"use strict";
var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { 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; } };
var _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"); } };
var _ref = [1, 2];

View File

@@ -1,6 +1,6 @@
"use strict";
var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { 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; } };
var _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"); } };
var _rect$topLeft = _slicedToArray(rect.topLeft, 2);
@@ -9,4 +9,4 @@ var y1 = _rect$topLeft[1];
var _rect$bottomRight = _slicedToArray(rect.bottomRight, 2);
var x2 = _rect$bottomRight[0];
var y2 = _rect$bottomRight[1];
var y2 = _rect$bottomRight[1];

View File

@@ -1,6 +1,6 @@
"use strict";
var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { 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; } };
var _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"); } };
function somethingAdvanced(_ref) {
var _ref$topLeft = _ref.topLeft;
@@ -33,4 +33,4 @@ var unpackArray = function (_ref, _ref3) {
return a + b + c;
};
console.log(unpackArray(["hello", ", ", "world"], [1, 2, 3]));
console.log(unpackArray(["hello", ", ", "world"], [1, 2, 3]));

View File

@@ -1,4 +1,4 @@
import foo from "foo";
import { default as foo } from "foo";
import { foo } from "foo";
import * as foo from "foo";
import { default as foo2 } from "foo";
import { foo3 } from "foo";
import * as foo4 from "foo";

View File

@@ -3,6 +3,6 @@
var _foo = require("foo");
var foo = _foo["default"];
var foo = _foo["default"];
var foo = _foo.foo;
var foo = _foo;
var foo2 = _foo["default"];
var foo3 = _foo.foo3;
var foo4 = _foo;

View File

@@ -1,7 +1,6 @@
"use strict";
var _core = require("6to5-runtime/core-js");
var _core = require("6to5-runtime/core-js")["default"];
obj.constructor === Object;
obj.constructor === _core.Promise;

View File

@@ -1,7 +1,6 @@
"use strict";
var _core = require("6to5-runtime/core-js");
var _core = require("6to5-runtime/core-js")["default"];
for (var _iterator = _core.$for.getIterator(arr), _step; !(_step = _iterator.next()).done;) {
var i = _step.value;
}

View File

@@ -1,7 +1,6 @@
"use strict";
var _core = require("6to5-runtime/core-js");
var _core = require("6to5-runtime/core-js")["default"];
var arr = (function () {
var _arr = [];

View File

@@ -1,11 +1,8 @@
"use strict";
var _regeneratorRuntime = require("6to5-runtime/regenerator");
var _to5Helpers = require("6to5-runtime/helpers");
var _core = require("6to5-runtime/core-js");
var _core = require("6to5-runtime/core-js")["default"];
var _regeneratorRuntime = require("6to5-runtime/regenerator")["default"];
var _to5Helpers = require("6to5-runtime/helpers")["default"];
var giveWord = _regeneratorRuntime.mark(function giveWord() {
return _regeneratorRuntime.wrap(function giveWord$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {

View File

@@ -1,6 +1,6 @@
define(["exports", "foo", "6to5-runtime/helpers"], function (exports, _foo, _to5RuntimeHelpers) {
"use strict";
var _to5Helpers = _to5RuntimeHelpers;
var _to5Helpers = _to5RuntimeHelpers["default"];
var foo = _to5Helpers.interopRequire(_foo);
});
});

View File

@@ -1,5 +1,4 @@
"use strict";
var _to5Helpers = require("6to5-runtime/helpers");
var foo = _to5Helpers.interopRequire(require("foo"));
var _to5Helpers = require("6to5-runtime/helpers")["default"];
var foo = _to5Helpers.interopRequire(require("foo"));

View File

@@ -4,10 +4,10 @@ System.register(["6to5-runtime/helpers"], function (_export) {
var _to5Helpers;
return {
setters: [function (_to5RuntimeHelpers) {
_to5Helpers = _to5RuntimeHelpers;
_to5Helpers = _to5RuntimeHelpers["default"];
}],
execute: function () {
foo.apply(undefined, _to5Helpers.toConsumableArray(bar));
}
};
});
});

View File

@@ -7,6 +7,6 @@
})(function (exports, _foo, _to5RuntimeHelpers) {
"use strict";
var _to5Helpers = _to5RuntimeHelpers;
var _to5Helpers = _to5RuntimeHelpers["default"];
var foo = _to5Helpers.interopRequire(_foo);
});
});

View File

@@ -1,7 +1,6 @@
"use strict";
var _regeneratorRuntime = require("6to5-runtime/regenerator");
var _regeneratorRuntime = require("6to5-runtime/regenerator")["default"];
void _regeneratorRuntime.mark(function callee$0$0() {
return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {

View File

@@ -0,0 +1 @@
Symbol.iterator in Object(arr);

View File

@@ -0,0 +1,4 @@
"use strict";
var _core = require("6to5-runtime/core-js")["default"];
_core.$for.isIterable(Object(arr));

View File

@@ -1,5 +1,6 @@
var assert = require("assert");
var util = require("../lib/6to5/util");
var parse = require("../lib/6to5/helpers/parse");
var t = require("../lib/6to5/types");
suite("util", function () {
@@ -9,6 +10,23 @@ suite("util", function () {
}, /unknown template/);
});
test("templates do not recurse", function () {
var key = __filename;
var KEY = parse({ loc: key }, "replacedKey").program.body[0].expression;
var VALUE = parse({ loc: key }, "+KEY").program.body[0].expression;
util.templates[key] = util.parseTemplate(key, "KEY = VALUE;");
var result = util.template(key, {KEY: KEY, VALUE: VALUE});
delete util.templates[key];
assert.strictEqual(
result.right.argument.name,
"KEY",
"template should not recurse into replaced nodes, " +
"replacing KEY inside VALUE"
);
});
test("canCompile", function () {
assert.ok(util.canCompile("test.js"));
assert.ok(util.canCompile("/test.js"));