Compare commits

..

66 Commits

Author SHA1 Message Date
Sebastian McKenzie
a1bdd804e2 v1.12.14 2014-11-15 11:30:37 +11:00
Sebastian McKenzie
10c051890b fix changelog version 2014-11-15 11:29:41 +11:00
Sebastian McKenzie
ac49d0a335 v1.12.4 2014-11-15 11:29:06 +11:00
Sebastian McKenzie
b56f1800e5 update regenerator-6to5 2014-11-15 11:27:29 +11:00
Sebastian McKenzie
49ef92c586 add changelog for v1.12.4 2014-11-15 11:23:42 +11:00
Sebastian McKenzie
542fe89123 fix up tests to work with new member expression keyword generator 2014-11-15 11:23:16 +11:00
Sebastian McKenzie
5b118c0c3f add _property-literals test 2014-11-15 11:13:10 +11:00
Sebastian McKenzie
8503916799 add _memberExpressionKeywords transformer that turns keyword identifiers to computed literals 2014-11-15 11:13:02 +11:00
Sebastian McKenzie
206c828a56 more react compliant whitespace - #165 2014-11-15 11:00:32 +11:00
Sebastian McKenzie
7a261a1db1 fix duplicate let scoping in functions - fixes #166 2014-11-15 09:47:48 +11:00
Sebastian McKenzie
c9d9a085f1 v1.12.13 2014-11-15 03:08:35 +11:00
Sebastian McKenzie
6d1953d9c3 fix constants transformer not accurately checking nodes 2014-11-15 03:07:33 +11:00
Sebastian McKenzie
92621d71c7 remove unused variable 2014-11-15 03:01:58 +11:00
Sebastian McKenzie
dc01731c25 add changelog for 1.12.13 2014-11-15 03:01:01 +11:00
Sebastian McKenzie
9fb8a80f60 support raw property on tagged template literals - closes #164 2014-11-15 03:00:53 +11:00
Sebastian McKenzie
85c2de57e4 fix for-head duplication testing and replacement - fixes #162 2014-11-15 02:50:05 +11:00
Sebastian McKenzie
58fac2e2be support duplicate constants within different block scopes - fixes #161 2014-11-15 02:49:49 +11:00
Sebastian McKenzie
682806f1ca instead of ignoring dot tests, add them as pending 2014-11-15 02:49:28 +11:00
Sebastian McKenzie
47c6f74251 v1.12.12 2014-11-14 23:15:14 +11:00
Sebastian McKenzie
37f360c72d make scope tracker more reliable to handle all edgecases 2014-11-14 23:13:58 +11:00
Sebastian McKenzie
e5a8c95b62 v1.12.11 2014-11-14 19:39:25 +11:00
Sebastian McKenzie
921d459f13 fix transformation let scoping hoisting test 2014-11-14 19:38:29 +11:00
Sebastian McKenzie
58898932e6 shift letScoping to before forOf transformer 2014-11-14 19:35:07 +11:00
Sebastian McKenzie
c7b45116c4 fix generation of integer Literals in MemberExpression 2014-11-14 19:34:54 +11:00
Sebastian McKenzie
32ddd638ba Revert "expose moduleName option - closes #158"
This reverts commit fdd1451d53.
2014-11-14 18:33:11 +11:00
Sebastian McKenzie
0eb3cda2d4 add 1.12.11 changelog 2014-11-14 17:20:05 +11:00
Sebastian McKenzie
2acb24d43d block scope classes 2014-11-14 17:19:46 +11:00
Sebastian McKenzie
fdd1451d53 expose moduleName option - closes #158 2014-11-14 17:19:39 +11:00
Sebastian McKenzie
43e2f121a6 remove nodes replacing in util.template 2014-11-14 09:28:23 +11:00
Sebastian McKenzie
297e55ba63 Revert "fix up types.toStatement and return an expressionStatement if all else fails"
This reverts commit 740193b1e2.
2014-11-14 09:28:04 +11:00
Sebastian McKenzie
38396dadd5 remove unused nodes.inherits in util.template 2014-11-14 09:15:29 +11:00
Sebastian McKenzie
f75f045026 turn custom runtime into a proper identifier 2014-11-14 09:15:00 +11:00
Sebastian McKenzie
740193b1e2 fix up types.toStatement and return an expressionStatement if all else fails 2014-11-14 09:14:49 +11:00
Sebastian McKenzie
b9fe1475c2 add basic api test 2014-11-14 09:13:00 +11:00
Sebastian McKenzie
6065220f9b add runtime test 2014-11-14 09:12:54 +11:00
Sebastian McKenzie
715884662e fix basic unicode-regex test 2014-11-14 09:12:49 +11:00
Sebastian McKenzie
11780c28ff add let scoping hoisting test 2014-11-14 09:12:38 +11:00
Sebastian McKenzie
215c2da7cb v1.12.10 2014-11-14 07:40:41 +11:00
Sebastian McKenzie
c7c41d6548 add changelog for 1.12.10 2014-11-14 07:39:06 +11:00
Sebastian McKenzie
695571b435 fix LetScoping::pushDeclar - fixes #156 2014-11-14 07:34:50 +11:00
Sebastian McKenzie
f845633cc1 v1.12.9 2014-11-14 02:24:08 +11:00
Sebastian McKenzie
72c9b1d6c9 remove redundant changelog message 2014-11-14 02:23:23 +11:00
Sebastian McKenzie
edd3363e48 fix unicode regex test escaping 2014-11-14 02:23:12 +11:00
Sebastian McKenzie
114b5ef9ec add changelog for 1.12.9 2014-11-14 02:20:15 +11:00
Sebastian McKenzie
2f4e0c3361 escape unicode characters - fixes #154 2014-11-14 02:17:06 +11:00
Sebastian McKenzie
3ee51dae1a fix semicolon 2014-11-14 00:59:18 +11:00
Sebastian McKenzie
20263c1151 fix newline in let-scoping/for-break-continue-return test 2014-11-14 00:55:39 +11:00
Sebastian McKenzie
eaac564f11 add toIdentifier, toBlock and toStatement tests 2014-11-14 00:55:22 +11:00
Sebastian McKenzie
63a47ef7bb optimise types.toStatement for when we're directly passed a statement 2014-11-14 00:55:14 +11:00
Sebastian McKenzie
6963cc1e40 fix WithStatement missing paranthesis 2014-11-14 00:54:58 +11:00
Sebastian McKenzie
5eb2462e29 fix up semicolons for module ExportDeclaration generator 2014-11-14 00:54:28 +11:00
Sebastian McKenzie
9e285cdc20 remove unneccesary Literal generator raw 2014-11-14 00:54:12 +11:00
Sebastian McKenzie
01ade47af9 add single spread test 2014-11-14 00:54:00 +11:00
Sebastian McKenzie
b1fe449b0d allow XJSElement and SequenceExpression to be user whitespacable 2014-11-14 00:53:45 +11:00
Sebastian McKenzie
2b458ec2d4 make it illegal to use destructuring outside of an ExpressionStatement 2014-11-14 00:53:10 +11:00
Sebastian McKenzie
d5f47f4f4d generator: correctly output XJSEmptyExpression 2014-11-14 00:52:49 +11:00
Sebastian McKenzie
d4deb18975 support async functions in generator and move MethodDefinition to class generator 2014-11-14 00:52:36 +11:00
Sebastian McKenzie
5a794db73b fix up let scoping transformer comments 2014-11-14 00:52:15 +11:00
Sebastian McKenzie
dc131f05a8 add comprehensive generation tests 2014-11-14 00:51:59 +11:00
Sebastian McKenzie
1d4f79790a add brief usage to doc/index.md - thanks @gabrielecirulli ❤️ 2014-11-13 23:31:51 +11:00
Sebastian McKenzie
6bcbaf6df1 better feature code examples 2014-11-13 19:00:08 +11:00
Sebastian McKenzie
bc199ef0c9 better api documentation 2014-11-13 18:59:59 +11:00
Sebastian McKenzie
f5fed99c81 better 6to5 tagline 2014-11-13 18:59:46 +11:00
Sebastian McKenzie
66a6d3cffe add CONTRIBUTING.md 2014-11-13 18:59:29 +11:00
Sebastian McKenzie
39227486a6 add async to caveats 2014-11-13 14:47:39 +11:00
Sebastian McKenzie
caafa31df1 chagne ES6 to ES6+ when talking about 6to5 support 2014-11-13 14:47:32 +11:00
198 changed files with 1403 additions and 323 deletions

View File

@@ -1,3 +1,35 @@
# 1.12.14
* Fix duplicate let scoping in functions.
* Make JSX whitespace more React-compliant.
* Add `_memberExpressionKeywords` transformer that turns keyword identifiers to computed literals.
* Upgrade `regenerator-6to5`.
# 1.12.13
* Support duplicate constants within different block scopes.
* Fix for-head duplication testing and replacement.
* Support `raw` property on tagged template literals.
# 1.12.12
* Make scope tracker more reliable to handle all edgecases.
# 1.12.11
* Block scope classes.
* Fix generation of integer `Literal`s in `MemberExpression`.
# 1.12.10
* Fix let scoping var hoisting.
# 1.12.9
* Escape unicode characters when generating string `Literal`s.
* Fix semicolons being output for statements in `ExportDeclaration`.
* Fix `WithStatement` missing parenthesis.
# 1.12.8
* Temporarily forbid `AssignmentExpression` destructuring outside of `ExpressionStatement`.

31
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,31 @@
# Contributing
* **General**
* No ES6 syntax features or methods, exclusively ES5.
* Max of five arguments for functions
* Max depth of four nested blocks
* 2-spaced soft tabs
* **Naming**
* CamelCase all class names
* camelBack all variable names
* **Spacing**
* 80 character line max
* Spaces after all keywords
* Spaces before all left curly braces
* **Comments**
* Use JSDoc-style comments for methods
* Single-line comments for ambiguous code
* **Quotes**
* Always use double quotes
* Only use single quotes when the string contains a double quote
* **Declaration**
* No unused variables
* No pollution of global variables and prototypes
## Testing
$ make test
## Linting
$ make lint

View File

@@ -24,6 +24,6 @@
</a>
</p>
**6to5** turns ES6 code into vanilla ES5, so you can use ES6 features **today.**
**6to5** turns ES6+ code into vanilla ES5, so you can use next generation features **today.**
For more information view the [documentation](https://6to5.github.io).

View File

@@ -3,12 +3,6 @@
A browser version of 6to5 is available from `browser.js` inside the 6to5
directory in an npm release.
## API
```javascript
to5.transform("class Test {}").code;
```
## Scripts
While it's not recommended for serious use, when the browser version is included
@@ -47,3 +41,21 @@ To test 6to5 in your browser run:
$ make test-browser
And open `test/browser.html` in your browser if it doesn't open automatically.
## API
### to5.transform(code, [opts])
See [options](usage.md#options) for additional documentation.
```javascript
to5.transform("class Test {}").code;
```
### to5.run(code, [opts])
See [options](usage.md#options) for additional documentation.
```javascript
to5.run("class Test {}");
```

View File

@@ -1,5 +1,10 @@
# Caveats
## Async/Generators
The [regenerator runtime](https://github.com/facebook/regenerator/blob/master/runtime.js)
and an [ES6 polyfill](polyfill.md) are required in order for generators to work.
## Classes
Built-in classes such as `Date`, `Array` and `DOM` cannot be subclassed due to
@@ -32,11 +37,6 @@ A polyfill is required for for-of functionality that implements `Symbol` and
adds `prototype[Symbol.iterator]` behaviour to built-ins. Using the polyfills
specified in [polyfill](polyfill.md) suffices.
## Generators
The [regenerator runtime](https://github.com/facebook/regenerator/blob/master/runtime.js)
and an [ES6 polyfill](polyfill.md) are required in order for generators to work.
## Spread
An [ES6 polyfill](polyfill.md) is required in order for spread to work. More

View File

@@ -3,7 +3,32 @@
## Array comprehension
```javascript
[for (i of [1, 2, 3]) i * i]; // [1, 4, 9]
var results = [for (c of customers) if (c.city == "Seattle") { name: c.name, age: c.age }]
```
## Arrow functions
```javascript
// Expression bodies
var odds = evens.map(v => v + 1);
var nums = evens.map((v, i) => v + i);
// Statement bodies
nums.forEach(v => {
if (v % 5 === 0)
fives.push(v);
});
// Lexical this
var bob = {
_name: "Bob",
_friends: [],
printFriends() {
this._friends.forEach(f => {
console.log(this._name + " knows " + f);
});
}
};
```
## Async functions
@@ -16,31 +41,27 @@ async function chainAnimationsAsync(elem, animations) {
}
```
## Arrow functions
```javascript
arr.map(x => x * x);
```
## Let scoping
```javascript
for (let i in arr) {
let v = arr[i];
}
```
## Classes
```javascript
class Foo extends Bar {
constructor() { }
class SkinnedMesh extends THREE.Mesh {
constructor(geometry, materials) {
super(geometry, materials);
foo() { }
this.idMatrix = SkinnedMesh.defaultMatrix();
this.bones = [];
this.boneMatrices = [];
//...
}
get bar() { }
update(camera) {
//...
super.update();
}
set bar() { }
static defaultMatrix() {
return new THREE.Matrix4();
}
}
```
@@ -70,16 +91,35 @@ var MULTIPLIER; // error
## Default parameters
```javascript
function foo(bar = "foo") {
return bar + "bar";
function f(x, y = 12) {
// y is 12 if not passed (or passed as undefined)
return x + y;
}
f(3) == 15
```
## Destructuring
```javascript
var [a, [b], c, d] = ["hello", [", ", "junk"], ["world"]];
console.log(a + b + c); // hello, world
// list matching
var [a, , b] = [1,2,3];
// object matching
var { op: a, lhs: { op: b }, rhs: c } = getASTNode();
// object matching shorthand
// binds `op`, `lhs` and `rhs` in scope
var { op, lhs, rhs } = getASTNode();
// Can be used in parameter position
function g({ name: x }) {
console.log(x);
}
g({ name: 5 });
// Fail-soft destructuring
var [a] = [];
a === undefined;
```
## For-of
@@ -100,6 +140,14 @@ for (var i of [1, 2, 3]) {
```javascript
```
## Let scoping
```javascript
for (let i in arr) {
let v = arr[i];
}
```
## Modules
```javascript
@@ -141,23 +189,21 @@ function f(x, y) {
## Rest parameters
```javascript
function printList(name, ...items) {
console.log("list %s has the following items", name);
items.forEach(function (item) {
console.log(item);
});
function f(x, ...y) {
// y is an Array
return x * y.length;
}
f(3, "hello", true) == 6
```
## Spread
```javascript
function add(x, y) {
return x + y;
function f(x, y, z) {
return x + y + z;
}
var numbers = [5, 10];
add(...numbers); // 15
// Pass each elem of array as argument
f(...[1,2,3]) == 6
```
## Template literals

View File

@@ -1,4 +1,4 @@
**6to5** turns ES6 code into vanilla ES5, so you can use ES6 features **today.**
**6to5** turns ES6+ code into vanilla ES5, so you can use next generation features **today.**
- **Readable** - formatting is retained if possible so your generated code is as similar as possible.
- **Extensible** - with a large range of [plugins](plugins.md) and **browser support**.
@@ -11,6 +11,24 @@ It's as easy as:
$ npm install -g 6to5
## Usage
Once you've installed 6to5, there are multiple paths you can take depending on
how you want to use it.
6to5 will simply compile your ES6+ script to ES5 if you pass it as an argument
to the command-line tool `6to5`:
$ 6to5 script.js
If you have a file written using ES6+ and you just want to run it, `6to5-node`
has you covered:
$ 6to5-node script.js
And it doesn't end here! To see all the ways you can use 6to5, check out the
[Usage](http://6to5.github.io/usage.html) page.
## [Features](features.md)
- [Array comprehension](features.md#array-comprehension)

View File

@@ -50,16 +50,28 @@ Compile and run `test.js`.
```javascript
var to5 = require("6to5");
```
### to5.transform(code, [opts]);
```javascript
var result = to5.transform("code();", options);
result.code;
result.map;
result.ast;
```
### to5.transformFileSync(filename, [opts])
```javascript
to5.transformFileSync("filename.js", options).code;
```
### to5.transformFile(filename, [opts], callback)
```javascript
to5.transformFile("filename.js", options, function (err, result) {
result.code;
});
```

View File

@@ -2,13 +2,6 @@ var transform = module.exports = require("./transformation/transform");
transform.transform = transform;
transform.eval = function (code, opts) {
opts = opts || {};
opts.filename = opts.filename || "eval";
opts.sourceMap = "inline";
return eval(transform(code, opts).code);
};
transform.run = function (code, opts) {
opts = opts || {};
opts.sourceMap = "inline";

View File

@@ -18,7 +18,8 @@ function File(opts) {
this.ast = {};
}
File.declarations = ["extends", "class-props", "slice", "apply-constructor"];
File.declarations = ["extends", "class-props", "slice", "apply-constructor",
"tagged-template-literal"];
File.normaliseOptions = function (opts) {
opts = _.cloneDeep(opts || {});

View File

@@ -30,3 +30,11 @@ exports.ClassBody = function (node, print) {
this.rightBrace();
}
};
exports.MethodDefinition = function (node, print) {
if (node.static) {
this.push("static ");
}
this._method(node, print);
};

View File

@@ -1,4 +1,5 @@
var t = require("../../types");
var util = require("../../util");
var t = require("../../types");
exports.UnaryExpression = function (node, print) {
var hasSpace = /[a-z]$/.test(node.operator);
@@ -105,6 +106,11 @@ exports.MemberExpression = function (node, print) {
print(node.property);
this.push("]");
} else {
// 5..toFixed(2);
if (t.isLiteral(node.object) && util.isInteger(node.object.value)) {
this.push(".");
}
this.push(".");
print(node.property);
}

View File

@@ -74,5 +74,5 @@ exports.XJSClosingElement = function (node, print) {
};
exports.XJSEmptyExpression = function () {
this.push("null");
};

View File

@@ -41,6 +41,8 @@ exports._method = function (node, print) {
this.push(kind + " ");
}
if (value.async) this.push("async ");
if (node.computed) {
this.push("[");
print(key);
@@ -54,16 +56,9 @@ exports._method = function (node, print) {
print(value.body);
};
exports.MethodDefinition = function (node, print) {
if (node.static) {
this.push("static ");
}
this._method(node, print);
};
exports.FunctionDeclaration =
exports.FunctionExpression = function (node, print) {
if (node.async) this.push("async ");
this.push("function");
if (node.generator) this.push("*");
this.space();
@@ -74,6 +69,8 @@ exports.FunctionExpression = function (node, print) {
};
exports.ArrowFunctionExpression = function (node, print) {
if (node.async) this.push("async ");
if (node.params.length === 1 && !node.defaults.length && !node.rest && t.isIdentifier(node.params[0])) {
print(node.params[0]);
} else {

View File

@@ -25,9 +25,10 @@ exports.ExportDeclaration = function (node, print) {
if (node.declaration) {
print(node.declaration);
if (t.isStatement(node.declaration)) return;
} else {
if (specifiers.length === 1 && t.isExportBatchSpecifier(specifiers[0])) {
this.push("*");
print(specifiers[0]);
} else {
this.push("{");
if (specifiers.length) {

View File

@@ -4,6 +4,7 @@ exports.WithStatement = function (node, print) {
this.keyword("with");
this.push("(");
print(node.object);
this.push(")");
print.block(node.body);
};
@@ -134,15 +135,6 @@ exports.SwitchStatement = function (node, print) {
this.push(") {");
print.sequence(node.cases, { indent: true });
this.push("}");
//if (node.cases.length) {
// this.newline();
// print.sequence(node.cases, { indent: true });
// this.newline();
// this.rightBrace();
//} else {
// this.push("}");
//}
};
exports.SwitchCase = function (node, print) {
@@ -154,13 +146,8 @@ exports.SwitchCase = function (node, print) {
this.push("default:");
}
if (node.consequent.length === 1) {
this.space();
print(node.consequent[0]);
} else if (node.consequent.length > 1) {
this.newline();
print.sequence(node.consequent, { indent: true });
}
this.space();
print.sequence(node.consequent, { indent: true });
};
exports.DebuggerStatement = function () {

View File

@@ -74,13 +74,20 @@ exports.Literal = function (node) {
var val = node.value;
var type = typeof val;
if (type === "boolean" || type === "number" || type === "string") {
if (type === "string") {
val = JSON.stringify(val);
// escape unicode characters
val = val.replace(/[\u007f-\uffff]/g, function(c) {
return "\\u" + ("0000" + c.charCodeAt(0).toString(16)).slice(-4);
});
this.push(val);
} else if (type === "boolean" || type === "number") {
this.push(JSON.stringify(val));
} else if (node.regex) {
this.push("/" + node.regex.pattern + "/" + node.regex.flags);
} else if (val === null) {
this.push("null");
} else if (node.raw) {
this.push(node.raw);
}
};

View File

@@ -2,8 +2,8 @@ module.exports = Node;
var whitespace = require("./whitespace");
var parens = require("./parentheses");
var t = require("../../types");
var _ = require("lodash");
var t = require("../../types");
var _ = require("lodash");
var find = function (obj, node, parent) {
var result;
@@ -24,17 +24,14 @@ function Node(node, parent) {
}
Node.prototype.isUserWhitespacable = function () {
//var parent = this.parent;
var parent = this.parent;
var node = this.node;
if (t.isUserWhitespacable(node)) {
if (t.isUserWhitespacable(node) ||
t.isSequenceExpression(parent)) {
return true;
}
//if (t.isArrayExpression(parent)) {
// return true;
//}
return false;
};

View File

@@ -5,7 +5,7 @@ var t = require("./types");
var _ = require("lodash");
module.exports = function (namespace) {
namespace = t.identifier(namespace || "to5Runtime");
namespace = t.identifier(t.toIdentifier(namespace || "to5Runtime"));
var body = [];
var container = t.functionExpression(null, [], t.blockStatement(body));

View File

@@ -0,0 +1,4 @@
(function (strings, raw) {
return Object.defineProperties(strings, { raw: { value: raw } });
});

View File

@@ -27,37 +27,38 @@ transform.moduleFormatters = {
};
_.each({
modules: require("./transformers/modules"),
propertyNameShorthand: require("./transformers/property-name-shorthand"),
constants: require("./transformers/constants"),
arrayComprehension: require("./transformers/array-comprehension"),
generatorComprehension: require("./transformers/generator-comprehension"),
arrowFunctions: require("./transformers/arrow-functions"),
classes: require("./transformers/classes"),
modules: require("./transformers/modules"),
propertyNameShorthand: require("./transformers/property-name-shorthand"),
constants: require("./transformers/constants"),
arrayComprehension: require("./transformers/array-comprehension"),
generatorComprehension: require("./transformers/generator-comprehension"),
arrowFunctions: require("./transformers/arrow-functions"),
classes: require("./transformers/classes"),
_propertyLiterals: require("./transformers/_property-literals"),
computedPropertyNames: require("./transformers/computed-property-names"),
_propertyLiterals: require("./transformers/_property-literals"),
computedPropertyNames: require("./transformers/computed-property-names"),
spread: require("./transformers/spread"),
templateLiterals: require("./transformers/template-literals"),
propertyMethodAssignment: require("./transformers/property-method-assignment"),
defaultParameters: require("./transformers/default-parameters"),
restParameters: require("./transformers/rest-parameters"),
destructuring: require("./transformers/destructuring"),
letScoping: require("./transformers/let-scoping"),
forOf: require("./transformers/for-of"),
unicodeRegex: require("./transformers/unicode-regex"),
spread: require("./transformers/spread"),
templateLiterals: require("./transformers/template-literals"),
propertyMethodAssignment: require("./transformers/property-method-assignment"),
defaultParameters: require("./transformers/default-parameters"),
restParameters: require("./transformers/rest-parameters"),
destructuring: require("./transformers/destructuring"),
forOf: require("./transformers/for-of"),
letScoping: require("./transformers/let-scoping"),
unicodeRegex: require("./transformers/unicode-regex"),
react: require("./transformers/react"),
react: require("./transformers/react"),
_aliasFunctions: require("./transformers/_alias-functions"),
_blockHoist: require("./transformers/_block-hoist"),
_declarations: require("./transformers/_declarations"),
_aliasFunctions: require("./transformers/_alias-functions"),
_blockHoist: require("./transformers/_block-hoist"),
_declarations: require("./transformers/_declarations"),
generators: require("./transformers/generators"),
useStrict: require("./transformers/use-strict"),
generators: require("./transformers/generators"),
useStrict: require("./transformers/use-strict"),
_moduleFormatter: require("./transformers/_module-formatter")
_memberExpressionKeywords: require("./transformers/_member-expression-keywords"),
_moduleFormatter: require("./transformers/_module-formatter")
}, function (transformer, key) {
transform.transformers[key] = new Transformer(key, transformer);
});

View File

@@ -0,0 +1,10 @@
var esutils = require("esutils");
var t = require("../../types");
exports.MemberExpression = function (node) {
var prop = node.property;
if (t.isIdentifier(prop) && esutils.keyword.isKeywordES6(prop.name, true)) {
node.property = t.literal(prop.name);
node.computed = true;
}
};

View File

@@ -4,7 +4,7 @@ var t = require("../../types");
var _ = require("lodash");
exports.ClassDeclaration = function (node, parent, file, scope) {
return t.variableDeclaration("var", [
return t.variableDeclaration("let", [
t.variableDeclarator(node.id, new Class(node, file, scope).run())
]);
};

View File

@@ -7,13 +7,14 @@ exports.BlockStatement =
exports.ForInStatement =
exports.ForOfStatement =
exports.ForStatement = function (node, parent, file) {
var constants = [];
var constants = {};
var check = function (node, names) {
var check = function (node, names, parent) {
_.each(names, function (name) {
if (constants.indexOf(name) >= 0) {
throw file.errorWithNode(node, name + " is read-only");
}
if (!_.has(constants, name)) return;
if (parent && t.isBlockStatement(parent) && parent !== constants[name]) return;
throw file.errorWithNode(node, name + " is read-only");
});
};
@@ -21,12 +22,12 @@ exports.ForStatement = function (node, parent, file) {
return t.getIds(node, false, ["MemberExpression"]);
};
_.each(node.body, function (child) {
_.each(node.body, function (child, parent) {
if (child && t.isVariableDeclaration(child, { kind: "const" })) {
_.each(child.declarations, function (declar) {
_.each(getIds(declar), function (name) {
check(declar, [name]);
constants.push(name);
check(declar, [name], parent);
constants[name] = parent;
});
declar._ignoreConstant = true;
@@ -37,13 +38,13 @@ exports.ForStatement = function (node, parent, file) {
}
});
if (!constants.length) return;
if (_.isEmpty(constants)) return;
traverse(node, function (child) {
traverse(node, function (child, parent) {
if (child._ignoreConstant) return;
if (t.isVariableDeclarator(child) || t.isDeclaration(child) || t.isAssignmentExpression(child)) {
check(child, getIds(child));
if (t.isDeclaration(child) || t.isAssignmentExpression(child)) {
check(child, getIds(child), parent);
}
});
};

View File

@@ -5,17 +5,17 @@ exports.ForOfStatement = function (node, parent, file, scope) {
var left = node.left;
var declar;
var stepKey = t.identifier(file.generateUid("step", scope));
var stepValueId = t.memberExpression(stepKey, t.identifier("value"));
var stepKey = t.identifier(file.generateUid("step", scope));
var stepValue = t.memberExpression(stepKey, t.identifier("value"));
if (t.isIdentifier(left)) {
declar = t.expressionStatement(t.assignmentExpression("=", left, stepValueId));
declar = t.expressionStatement(t.assignmentExpression("=", left, stepValue));
} else if (t.isVariableDeclaration(left)) {
declar = t.variableDeclaration(left.kind, [
t.variableDeclarator(left.declarations[0].id, stepValueId)
t.variableDeclarator(left.declarations[0].id, stepValue)
]);
} else {
return;
throw file.errorWithNode(left, "Unknown node type " + left.type + " in ForOfStatement");
}
var node2 = util.template("for-of", {

View File

@@ -74,7 +74,6 @@ function LetScoping(forParent, block, parent, file, scope) {
this.letReferences = {};
this.body = [];
this.info = this.getInfo();
}
/**
@@ -87,8 +86,10 @@ LetScoping.prototype.run = function () {
if (block._letDone) return;
block._letDone = true;
this.info = this.getInfo();
// this is a block within a `Function` so we can safely leave it be
if (t.isFunction(this.parent)) return;
if (t.isFunction(this.parent)) return this.noClosure();
// this block has no let references so let's clean up
if (!this.info.keys.length) return this.noClosure();
@@ -132,7 +133,7 @@ LetScoping.prototype.run = function () {
/**
* There are no let references accessed within a closure so we can just traverse
* through this block and replace all references that exist in a high scope to
* through this block and replace all references that exist in a higher scope to
* their uids.
*/
@@ -145,11 +146,25 @@ LetScoping.prototype.noClosure = function () {
if (_.isEmpty(replacements)) return;
traverse(block, function (node, parent) {
var replace = function (node, parent) {
if (!t.isIdentifier(node)) return;
if (!t.isReferenced(node, parent)) return;
node.name = replacements[node.name] || node.name;
});
};
var traverseReplace = function (node, parent) {
replace(node, parent);
traverse(node, replace);
};
var forParent = this.forParent;
if (forParent) {
traverseReplace(forParent.right, forParent);
traverseReplace(forParent.test, forParent);
traverseReplace(forParent.update, forParent);
}
traverse(block, replace);
};
/**
@@ -181,10 +196,23 @@ LetScoping.prototype.getInfo = function () {
keys: []
};
var duplicates = function (id, key) {
var has = scope.parentGet(key);
if (has && has !== id) {
// there's a variable with this exact name in an upper scope so we need
// to generate a new name
opts.duplicates[key] = id.name = file.generateUid(key, scope);
}
};
_.each(opts.declarators, function (declar) {
opts.declarators.push(declar);
var keys = t.getIds(declar);
var keys = t.getIds(declar, true);
_.each(keys, duplicates);
keys = _.keys(keys);
opts.outsideKeys = opts.outsideKeys.concat(keys);
opts.keys = opts.keys.concat(keys);
});
@@ -193,14 +221,7 @@ LetScoping.prototype.getInfo = function () {
if (!isLet(declar)) return;
_.each(t.getIds(declar, true), function (id, key) {
var has = scope.parentGet(key);
if (has && has !== id) {
// there's a variable with this exact name in an upper scope so we need
// to generate a new name
opts.duplicates[key] = id.name = file.generateUid(key, scope);
}
duplicates(id, key);
opts.keys.push(key);
});
});
@@ -211,7 +232,8 @@ LetScoping.prototype.getInfo = function () {
/**
* If we're inside of a `For*Statement` then traverse it and check if it has one
* of the following node types `ReturnStatement`, `BreakStatement`,
* `ContinueStatement` and replace it with a return value we can track later on.
* `ContinueStatement` and replace it with a return value that we can track
* later on.
*
* @returns {Object}
*/
@@ -251,7 +273,7 @@ LetScoping.prototype.checkFor = function () {
/**
* Hoist all var declarations in this block to before it so they retain scope
* once we wrap everything is in a closure.
* once we wrap everything in a closure.
*/
LetScoping.prototype.hoistVarDeclarations = function () {
@@ -340,7 +362,7 @@ LetScoping.prototype.getLetReferences = function () {
* @returns {Array}
*/
LetScoping.prototype.buildPushDeclar = function (node) {
LetScoping.prototype.pushDeclar = function (node) {
this.body.push(t.variableDeclaration(node.kind, node.declarations.map(function (declar) {
return t.variableDeclarator(declar.id);
})));

View File

@@ -106,11 +106,35 @@ exports.XJSElement = {
exit: function (node) {
var callExpr = node.openingElement;
var childrenToRender = node.children.filter(function(child) {
return !(t.isLiteral(child) && _.isString(child.value) && child.value.match(/^[ \t]*[\r\n][ \t\r\n]*$/));
});
_.each(node.children, function (child) {
if (t.isLiteral(child)) {
var lines = child.value.split(/\r\n|\n|\r/);
_.each(lines, function (line, i) {
var isFirstLine = i === 0;
var isLastLine = i === lines.length - 1;
// replace rendered whitespace tabs with spaces
var trimmedLine = line.replace(/\t/g, ' ');
// trim whitespace touching a newline
if (!isFirstLine) {
trimmedLine = trimmedLine.replace(/^[ ]+/, '');
}
// trim whitespace touching an endline
if (!isLastLine) {
trimmedLine = trimmedLine.replace(/[ ]+$/, '');
}
if (trimmedLine) {
callExpr.arguments.push(t.literal(trimmedLine));
}
});
return;
}
_.each(childrenToRender, function (child) {
callExpr.arguments.push(child);
});

View File

@@ -5,14 +5,22 @@ var buildBinaryExpression = function (left, right) {
return t.binaryExpression("+", left, right);
};
exports.TaggedTemplateExpression = function (node) {
exports.TaggedTemplateExpression = function (node, parent, file) {
var args = [];
var quasi = node.quasi;
var strings = quasi.quasis.map(function (elem) {
return t.literal(elem.value.raw);
var strings = [];
var raw = [];
_.each(quasi.quasis, function (elem) {
strings.push(t.literal(elem.value.cooked));
raw.push(t.literal(elem.value.raw));
});
args.push(t.arrayExpression(strings));
args.push(t.callExpression(file.addDeclaration("tagged-template-literal"), [
t.arrayExpression(strings),
t.arrayExpression(raw)
]));
_.each(quasi.expressions, function (expr) {
args.push(expr);

View File

@@ -4,6 +4,8 @@ var traverse = require("./index");
var t = require("../types");
var _ = require("lodash");
var FOR_KEYS = ["left", "init"];
function Scope(parent, block) {
this.parent = parent;
this.block = block;
@@ -19,29 +21,59 @@ Scope.prototype.getIds = function () {
var self = this;
var ids = block._scopeIds = {};
if (t.isBlockStatement(block)) {
_.each(block.body, function (node) {
if (t.isVariableDeclaration(node) && node.kind !== "var") {
self.add(node, ids);
}
});
} else if (t.isProgram(block) || t.isFunction(block)) {
traverse(block, function (node, parent) {
if (parent !== block && t.isVariableDeclaration(node) && node.kind !== "var") {
return;
}
// ForStatement - left, init
if (t.isDeclaration(node)) {
self.add(node, ids);
} else if (t.isFunction(node)) {
return false;
}
if (t.isFor(block)) {
_.each(FOR_KEYS, function (key) {
var node = block[key];
if (t.isLet(node)) self.add(node, ids);
});
} else if (t.isCatchClause(block)) {
block = block.body;
}
// Program, BlockStatement - let variables
if (t.isBlockStatement(block) || t.isProgram(block)) {
_.each(block.body, function (node) {
// check for non-var `VariableDeclaration`s
if (t.isLet(node)) self.add(node, ids);
});
}
// CatchClause - param
if (t.isCatchClause(block)) {
self.add(block.param, ids);
}
// Program, Function - var variables
if (t.isProgram(block) || t.isFunction(block)) {
traverse(block, function (node) {
if (t.isFor(node)) {
_.each(FOR_KEYS, function (key) {
var declar = node[key];
if (t.isVar(declar)) self.add(declar, ids);
});
}
// this block is a function so we'll stop since none of the variables
// declared within are accessible
if (t.isFunction(node)) return false;
// we've ran into a declaration!
// we'll let the BlockStatement scope deal with `let` declarations
if (t.isDeclaration(node) && !t.isLet(node)) {
self.add(node, ids);
}
});
}
// Function - params
if (t.isFunction(block)) {
this.add(block.rest, ids);
_.each(block.params, function (param) {
self.add(param, ids);
});
@@ -51,6 +83,7 @@ Scope.prototype.getIds = function () {
};
Scope.prototype.add = function (node, ids) {
if (!node) return;
_.merge(ids || this.ids, t.getIds(node, true));
};

View File

@@ -35,12 +35,13 @@
"ClassDeclaration": ["Statement", "Declaration", "Class"],
"ClassExpression": ["Class"],
"ForOfStatement": ["Statement", "For"],
"ForInStatement": ["Statement", "For"],
"ForStatement": ["Statement", "For"],
"ForOfStatement": ["Statement", "For", "Scope"],
"ForInStatement": ["Statement", "For", "Scope"],
"ForStatement": ["Statement", "For", "Scope"],
"ObjectPattern": ["Pattern"],
"ArrayPattern": ["Pattern"],
"Property": ["UserWhitespacable"]
"Property": ["UserWhitespacable"],
"XJSElement": ["UserWhitespacable"]
}

View File

@@ -106,6 +106,10 @@ t.ensureBlock = function (node) {
};
t.toStatement = function (node, ignore) {
if (t.isStatement(node)) {
return node;
}
var mustHaveId = false;
var newType;
@@ -115,8 +119,6 @@ t.toStatement = function (node, ignore) {
} else if (t.isFunction(node)) {
mustHaveId = true;
newType = "FunctionDeclaration";
} else if (t.isStatement(node)) {
newType = node.type;
}
if (mustHaveId && !node.id) {
@@ -183,6 +185,14 @@ t.getIds = function (node, map, ignoreTypes) {
return ids;
};
t.isLet = function (node) {
return t.isVariableDeclaration(node) && (node.kind !== "var" || node._let);
};
t.isVar = function (node) {
return t.isVariableDeclaration(node, { kind: "var" }) && !node._let;
};
t.getIds.nodes = {
AssignmentExpression: "left",
ImportSpecifier: "id",

View File

@@ -17,6 +17,10 @@ exports.canCompile = function (filename, altExts) {
return _.contains(exts, ext);
};
exports.isInteger = function (i) {
return _.isNumber(i) && i % 1 === 0;
};
exports.resolve = function (loc) {
try {
return require.resolve(loc);
@@ -123,23 +127,17 @@ exports.template = function (name, nodes, keepExpression) {
template = _.cloneDeep(template);
var inherits = false;
if (nodes) {
inherits = nodes.inherits;
delete nodes.inherits;
if (!_.isEmpty(nodes)) {
traverse(template, function (node) {
if (t.isIdentifier(node) && _.has(nodes, node.name)) {
var newNode = nodes[node.name];
if (_.isString(newNode)) {
node.name = newNode;
} else {
return newNode;
}
if (!_.isEmpty(nodes)) {
traverse(template, function (node) {
if (t.isIdentifier(node) && _.has(nodes, node.name)) {
var newNode = nodes[node.name];
if (_.isString(newNode)) {
node.name = newNode;
} else {
return newNode;
}
});
}
}
});
}
var node = template.body[0];
@@ -150,10 +148,6 @@ exports.template = function (name, nodes, keepExpression) {
if (t.isParenthesizedExpression(node)) node = node.expression;
}
if (inherits) {
node = t.inherits(node, inherits);
}
return node;
};

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "1.12.8",
"version": "1.12.14",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://github.com/6to5/6to5",
"repository": {
@@ -44,7 +44,7 @@
"es6-symbol": "0.1.1",
"regexpu": "0.3.0",
"source-map": "0.1.40",
"regenerator-6to5": "https://github.com/6to5/regenerator-6to5/archive/75925940a7bb67d1ee8afec36b6d6eec072fb47c.tar.gz",
"regenerator-6to5": "https://github.com/6to5/regenerator-6to5/archive/a9c53518af063ffef410f826225f8ee250131932.tar.gz",
"chokidar": "0.10.5",
"source-map-support": "0.2.8",
"esutils": "1.1.4",

View File

@@ -36,8 +36,6 @@ exports.get = function (entryName) {
if (fs.existsSync(suiteOptsLoc)) suite.options = require(suiteOptsLoc);
_.each(fs.readdirSync(suite.filename), function (taskName) {
if (taskName[0] === ".") return;
var taskDir = suite.filename + "/" + taskName;
if (fs.statSync(taskDir).isFile()) return;
@@ -59,6 +57,7 @@ exports.get = function (entryName) {
var test = {
title: humanise(taskName),
disabled: taskName[0] === ".",
options: taskOpts,
exec: {
code: readFile(execLoc),

17
test/api.js Normal file
View File

@@ -0,0 +1,17 @@
var transform = require("../lib/6to5/transformation/transform");
var assert = require("assert");
var File = require("../lib/6to5/file");
suite("api", function () {
test("{ code: false }", function () {
var result = transform("foo('bar');", { code: false });
assert.ok(!result.code);
});
test("addDeclaration unknown", function () {
var file = new File;
assert.throws(function () {
file.addDeclaration("foob");
}, /unknown declaration foob/);
});
});

View File

@@ -1,3 +0,0 @@
var multiples = [for (num of nums) num * num];
var multiples = [for (num of nums) for (num2 of nums) num * num];
var multiples = [for (num of nums) if (num > 5) num * num];

View File

@@ -1,3 +0,0 @@
var multiples = [for (num of nums) num * num];
var multiples = [for (num of nums) for (num2 of nums) num * num];
var multiples = [for (num of nums) if (num > 5) num * num];

View File

@@ -1 +0,0 @@
var foo = [1, 2, 3];

View File

@@ -1 +0,0 @@
var foo = [1, 2, 3];

View File

@@ -1,17 +0,0 @@
var foo = `i
am a multiline string`;
var foo = `i am also
a multiline string
foobar`;
var foo = `im a single line string`;
var foo = tagit`i
am a multiline string`;
var foo = tagit`i am also
a multiline string
foobar`;
var foo = tagit`im a single line string`;

View File

@@ -1,17 +0,0 @@
var foo = `i
am a multiline string`;
var foo = `i am also
a multiline string
foobar`;
var foo = `im a single line string`;
var foo = tagit`i
am a multiline string`;
var foo = tagit`i am also
a multiline string
foobar`;
var foo = tagit`im a single line string`;

View File

@@ -4,6 +4,6 @@ export { a as b, c as d } from "hello";
export { a as b, c as d };
export {};
export default i = 20;
export function test() {};
export function test() {}
export var i = 20;
export let i = 42;

View File

@@ -0,0 +1,5 @@
[a, b, c];
[[], [b, c], []];
[a,, b,];
[a,,,, b];
[a, b,, c];

View File

@@ -0,0 +1,5 @@
[a, b, c];
[[], [b, c], []];
[a,, b];
[a,,,, b];
[a, b,, c];

View File

@@ -0,0 +1,4 @@
var foo = x => x * x;
var foo = (a, b) => a * b;
var foo = async x => x * x;
var foo = async (a, b) => a * b;

View File

@@ -0,0 +1,4 @@
var foo = x => x * x;
var foo = (a, b) => a * b;
var foo = async x => x * x;
var foo = async (a, b) => a * b;

View File

@@ -0,0 +1,3 @@
foo === bar;
foo + bar;
foo = bar;

View File

@@ -0,0 +1,3 @@
foo === bar;
foo + bar;
foo = bar;

View File

@@ -0,0 +1,7 @@
async function foo() {
await bar();
}
async function bar() {
await* foo();
}

View File

@@ -0,0 +1,7 @@
async function foo() {
await bar();
}
async function bar() {
await* foo();
}

View File

@@ -0,0 +1,5 @@
{}
{
foo();
}

View File

@@ -0,0 +1,5 @@
{}
{
foo();
}

View File

@@ -0,0 +1,7 @@
for (var i in foo) {
break;
}
foo: for (var i in foo) {
break foo;
}

View File

@@ -0,0 +1,7 @@
for (var i in foo) {
break;
}
foo: for (var i in foo) {
break foo;
}

View File

@@ -0,0 +1,5 @@
foo();
foo("foo");
foo("foo", "bar");
foo(bar());
foo(bar("test"));

View File

@@ -0,0 +1,5 @@
foo();
foo("foo");
foo("foo", "bar");
foo(bar());
foo(bar("test"));

View File

@@ -0,0 +1,13 @@
class Foo {
async foo() {}
foo() {}
["foo"]() {}
get foo() {}
set foo() {}
static async foo() {}
static foo() {}
static ["foo"]() {}
static get foo() {}
static set foo() {}
}

View File

@@ -0,0 +1,13 @@
class Foo {
async foo() {}
foo() {}
["foo"]() {}
get foo() {}
set foo() {}
static async foo() {}
static foo() {}
static ["foo"]() {}
static get foo() {}
static set foo() {}
}

View File

@@ -0,0 +1,2 @@
var foo = class Foo {};
var foo = class Foo extends Bar {};

View File

@@ -0,0 +1,2 @@
var foo = class Foo {};
var foo = class Foo extends Bar {};

View File

@@ -0,0 +1,2 @@
class Foo {}
class Foo extends Bar {}

View File

@@ -0,0 +1,2 @@
class Foo {}
class Foo extends Bar {}

View File

@@ -0,0 +1,9 @@
[for (x of nums) x * x];
[for (x of nums) if (x > 2) x * x];
[for (nums of nums2) for (x of nums) x * x];
[for (nums of nums2) for (x of nums) if (x > 2) x * x];
(for (x of nums) x * x);
(for (x of nums) if (x > 2) x * x);
(for (nums of nums2) for (x of nums) x * x);
(for (nums of nums2) for (x of nums) if (x > 2) x * x);

View File

@@ -0,0 +1,9 @@
[for (x of nums) x * x];
[for (x of nums) if (x > 2) x * x];
[for (nums of nums2) for (x of nums) x * x];
[for (nums of nums2) for (x of nums) if (x > 2) x * x];
(for (x of nums) x * x);
(for (x of nums) if (x > 2) x * x);
(for (nums of nums2) for (x of nums) x * x);
(for (nums of nums2) for (x of nums) if (x > 2) x * x);

View File

@@ -0,0 +1 @@
foo ? foo : bar;

View File

@@ -0,0 +1 @@
foo ? foo : bar;

View File

@@ -0,0 +1,7 @@
for (var i in foo) {
continue;
}
foo: for (var i in foo) {
continue foo;
}

View File

@@ -0,0 +1,7 @@
for (var i in foo) {
continue;
}
foo: for (var i in foo) {
continue foo;
}

View File

@@ -0,0 +1 @@
debugger;

View File

@@ -0,0 +1 @@
debugger;

View File

@@ -0,0 +1,5 @@
do {
test();
} while (true);
do {} while (true);

View File

@@ -0,0 +1,5 @@
do {
test();
} while (true);
do {} while (true);

View File

@@ -0,0 +1 @@
;

View File

@@ -0,0 +1 @@
;

View File

@@ -0,0 +1,27 @@
export default 42;
export default {};
export default [];
export default foo;
export default function () {};
export default class {};
export default function foo() {};
export default class Foo {};
export * from "foo";
export { foo } from "foo";
export { foo, bar } from "foo";
export { foo as bar } from "foo";
export { foo as default } from "foo";
export { foo as default, bar } from "foo";
export { foo };
export { foo, bar };
export { foo as bar };
export { foo as default };
export { foo as default, bar };
export var foo = 1;
export var foo2 = function () {};
export var foo3;
export let foo4 = 2;
export let foo5;
export const foo6 = 3;
export function foo7() {}
export class foo8 {}

View File

@@ -0,0 +1,27 @@
export default 42;
export default {};
export default [];
export default foo;
export default function () {};
export default class {};
export default function foo() {};
export default class Foo {};
export * from "foo";
export { foo } from "foo";
export { foo, bar } from "foo";
export { foo as bar } from "foo";
export { foo as default } from "foo";
export { foo as default, bar } from "foo";
export { foo };
export { foo, bar };
export { foo as bar };
export { foo as default };
export { foo as default, bar };
export var foo = 1;
export var foo2 = function () {};
export var foo3;
export let foo4 = 2;
export let foo5;
export const foo6 = 3;
export function foo7() {}
export class foo8 {}

View File

@@ -0,0 +1,5 @@
for (var i in nums) {}
for (var i in nums) {
nums[i] = nums[i] * nums[i];
}

View File

@@ -0,0 +1,5 @@
for (var i in nums) {}
for (var i in nums) {
nums[i] = nums[i] * nums[i];
}

View File

@@ -0,0 +1,5 @@
for (var x of nums) {}
for (var x of nums) {
console.log(x * x);
}

View File

@@ -0,0 +1,5 @@
for (var x of nums) {}
for (var x of nums) {
console.log(x * x);
}

View File

@@ -0,0 +1,3 @@
for (var i = 0;;) {}
for (var i = 0; i < 5;) {}
for (var i = 0; i < 5; i++) {}

View File

@@ -0,0 +1,3 @@
for (var i = 0;;) {}
for (var i = 0; i < 5;) {}
for (var i = 0; i < 5; i++) {}

View File

@@ -0,0 +1,23 @@
function foo(bar = "bar") {}
function foo(bar = "bar", ...items) {}
function foo(...items) {}
function* foo() {}
function foo() {}
async function foo() {}
var foo = function* foo() {};
var foo = function foo() {};
var foo = async function foo() {};
var foo = function* () {};
var foo = function () {};
var foo = async function () {};

View File

@@ -0,0 +1,23 @@
function foo(bar = "bar") {}
function foo(bar = "bar", ...items) {}
function foo(...items) {}
function* foo() {}
function foo() {}
async function foo() {}
var foo = function* foo() {};
var foo = function foo() {};
var foo = async function foo() {};
var foo = function* () {};
var foo = function () {};
var foo = async function () {};

View File

@@ -0,0 +1,2 @@
foo;
undefined;

View File

@@ -0,0 +1,2 @@
foo;
undefined;

View File

@@ -0,0 +1,25 @@
if (foo) foobar();
if (foo) {
foobar();
}
if (foo) {}
if (foo) {
foo();
} else bar();
if (foo) {
foo();
} else {
bar();
}
if (foo) {
foo();
} else if (bar) {
foobar();
} else {
bar();
}

View File

@@ -0,0 +1,25 @@
if (foo) foobar();
if (foo) {
foobar();
}
if (foo) {}
if (foo) {
foo();
} else bar();
if (foo) {
foo();
} else {
bar();
}
if (foo) {
foo();
} else if (bar) {
foobar();
} else {
bar();
}

View File

@@ -0,0 +1,9 @@
import "foo";
import foo from "foo";
import { default as foo } from "foo";
import * as foo from "foo";
import foo, { baz as xyz } from "foo";
import { bar } from "foo";
import { bar, baz } from "foo";
import { bar as baz } from "foo";
import { bar as baz, xyz } from "foo";

Some files were not shown because too many files have changed in this diff Show More