Compare commits

..

30 Commits

Author SHA1 Message Date
Sebastian McKenzie
afdde8b3a7 v2.2.0 2014-12-29 12:48:45 +11:00
Sebastian McKenzie
918ddb4124 disable system tests temporairly 2014-12-29 11:16:47 +11:00
Sebastian McKenzie
18739ad78b remove unused variable 2014-12-29 11:15:24 +11:00
Sebastian McKenzie
74a84e2473 fix duplicate comments being output, breaking code 2014-12-29 11:13:50 +11:00
Sebastian McKenzie
52ffc65a06 make system module formatter modules anonymous by default - fixes #347 2014-12-29 01:55:30 +11:00
Sebastian McKenzie
d4fbfbbe47 Merge pull request #348 from guybedford/system
System test adjustments
2014-12-29 01:51:16 +11:00
Sebastian McKenzie
781467d423 v2.1.0 2014-12-29 01:41:05 +11:00
Sebastian McKenzie
44f5b7d013 fix case statement newline in code generator test 2014-12-29 01:39:04 +11:00
Sebastian McKenzie
dcf7f0b70b fix newline in case statement test 2014-12-29 01:37:19 +11:00
Sebastian McKenzie
03efd69998 check if node exists before inheriting comments to it 2014-12-29 01:37:12 +11:00
Sebastian McKenzie
213003a007 fix new templates path in dotfiles 2014-12-29 01:34:49 +11:00
Sebastian McKenzie
b0503f2efe add 2.1.0 changelog 2014-12-29 01:33:58 +11:00
Sebastian McKenzie
c8cf7ff286 better blacklist tests and expose register cache - closes #344 2014-12-29 01:31:26 +11:00
Sebastian McKenzie
ceb32816d7 fix destructuring in switch/case statements - closes #346 2014-12-29 01:26:51 +11:00
Sebastian McKenzie
32b94899a6 update runtime script to runtime generator 2014-12-29 01:26:21 +11:00
Sebastian McKenzie
d951082b09 move replacement node comment inheritance to traverse replacement 2014-12-29 01:26:11 +11:00
Sebastian McKenzie
b49f6e33d6 fix newline on case statement 2014-12-29 01:25:56 +11:00
Sebastian McKenzie
c5fa6425a5 explicit canRun for hidden transformers 2014-12-29 01:25:15 +11:00
Sebastian McKenzie
70d896d609 rename runtime script to runtime-generator 2014-12-29 01:24:57 +11:00
Sebastian McKenzie
e00fa8c9b1 update core-js 2014-12-29 01:24:41 +11:00
Sebastian McKenzie
13933bc9b8 move templates folder into transformation folder 2014-12-29 01:24:35 +11:00
guybedford
295bab544b re-exporting in setters 2014-12-28 14:43:56 +02:00
guybedford
cfe05ca10d exported variable declarations hoist along with functions 2014-12-28 14:41:32 +02:00
guybedford
da72182219 make modules anonymous 2014-12-28 14:38:52 +02:00
Sebastian McKenzie
005f5b2174 v2.0.4 2014-12-28 11:06:04 +11:00
Sebastian McKenzie
8551c94fa0 fix linting errors 2014-12-28 11:05:27 +11:00
Sebastian McKenzie
c509d06bc2 vaoid being greedy when destructuring array iterables 2014-12-28 11:04:00 +11:00
Sebastian McKenzie
f21743012b v2.0.3 2014-12-28 09:37:32 +11:00
Sebastian McKenzie
22dc33f93c remove unused variable 2014-12-28 09:36:29 +11:00
Sebastian McKenzie
6df6652629 better circular references in amd/umd/system module formatter 2014-12-28 09:35:47 +11:00
100 changed files with 378 additions and 153 deletions

View File

@@ -1,3 +1,3 @@
node_modules
test
lib/6to5/templates
lib/6to5/transformation/templates

View File

@@ -1,7 +1,7 @@
node_modules
*.log
*.cache
lib/6to5/templates
lib/6to5/transformation/templates
test
benchmark
Makefile

View File

@@ -2,6 +2,27 @@
Gaps between patch versions are faulty/broken releases.
## 2.2.0
* Make `system` module formatter modules anonymous by default.
* Fix duplicate comments being output, breaking code.
## 2.1.0
* Add `cache` option to register hook.
* Update `core-js`.
* Fix starting newline not being added on case statements.
* Fix destructuring `VariableDeclaration`s not inside `BlockStatement`s and `Program`.
## 2.0.4
* Avoid being greedy when destructuring array iterables.
## 2.0.3
* Hoist function declarations in system module formatter for circular references.
* Hoist default function declarations in umd and amd module formatters for circular references.
## 2.0.2
* Inherit comments in `for-of` transformer.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env node
var runtime = require("../lib/6to5/runtime");
var runtime = require("../lib/6to5/runtime-generator");
console.log(runtime(process.argv[2]));

View File

@@ -20,7 +20,8 @@ commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NO
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
commander.option("-c, --remove-comments", "Remove comments from the compiled code", false);
commander.option("-a, --amd-module-ids", "Insert module id in AMD modules", false);
commander.option("-a, --amd-module-ids", "Insert module id in AMD modules", false); // todo: remove in 3.0.0
commander.option("-m, --module-ids", "Insert module id in modules", false);
commander.on("--help", function(){
var outKeys = function (title, obj) {
@@ -89,9 +90,9 @@ if (errors.length) {
exports.opts = {
sourceMapName: commander.outFile,
amdModuleIds: commander.amdModuleIds,
experimental: commander.experimental,
playground: commander.playground,
moduleIds: commander.amdModuleIds || commander.moduleIds,
blacklist: commander.blacklist,
whitelist: commander.whitelist,
sourceMap: commander.sourceMaps || commander.sourceMapsInline,

View File

@@ -152,10 +152,10 @@ result.ast;
// Default: `sourceRoot` option.
moduleRoot: "my-app",
// If truthy, insert an explicit id for each defined AMD module.
// By default, AMD modules are anonymous.
// If truthy, insert an explicit id for each defined AMD/System module.
// By default, AMD/System modules are anonymous.
// Default: false
amdModuleIds: true,
moduleIds: true,
// Optionally replace all 6to5 helper declarations with a referenece to this
// variable. If set to `true` then the default namespace is used "to5Runtime".
@@ -250,6 +250,10 @@ require("6to5/register")({
// This will remove the currently hooked extensions of .es6 and .js so you'll
// have to add them back if you want them to be used again.
extensions: [".js", ".es6"]
extensions: [".js", ".es6"],
// Enables `roadrunner` cache that will save to a `.roadrunner.json` file in your cwd
// Do not check this into git as it's user-specific
cache: true
});
```

View File

@@ -22,6 +22,7 @@ File.declarations = [
"tagged-template-literal",
"interop-require",
"to-array",
"sliced-to-array",
"object-without-properties",
"has-own",
"slice"
@@ -34,6 +35,7 @@ File.normaliseOptions = function (opts) {
experimental: false,
playground: false,
whitespace: true,
moduleIds: opts.amdModuleIds || false,
blacklist: [],
whitelist: [],
sourceMap: false,
@@ -82,13 +84,19 @@ File.normaliseOptions = function (opts) {
return opts;
};
File.prototype.toArray = function (node) {
File.prototype.toArray = function (node, i) {
if (t.isArrayExpression(node)) {
return node;
} else if (t.isIdentifier(node) && node.name === "arguments") {
return t.callExpression(t.memberExpression(this.addDeclaration("slice"), t.identifier("call")), [node]);
} else {
return t.callExpression(this.addDeclaration("to-array"), [node]);
var declarationName = "to-array";
var args = [node];
if (i) {
args.push(t.literal(i));
declarationName = "sliced-to-array";
}
return t.callExpression(this.addDeclaration(declarationName), args);
}
};

View File

@@ -146,7 +146,7 @@ exports.SwitchCase = function (node, print) {
this.push("default:");
}
this.space();
this.newline();
print.sequence(node.consequent, { indent: true });
};

View File

@@ -7,7 +7,7 @@ exports.Transformer = require("./transformation/transformer");
exports.types = require("./types");
exports.runtime = require("./runtime");
exports.runtime = require("./runtime-generator");
exports.register = function (opts) {
var register = require("./register");

View File

@@ -1,6 +1,7 @@
require("./polyfill");
var sourceMapSupport = require("source-map-support");
var roadrunner = require("roadrunner");
var util = require("./util");
var to5 = require("./index");
var fs = require("fs");
@@ -38,15 +39,22 @@ var blacklistTest = function (transformer, code) {
};
blacklistTest("arrayComprehension", "var foo = [for (foo of bar) foo * foo];");
//blacklistTest("generatorComprehension", "");
blacklistTest("generatorComprehension", "var foo = (for (foo of bar) foo * foo)");
blacklistTest("arrowFunctions", "var foo = x => x * x;");
blacklistTest("classes", "class Foo {}");
blacklistTest("computedPropertyNames", "var foo = { [foo]: bar };");
//blacklistTest("constants", "const foo = 0;");
blacklistTest("constants", function () {
try {
new Function("const foo = 'foo';\nfoo = 'wow';");
} catch (err) {
return; // constants are supported
}
throw new SyntaxError;
});
blacklistTest("defaultParamaters", "var foo = function (bar = 0) {};");
blacklistTest("destructuring", "var { x, y } = { x: 0, y: 0 };");
blacklistTest("forOf", "for (var foo of bar) {}");
blacklistTest("generators", "function* foo() {}");
blacklistTest("generators", "function* foo() {}\nasync function bar() {}"); // generators/async functions delegated to same transformer
blacklistTest("letScoping", "let foo = 0;");
blacklistTest("modules", 'import foo from "from";');
blacklistTest("propertyMethodAssignment", "{ get foo() {} }");
@@ -130,6 +138,11 @@ module.exports = function (opts) {
if (opts.cache) cache = opts.cache;
if (opts.cache === false) cache = null;
if (opts.cache === true) {
roadrunner.load();
roadrunner.setup();
cache = roadrunner.get("6to5");
}
_.extend(transformOpts, opts);
};

View File

@@ -169,30 +169,36 @@ DefaultFormatter.prototype._exportsAssign = function (id, init) {
DefaultFormatter.prototype.exportDeclaration = function (node, nodes) {
var declar = node.declaration;
var id = declar.id;
if (node.default) {
nodes.push(
this._exportsAssign(t.identifier("default"), this._pushStatement(declar, nodes))
);
} else {
var assign;
id = t.identifier("default");
}
if (t.isVariableDeclaration(declar)) {
for (var i in declar.declarations) {
var decl = declar.declarations[i];
var assign;
decl.init = this._exportsAssign(decl.id, decl.init).expression;
if (t.isVariableDeclaration(declar)) {
for (var i in declar.declarations) {
var decl = declar.declarations[i];
var newDeclar = t.variableDeclaration(declar.kind, [decl]);
if (i === "0") t.inherits(newDeclar, declar);
nodes.push(newDeclar);
}
} else {
assign = this._exportsAssign(declar.id, declar.id);
decl.init = this._exportsAssign(decl.id, decl.init).expression;
nodes.push(t.toStatement(declar));
nodes.push(assign);
this._hoistExport(declar, assign);
var newDeclar = t.variableDeclaration(declar.kind, [decl]);
if (i === "0") t.inherits(newDeclar, declar);
nodes.push(newDeclar);
}
} else {
var ref = declar;
if (t.isFunctionDeclaration(declar) || t.isClassDeclaration(declar)) {
ref = declar.id;
nodes.push(declar);
}
assign = this._exportsAssign(id, ref);
nodes.push(assign);
this._hoistExport(declar, assign);
}
};

View File

@@ -55,7 +55,7 @@ AMDFormatter.prototype.transform = function (ast) {
*/
AMDFormatter.prototype.getModuleName = function () {
if (this.file.opts.amdModuleIds) {
if (this.file.opts.moduleIds) {
return DefaultFormatter.prototype.getModuleName.apply(this, arguments);
} else {
return null;

View File

@@ -1,24 +1,20 @@
module.exports = SystemFormatter;
var DefaultFormatter = require("./_default");
var AMDFormatter = require("./amd");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
var AMDFormatter = require("./amd");
var traverse = require("../../traverse");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
function SystemFormatter(file) {
this.exportIdentifier = file.generateUidIdentifier("export");
this.noInteropRequire = true;
AMDFormatter.apply(this, arguments);
this.moduleNameLiteral = t.literal(this.getModuleName());
}
util.inherits(SystemFormatter, AMDFormatter);
SystemFormatter.prototype.getModuleName = DefaultFormatter.prototype.getModuleName;
SystemFormatter.prototype._exportsWildcard = function (objectIdentifier) {
var leftIdentifier = t.identifier("i");
var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);
@@ -66,20 +62,41 @@ SystemFormatter.prototype.buildRunnerSetters = function () {
SystemFormatter.prototype.transform = function (ast) {
var program = ast.program;
var moduleName = this.getModuleName();
var moduleNameLiteral = t.literal(moduleName);
var runner = util.template("system", {
MODULE_NAME: this.moduleNameLiteral,
MODULE_NAME: moduleNameLiteral,
MODULE_DEPENDENCIES: t.arrayExpression(this.buildDependencyLiterals()),
EXPORT_IDENTIFIER: this.exportIdentifier,
SETTERS: this.buildRunnerSetters(),
EXECUTE: t.functionExpression(null, [], t.blockStatement(program.body))
}, true);
var handlerBody = runner.expression.arguments[2].body.body;
if (!moduleName) runner.expression.arguments.shift();
var returnStatement = handlerBody.pop();
// hoist up function declarations for circular references
traverse(program, {
enter: function (node) {
if (t.isFunction(node)) this.stop();
if (t.isFunctionDeclaration(node) || node._blockHoist) {
handlerBody.push(node);
this.remove();
}
}
});
if (!_.isEmpty(this.ids)) {
var handlerBody = runner.expression.arguments[2].body.body;
handlerBody.unshift(t.variableDeclaration("var", _.map(this.ids, function (uid) {
handlerBody.push(t.variableDeclaration("var", _.map(this.ids, function (uid) {
return t.variableDeclarator(uid);
})));
}
handlerBody.push(returnStatement);
program.body = [runner];
};

View File

@@ -0,0 +1,12 @@
(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;
}
});

View File

@@ -72,14 +72,13 @@ Transformer.prototype.transform = function (file) {
Transformer.prototype.canRun = function (file) {
var opts = file.opts;
var key = this.key;
if (key[0] === "_") return true;
var blacklist = opts.blacklist;
if (blacklist.length && _.contains(blacklist, key)) return false;
if (key[0] !== "_") {
var whitelist = opts.whitelist;
if (whitelist.length && !_.contains(whitelist, key)) return false;
}
var whitelist = opts.whitelist;
if (whitelist.length && !_.contains(whitelist, key)) return false;
return true;
};

View File

@@ -61,13 +61,27 @@ var pushObjectPattern = function (opts, nodes, pattern, parentId) {
};
var pushArrayPattern = function (opts, nodes, pattern, parentId) {
if (!pattern.elements) return;
var i;
var hasSpreadElement = false;
for (i in pattern.elements) {
if (t.isSpreadElement(pattern.elements[i])) {
hasSpreadElement = true;
break;
}
}
var toArray = opts.file.toArray(parentId, !hasSpreadElement && pattern.elements.length);
var _parentId = opts.file.generateUidIdentifier("ref", opts.scope);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(_parentId, opts.file.toArray(parentId))
t.variableDeclarator(_parentId, toArray)
]));
parentId = _parentId;
for (var i in pattern.elements) {
for (i in pattern.elements) {
var elem = pattern.elements[i];
if (!elem) continue;
@@ -254,6 +268,7 @@ exports.VariableDeclaration = function (node, parent, file, scope) {
}
if (!t.isProgram(parent) && !t.isBlockStatement(parent)) {
declar = null;
for (i in nodes) {
node = nodes[i];

View File

@@ -1,26 +1,16 @@
var t = require("../../types");
var inheritsComments = function (node, nodes) {
if (nodes.length) {
t.inheritsComments(nodes[0], node);
}
};
exports.ImportDeclaration = function (node, parent, file) {
var nodes = [];
if (node.specifiers.length) {
if (!file.moduleFormatter.importSpecifier) return;
for (var i in node.specifiers) {
file.moduleFormatter.importSpecifier(node.specifiers[i], node, nodes, parent);
}
} else {
if (!file.moduleFormatter.importDeclaration) return;
file.moduleFormatter.importDeclaration(node, nodes, parent);
}
inheritsComments(node, nodes);
return nodes;
};
@@ -35,16 +25,12 @@ exports.ExportDeclaration = function (node, parent, file) {
declar.init = declar.init || t.identifier("undefined");
}
if (!file.moduleFormatter.exportDeclaration) return;
file.moduleFormatter.exportDeclaration(node, nodes, parent);
} else {
if (!file.moduleFormatter.exportSpecifier) return;
for (var i in node.specifiers) {
file.moduleFormatter.exportSpecifier(node.specifiers[i], node, nodes, parent);
}
}
inheritsComments(node, nodes);
return nodes;
};

View File

@@ -42,19 +42,35 @@ function traverse(parent, opts, scope) {
if (result != null) {
updated = true;
var isArray = _.isArray(result);
// inherit comments from original node to the first replacement node
var inheritTo = result;
if (isArray) inheritTo = result[0];
if (inheritTo) t.inheritsComments(inheritTo, node);
// replace the node
node = obj[key] = result;
if (_.isArray(result) && _.contains(t.STATEMENT_OR_BLOCK_KEYS, key) && !t.isBlockStatement(obj)) {
// we're replacing a statement or block node with an array of statements so we better
// ensure that it's a block
if (isArray && _.contains(t.STATEMENT_OR_BLOCK_KEYS, key) && !t.isBlockStatement(obj)) {
t.ensureBlock(obj, key);
}
}
};
var stop = false;
var stopped = false;
var removed = false;
var context = {
stop: function () {
stop = true;
stopped = true;
},
remove: function () {
stopped = removed = true;
}
};
@@ -67,8 +83,13 @@ function traverse(parent, opts, scope) {
var result = opts.enter.call(context, node, parent, ourScope);
maybeReplace(result);
if (removed) {
delete obj[key];
updated = true;
}
// stop iteration
if (stop || result === false) return;
if (stopped || result === false) return;
}
// traverse node

View File

@@ -293,8 +293,9 @@ t.removeComments = function (child) {
};
t.inheritsComments = function (child, parent) {
child.leadingComments = _.compact([].concat(child.leadingComments, parent.leadingComments));
child.trailingComments = _.compact([].concat(child.trailingComments, parent.trailingComments));
_.each(["leadingComments", "trailingComments"], function (key) {
child[key] = _.uniq(_.compact([].concat(child[key], parent[key])));
});
return child;
};

View File

@@ -268,7 +268,7 @@ exports.parseTemplate = function (loc, code) {
var loadTemplates = function () {
var templates = {};
var templatesLoc = __dirname + "/templates";
var templatesLoc = __dirname + "/transformation/templates";
if (!fs.existsSync(templatesLoc)) {
throw new Error("no templates directory - this is most likely the " +
"result of a broken `npm publish`. Please report to " +

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "2.0.2",
"version": "2.2.0",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://github.com/6to5/6to5",
"repository": {
@@ -39,7 +39,7 @@
"ast-types": "~0.6.1",
"chokidar": "0.11.1",
"commander": "2.5.0",
"core-js": "^0.3.2",
"core-js": "^0.3.3",
"estraverse": "1.8.0",
"esutils": "1.1.6",
"fs-readdir-recursive": "0.1.0",

View File

@@ -33,7 +33,10 @@ switch (foo) {
}
switch (foo) {
case "foo": foo();
case "bar": bar();
default: yay();
case "foo":
foo();
case "bar":
bar();
default:
yay();
}

View File

@@ -1,4 +1,7 @@
System.register("es6-modules-system/exports-default/expected", [], function (_export) {
System.register([], function (_export) {
_export("default", foo);
function foo() {}
return {
setters: [],
execute: function () {
@@ -16,12 +19,9 @@ System.register("es6-modules-system/exports-default/expected", [], function (_ex
_export("default", function () {});
function foo() {}
_export("default", foo);
var Foo = function Foo() {};
_export("default", Foo);
}
};
});
});

View File

@@ -1,16 +1,12 @@
System.register("es6-modules-system/exports-from/expected", ["foo"], function (_export) {
System.register(["foo"], function (_export) {
var _foo;
return {
setters: [function (m) {
_foo = m
}],
execute: function () {
"use strict";
for (var i in _foo) {
_export(i, _foo[i])
}
_export("foo", _foo.foo);
_export("foo", _foo.foo);
@@ -24,6 +20,10 @@ System.register("es6-modules-system/exports-from/expected", ["foo"], function (_
_export("default", _foo.foo);
_export("bar", _foo.bar);
}],
execute: function () {
"use strict";
}
};
});

View File

@@ -1,4 +1,4 @@
System.register("es6-modules-system/exports-named/expected", [], function (_export) {
System.register([], function (_export) {
return {
setters: [],
execute: function () {

View File

@@ -1,21 +1,21 @@
System.register("es6-modules-system/exports-variable/expected", [], function (_export) {
System.register([], function (_export) {
_export("foo7", foo7);
function foo7() {}
return {
setters: [],
execute: function () {
"use strict";
_export("foo7", foo7);
var foo = _export("foo", 1);
var foo2 = _export("foo2", function () {});
var foo3 = _export("foo3", undefined);
var foo4 = _export("foo4", 2);
var foo5 = _export("foo5", undefined);
var foo6 = _export("foo6", 3);
function foo7() {}
var foo8 = function foo8() {};
_export("foo8", foo8);
}
};
});
});

View File

@@ -1,9 +1,11 @@
import { isEven } from "./evens";
export function nextOdd(n) {
return isEven(n) ? n + 1 : n + 2;
return p = isEven(n) ? n + 1 : n + 2;
}
export var p = 5;
export var isOdd = (function (isEven) {
return function (n) {
return !isEven(n);

View File

@@ -1,4 +1,12 @@
System.register("es6-modules-system/hoist-function-exports/expected", ["./evens"], function (_export) {
System.register(["./evens"], function (_export) {
var p;
_export("nextOdd", nextOdd);
function nextOdd(n) {
return _export("p", p = isEven(n) ? n + 1 : n + 2);
}
var _evens;
return {
setters: [function (m) {
@@ -7,12 +15,8 @@ System.register("es6-modules-system/hoist-function-exports/expected", ["./evens"
execute: function () {
"use strict";
_export("nextOdd", nextOdd);
var isEven = _evens.isEven;
function nextOdd(n) {
return isEven(n) ? n + 1 : n + 2;
}
_export("p", p = 5);
var isOdd = _export("isOdd", (function (isEven) {
return function (n) {
@@ -21,4 +25,4 @@ System.register("es6-modules-system/hoist-function-exports/expected", ["./evens"
})(isEven));
}
};
});
});

View File

@@ -1,4 +1,4 @@
System.register("es6-modules-system/imports-default/expected", ["foo"], function (_export) {
System.register([], function (_export) {
var _foo;
return {
setters: [function (m) {

View File

@@ -1,4 +1,4 @@
System.register("es6-modules-system/imports-glob/expected", ["foo"], function (_export) {
System.register(["foo"], function (_export) {
var _foo;
return {
setters: [function (m) {

View File

@@ -1,4 +1,4 @@
System.register("es6-modules-system/imports-mixing/expected", ["foo"], function (_export) {
System.register(["foo"], function (_export) {
var _foo;
return {
setters: [function (m) {

View File

@@ -1,4 +1,4 @@
System.register("es6-modules-system/imports-named/expected", ["foo"], function (_export) {
System.register(["foo"], function (_export) {
var _foo;
return {
setters: [function (m) {

View File

@@ -1,4 +1,4 @@
System.register("es6-modules-system/imports/expected", ["foo", "foo-bar", "./directory/foo-bar"], function (_export) {
System.register(["foo", "foo-bar", "./directory/foo-bar"], function (_export) {
var _foo, _fooBar, _directoryFooBar;
return {
setters: [function (m) {

View File

@@ -1,4 +1,4 @@
System.register("es6-modules-system/overview/expected", ["foo", "foo-bar", "./directory/foo-bar"], function (_export) {
System.register(["foo", "foo-bar", "./directory/foo-bar"], function (_export) {
var _foo, _fooBar, _directoryFooBar;
return {
setters: [function (m) {

View File

@@ -1,4 +1,4 @@
System.register("es6-modules-system/remap/expected", [], function (_export) {
System.register([], function (_export) {
return {
setters: [],
execute: function () {

View File

@@ -1,18 +1,29 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
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 _ref = [1, 2];
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 2);
var a = _ref2[0];
var b = _ref2[1];
var _ref3 = [3, 4];
var _ref4 = _toArray(_ref3);
var _ref4 = _slicedToArray(_ref3, 2);
var c = _ref4[0];
var d = _ref4[1];

View File

@@ -1,18 +1,29 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
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 _ref = ["hello", [", ", "junk"], ["world"]];
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 4);
var a = _ref2[0];
var _ref3 = _toArray(_ref2[1]);
var _ref3 = _slicedToArray(_ref2[1], 1);
var b = _ref3[0];
var _ref4 = _toArray(_ref2[2]);
var _ref4 = _slicedToArray(_ref2[2], 1);
var c = _ref4[0];
var d = _ref2[3];

View File

@@ -1,8 +1,19 @@
"use strict";
var _temp, _ref;
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
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;
}
};
console.log((_temp = [123], _ref = _toArray(_temp), x = _ref[0], _temp));
console.log((_temp = [123], _ref = _slicedToArray(_temp, 1), x = _ref[0], _temp));

View File

@@ -1,12 +1,23 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
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 _ref = f();
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 2);
a = _ref2[0];
b = _ref2[1];

View File

@@ -1,18 +1,29 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
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 _ref = ["foo", "hello", [", ", "junk"], ["world"]];
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 5);
var a = _ref2[1];
var _ref3 = _toArray(_ref2[2]);
var _ref3 = _slicedToArray(_ref2[2], 1);
var b = _ref3[0];
var _ref4 = _toArray(_ref2[3]);
var _ref4 = _slicedToArray(_ref2[3], 1);
var c = _ref4[0];
var d = _ref2[4];

View File

@@ -1,11 +1,22 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
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;
}
};
for (var _ref in obj) {
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 2);
var name = _ref2[0];
var value = _ref2[1];

View File

@@ -1,12 +1,23 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
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;
}
};
for (var _iterator = this.test.expectation.registers[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
var _ref = _step.value;
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 3);
var name = _ref2[0];
var before = _ref2[1];

View File

@@ -1,12 +1,23 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
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 _ref = [1, 2];
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 2);
this.foo = _ref2[0];
this.bar = _ref2[1];

View File

@@ -1,14 +1,25 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
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 _ref = _toArray(rect.topLeft);
var _ref = _slicedToArray(rect.topLeft, 2);
var x1 = _ref[0];
var y1 = _ref[1];
var _ref2 = _toArray(rect.bottomRight);
var _ref2 = _slicedToArray(rect.bottomRight, 2);
var x2 = _ref2[0];
var y2 = _ref2[1];

View File

@@ -1,7 +1,18 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
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;
}
};
function somethingAdvanced(_ref) {
@@ -20,12 +31,12 @@ function unpackObject(_ref2) {
console.log(unpackObject({ title: "title", author: "author" }));
var unpackArray = function (_ref3, _ref5) {
var _ref4 = _toArray(_ref3);
var _ref4 = _slicedToArray(_ref3, 3);
var a = _ref4[0];
var b = _ref4[1];
var c = _ref4[2];
var _ref6 = _toArray(_ref5);
var _ref6 = _slicedToArray(_ref5, 3);
var x = _ref6[0];
var y = _ref6[1];

View File

@@ -17,8 +17,10 @@ _loop: for (var i in nums) {
})(i);
switch (_ret) {
case "break": break _loop;
case "continue": continue _loop;
case "break":
break _loop;
case "continue":
continue _loop;
default:
if (typeof _ret === "object") return _ret.v;
}

View File

@@ -1,6 +1,7 @@
define(["exports"], function (exports) {
"use strict";
exports["default"] = foo;
exports["default"] = 42;
exports["default"] = {};
exports["default"] = [];
@@ -10,7 +11,6 @@ define(["exports"], function (exports) {
exports["default"] = function () {};
function foo() {}
exports["default"] = foo;
var Foo = function Foo() {};
exports["default"] = Foo;

View File

@@ -7,6 +7,7 @@
})(function (exports) {
"use strict";
exports["default"] = foo;
exports["default"] = 42;
exports["default"] = {};
exports["default"] = [];
@@ -16,7 +17,6 @@
exports["default"] = function () {};
function foo() {}
exports["default"] = foo;
var Foo = function Foo() {};
exports["default"] = Foo;

View File

@@ -1,4 +1,4 @@
var runtime = require("../lib/6to5/runtime");
var runtime = require("../lib/6to5/runtime-generator");
var assert = require("assert");
suite("runtime", function () {