Compare commits

...

12 Commits

Author SHA1 Message Date
Sebastian McKenzie
75ece96475 v1.10.6 2014-10-28 13:18:47 +11:00
Sebastian McKenzie
b016fda8af add browser.js to .gitignore 2014-10-28 13:18:00 +11:00
Sebastian McKenzie
2cffad61fa more reliable destructuring building 2014-10-28 13:16:31 +11:00
Sebastian McKenzie
4e248c0a16 add member expression destructuring test 2014-10-28 13:16:21 +11:00
Sebastian McKenzie
4f5026101b fix cache-templates build script position - fixes #101 2014-10-28 13:16:08 +11:00
Sebastian McKenzie
4ce38eab37 v1.10.5 2014-10-28 10:59:28 +11:00
Sebastian McKenzie
0a7ce115ff remove browser.js in make publish 2014-10-28 10:58:29 +11:00
Sebastian McKenzie
21ed438fd8 alias functions in scope call wrapping - fixes #99 2014-10-28 10:58:20 +11:00
Sebastian McKenzie
5f9e954d21 v1.10.4 2014-10-28 10:54:18 +11:00
Sebastian McKenzie
a03fd0f43a fix formatting 2014-10-28 10:52:48 +11:00
Sebastian McKenzie
dcc5eaa95e support MemberExpressions in destructuring - fixes #100 2014-10-28 10:52:24 +11:00
Sebastian McKenzie
3b7ce5aaa1 add browser file so we can have a custom browser environment 2014-10-28 10:52:07 +11:00
9 changed files with 30 additions and 17 deletions

1
.gitignore vendored
View File

@@ -4,5 +4,6 @@ test/tmp
*.log
*.cache
/templates.json
/browser.js
coverage
dist

View File

@@ -35,7 +35,7 @@ build:
node bin/cache-templates
browserify lib/6to5/transform.js -s to5 >dist/6to5.js
browserify lib/6to5/browser.js -s to5 >dist/6to5.js
uglifyjs dist/6to5.js >dist/6to5.min.js
rm -rf templates.json
@@ -45,6 +45,9 @@ publish:
make test
make build
cp dist/6to5.js browser.js
node bin/cache-templates
test -f templates.json
@@ -54,4 +57,4 @@ publish:
git push --follow-tags
rm -rf templates.json
rm -rf templates.json browser.js

3
lib/6to5/browser.js Normal file
View File

@@ -0,0 +1,3 @@
var transform = require("./transform");
module.exports = transform;

View File

@@ -13,11 +13,15 @@ var buildVariableAssign = function (kind, id, init) {
}
};
var push = function (kind, nodes, pattern, parentId) {
if (pattern.type === "ObjectPattern") {
pushObjectPattern(kind, nodes, pattern, parentId);
} else if (pattern.type === "ArrayPattern") {
pushArrayPattern(kind, nodes, pattern, parentId);
var push = function (kind, nodes, elem, parentId) {
if (elem.type === "ObjectPattern") {
pushObjectPattern(kind, nodes, elem, parentId);
} else if (elem.type === "ArrayPattern") {
pushArrayPattern(kind, nodes, elem, parentId);
} else if (elem.type === "MemberExpression") {
nodes.push(buildVariableAssign(false, elem, parentId));
} else {
nodes.push(buildVariableAssign(kind, elem, parentId));
}
};
@@ -39,12 +43,7 @@ var pushArrayPattern = function (kind, nodes, pattern, parentId) {
if (!elem) return;
var newPatternId = b.memberExpression(parentId, b.literal(i), true);
if (elem.type === "Identifier") {
nodes.push(buildVariableAssign(kind, elem, newPatternId));
} else {
push(kind, nodes, elem, newPatternId);
}
push(kind, nodes, elem, newPatternId);
});
};

View File

@@ -42,9 +42,11 @@ exports.VariableDeclaration = function (node, parent, file) {
if (node.type === "FunctionDeclaration") {
throw new Error("`FunctionDeclaration`s that use `let` and `constant` references aren't allowed outside of the root scope");
} else {
return b.callExpression(b.functionExpression(null, letReferences, b.blockStatement([
var func = b.functionExpression(null, letReferences, b.blockStatement([
b.returnStatement(node)
])), letReferences);
]));
func._aliasFunction = true;
return b.callExpression(func, letReferences);
}
} else {
return false;

View File

@@ -275,7 +275,7 @@ exports.parse = function (opts, code, callback) {
message += frame;
}
err.stack = err.stack.replace(err.message, message);
err.stack = err.stack.replace(err.message, message);
err.message = message;
}

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "1.10.3",
"version": "1.10.6",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://github.com/sebmck/6to5",
"repository": {

View File

@@ -0,0 +1 @@
[this.foo, this.bar] = [1, 2];

View File

@@ -0,0 +1,4 @@
"use strict";
var _ref = [1, 2];
this.foo = _ref[0];
this.bar = _ref[1];