Compare commits

...

17 Commits

Author SHA1 Message Date
Sebastian McKenzie
44f2f701e1 v1.13.11 2014-11-24 10:23:56 +11:00
Sebastian McKenzie
032bc0af5e fix util.regexify tests 2014-11-24 10:23:00 +11:00
Sebastian McKenzie
0e822a7e54 remove unused variables 2014-11-24 10:21:01 +11:00
Sebastian McKenzie
51e521f0e0 add 1.13.11 changelog 2014-11-24 10:19:40 +11:00
Sebastian McKenzie
e5ce69d6af clean up register module formatter and rename it to system 2014-11-24 10:19:06 +11:00
Sebastian McKenzie
e3b8fa93e2 export as module.exports if there are no other ExportDeclarations in commonInterop module formatter @guybedford 2014-11-24 10:05:50 +11:00
Sebastian McKenzie
f4ce3a23ad fix explicit arguments reference for rest parameters - fixes #210 2014-11-24 10:05:49 +11:00
Sebastian McKenzie
39f4696ac7 fix util.regexify on falsy values - fixes #208 2014-11-24 10:05:49 +11:00
Sebastian McKenzie
4a9918ec6b Merge pull request #209 from douglasduteil/feat-modules-add-register-module-type
Add "register" module formatter
2014-11-24 10:05:29 +11:00
Douglas Duteil
c87e14f6a9 feat(modules): add "register" module type
Inspired by https://github.com/ModuleLoader/es6-module-loader/wiki/System.register-Explained
2014-11-23 22:54:01 +01:00
Sebastian McKenzie
680771c81b v1.13.10 2014-11-24 01:02:18 +11:00
Sebastian McKenzie
cad3f63723 update assignment expression destructuring test 2014-11-24 01:01:13 +11:00
Sebastian McKenzie
eceda64528 add 1.13.10 changelog 2014-11-24 01:00:26 +11:00
Sebastian McKenzie
b8ec87e058 fix Scope::push block type error message 2014-11-24 00:59:56 +11:00
Sebastian McKenzie
04bd023787 add support for AssignmentExpression destructuring outside of ExpressionStatement 2014-11-24 00:56:06 +11:00
Sebastian McKenzie
f1759dc419 v1.13.9 2014-11-24 00:48:05 +11:00
Sebastian McKenzie
2985f1b40b fix VirtualPropertyExpression visitor keys - fixes #207 2014-11-24 00:47:10 +11:00
47 changed files with 769 additions and 78 deletions

View File

@@ -1,3 +1,18 @@
# 1.13.11
* Fix `util.regexify` on falsy values.
* Fix `_aliasFunction` with rest parameters.
* Export as `module.exports` instead of `exports.default` if there are no other `ExportDeclaration`s in `commonInterop` module formatter.
* Add `system` module formatter. Thanks [@douglasduteil](https://github.com/douglasduteil).
# 1.13.10
* Add support for `AssignmentExpression` destructuring outside of `ExpressionStatement`.
# 1.13.9
* Fix `VirtualPropertyExpression` visitor keys.
# 1.13.8
* Only use a single reference in abstract references.

View File

@@ -51,6 +51,69 @@ var test = 5; exports.test = test;
exports.default = test;
```
### Common interop
**In**
```javascript
import "foo";
import foo from "foo";
import * as foo from "foo";
import {bar} from "foo";
import {foo as bar} from "foo";
export {test};
export var test = 5;
export default test;
```
**Out**
```javascript
var _interopRequire = function (obj) {
return obj && (obj["default"] || obj);
};
require("foo");
var foo = _interopRequire(require("foo"));
var foo = require("foo");
var bar = require("foo").bar;
var bar = require("foo").foo;
exports.test = test;
var test = exports.test = 5;
exports["default"] = test;
```
#### module.exports behaviour
If there exist no other non-default `export`s then `default exports` are
exported as `module.exports` instead of `exports.default`.
**In**
```javascript
export default function foo() {
}
```
**Out**
```javascript
module.exports = foo;
function foo() {
}
```
### AMD
**In**
@@ -135,6 +198,43 @@ function bar() {
}
```
### Register
**In**
```javascript
import foo from "foo";
export function bar() {
return foo("foobar");
}
```
**Out**
```javascript
System.register("bar", ["foo"], function ($__export) {
"use strict";
var __moduleName = "bar";
var foo;
function bar() {
return foo("foobar");
}
return {
setters: [function (m) {
foo = m.default;
}],
execute: function () {
$__export("bar", bar);
}
};
});
```
## Custom
You can alternatively specify module names instead of one of the built-in types.

View File

@@ -10,9 +10,7 @@ var t = require("./types");
var _ = require("lodash");
function File(opts) {
this.opts = File.normaliseOptions(opts);
this.moduleFormatter = this.getModuleFormatter(this.opts.modules);
this.opts = File.normaliseOptions(opts);
this.uids = {};
this.ast = {};
}
@@ -168,6 +166,7 @@ File.prototype.parse = function (code) {
File.prototype.transform = function (ast) {
this.ast = ast;
this.scope = new Scope(ast.program);
this.moduleFormatter = this.getModuleFormatter(this.opts.modules);
var self = this;

View File

@@ -0,0 +1 @@
module.exports = VALUE;

View File

@@ -0,0 +1 @@
System.register(MODULE_NAME, MODULE_DEPENDENCIES, MODULE_BODY);

View File

@@ -41,34 +41,11 @@ AMDFormatter.prototype.transform = function (ast) {
};
AMDFormatter.prototype.getModuleName = function () {
var opts = this.file.opts;
var filenameRelative = opts.filenameRelative;
var moduleName = "";
if (!opts.amdModuleIds) {
if (this.file.opts.amdModuleIds) {
return CommonJSFormatter.prototype.getModuleName.apply(this, arguments);
} else {
return null;
}
if (opts.moduleRoot) {
moduleName = opts.moduleRoot + "/";
}
if (!opts.filenameRelative) {
return moduleName + opts.filename.replace(/^\//, "");
}
if (opts.sourceRoot) {
// remove sourceRoot from filename
var sourceRootRegEx = new RegExp("^" + opts.sourceRoot + "\/?");
filenameRelative = filenameRelative.replace(sourceRootRegEx, "");
}
// remove extension
filenameRelative = filenameRelative.replace(/\.(.*?)$/, "");
moduleName += filenameRelative;
return moduleName;
};
AMDFormatter.prototype._push = function (node) {

View File

@@ -4,8 +4,9 @@ var CommonJSFormatter = require("./common");
var util = require("../../util");
var t = require("../../types");
function CommonJSInteropFormatter(file) {
this.file = file;
function CommonJSInteropFormatter() {
this.has = false;
CommonJSFormatter.apply(this, arguments);
}
util.inherits(CommonJSInteropFormatter, CommonJSFormatter);
@@ -26,3 +27,27 @@ CommonJSInteropFormatter.prototype.importSpecifier = function (specifier, node,
CommonJSFormatter.prototype.importSpecifier.apply(this, arguments);
}
};
CommonJSInteropFormatter.prototype.export = function (node, nodes) {
if (node.default && !this.has) {
var declar = node.declaration;
// module.exports = VALUE;
var assign = util.template("exports-default-module", {
VALUE: this._pushStatement(declar, nodes)
}, true);
// hoist to the top if this default is a function
nodes.push(this._hoistExport(declar, assign));
return;
} else {
this.has = true;
}
CommonJSFormatter.prototype.export.apply(this, arguments);
};
CommonJSInteropFormatter.prototype.exportSpecifier = function () {
this.has = true;
CommonJSFormatter.prototype.exportSpecifier.apply(this, arguments);
};

View File

@@ -7,6 +7,33 @@ function CommonJSFormatter(file) {
this.file = file;
}
CommonJSFormatter.prototype.getModuleName = function () {
var opts = this.file.opts;
var filenameRelative = opts.filenameRelative;
var moduleName = "";
if (opts.moduleRoot) {
moduleName = opts.moduleRoot + "/";
}
if (!opts.filenameRelative) {
return moduleName + opts.filename.replace(/^\//, "");
}
if (opts.sourceRoot) {
// remove sourceRoot from filename
var sourceRootRegEx = new RegExp("^" + opts.sourceRoot + "\/?");
filenameRelative = filenameRelative.replace(sourceRootRegEx, "");
}
// remove extension
filenameRelative = filenameRelative.replace(/\.(.*?)$/, "");
moduleName += filenameRelative;
return moduleName;
};
CommonJSFormatter.prototype.import = function (node, nodes) {
// import "foo";
nodes.push(util.template("require", {
@@ -38,23 +65,32 @@ CommonJSFormatter.prototype.importSpecifier = function (specifier, node, nodes)
}));
};
CommonJSFormatter.prototype._hoistExport = function (declar, assign) {
if (t.isFunctionDeclaration(declar)) {
assign._blockHoist = true;
}
return assign;
};
CommonJSFormatter.prototype._pushStatement = function (ref, nodes) {
if (t.isClass(ref) || t.isFunction(ref)) {
if (ref.id) {
nodes.push(t.toStatement(ref));
ref = ref.id;
}
}
return ref;
};
CommonJSFormatter.prototype.export = function (node, nodes) {
var declar = node.declaration;
if (node.default) {
var ref = declar;
if (t.isClass(ref) || t.isFunction(ref)) {
if (ref.id) {
nodes.push(t.toStatement(ref));
ref = ref.id;
}
}
nodes.push(util.template("exports-default", {
//inherits: node,
VALUE: ref
VALUE: this._pushStatement(declar, nodes)
}, true));
} else {
var assign;
@@ -83,9 +119,7 @@ CommonJSFormatter.prototype.export = function (node, nodes) {
nodes.push(t.toStatement(declar));
nodes.push(assign);
if (t.isFunctionDeclaration(declar)) {
assign._blockHoist = true;
}
this._hoistExport(declar, assign);
}
}
};
@@ -126,7 +160,7 @@ CommonJSFormatter.prototype._exportSpecifier = function (getRef, specifier, node
};
CommonJSFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
return this._exportSpecifier(function () {
this._exportSpecifier(function () {
return t.callExpression(t.identifier("require"), [node.source]);
}, specifier, node, nodes);
};

View File

@@ -0,0 +1,203 @@
module.exports = SystemFormatter;
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
var SETTER_MODULE_NAMESPACE = t.identifier("m");
var DEFAULT_IDENTIFIER = t.identifier("default");
var NULL_SETTER = t.literal(null);
function SystemFormatter(file) {
this.exportedStatements = [];
this.importedModule = {};
this.exportIdentifier = file.generateUidIdentifier("export");
this.file = file;
}
SystemFormatter.prototype.transform = function (ast) {
var program = ast.program;
var body = program.body;
// extract the module name
var moduleName = this.file.opts.filename
.replace(/^.*\//, "").replace(/\..*$/, "");
// build an array of module names
var dependencies = Object.keys(this.importedModule).map(t.literal);
// generate the __moduleName variable
var moduleNameVariableNode = t.variableDeclaration("var", [
t.variableDeclarator(
t.identifier("__moduleName"),
t.literal(moduleName)
)
]);
body.splice(1, 0, moduleNameVariableNode);
// generate an array of import variables
var declaredSetters = _(this.importedModule)
.map()
.flatten()
.pluck("variableName")
.pluck("name")
.uniq()
.map(t.identifier)
.map(function (name) {
return t.variableDeclarator(name);
})
.value();
if (declaredSetters.length) {
body.splice(2, 0, t.variableDeclaration("var", declaredSetters));
}
// generate the execute function expression
var executeFunctionExpression = t.functionExpression(
null, [], t.blockStatement(this.exportedStatements)
);
// generate the execute function expression
var settersArrayExpression = t.arrayExpression(this._buildSetters());
// generate the return statement
var moduleReturnStatement = t.returnStatement(t.objectExpression([
t.property("init", t.identifier("setters"), settersArrayExpression),
t.property("init", t.identifier("execute"), executeFunctionExpression)
]));
body.push(moduleReturnStatement);
// runner
var runner = util.template("register", {
MODULE_NAME: t.literal(moduleName),
MODULE_DEPENDENCIES: t.arrayExpression(dependencies),
MODULE_BODY: t.functionExpression(
null,
[this.exportIdentifier],
t.blockStatement(body)
)
});
program.body = [t.expressionStatement(runner)];
};
SystemFormatter.prototype._buildSetters = function () {
// generate setters array expression elements
return _.map(this.importedModule, function (specs) {
if (!specs.length) {
return NULL_SETTER;
}
var expressionStatements = _.map(specs, function (spec) {
var right = SETTER_MODULE_NAMESPACE;
if (!spec.isBatch) {
right = t.memberExpression(right, spec.key);
}
return t.expressionStatement(
t.assignmentExpression("=", spec.variableName, right
)
);
});
return t.functionExpression(
null, [SETTER_MODULE_NAMESPACE], t.blockStatement(expressionStatements)
);
});
};
SystemFormatter.prototype.import = function (node) {
var MODULE_NAME = node.source.value;
this.importedModule[MODULE_NAME] = this.importedModule[MODULE_NAME] || [];
};
SystemFormatter.prototype.importSpecifier = function (specifier, node) {
var variableName = t.getSpecifierName(specifier);
// import foo from "foo";
if (specifier.default) {
specifier.id = DEFAULT_IDENTIFIER;
}
var MODULE_NAME = node.source.value;
this.importedModule[MODULE_NAME] = this.importedModule[MODULE_NAME] || [];
this.importedModule[MODULE_NAME].push({
variableName: variableName,
isBatch: specifier.type === "ImportBatchSpecifier",
key: specifier.id
});
};
SystemFormatter.prototype._export = function (name, identifier) {
this.exportedStatements.push(t.expressionStatement(
t.callExpression(this.exportIdentifier, [t.literal(name), identifier])
));
};
SystemFormatter.prototype.export = function (node, nodes) {
var declar = node.declaration;
var variableName, identifier;
if (node.default) {
// export default foo
variableName = DEFAULT_IDENTIFIER.name;
if (t.isClass(declar) || t.isFunction(declar)) {
if (!declar.id) {
declar.id = this.file.generateUidIdentifier("anonymous");
}
nodes.push(t.toStatement(declar));
declar = declar.id;
}
identifier = declar;
} else if (t.isVariableDeclaration(declar)) {
// export var foo
variableName = declar.declarations[0].id.name;
identifier = declar.declarations[0].id;
nodes.push(declar);
} else {
// export function foo () {}
variableName = declar.id.name;
identifier = declar.id;
nodes.push(declar);
}
this._export(variableName, identifier);
};
SystemFormatter.prototype.exportSpecifier = function (specifier, node) {
var variableName = t.getSpecifierName(specifier);
if (node.source) {
if (t.isExportBatchSpecifier(specifier)) {
// export * from "foo";
var exportIdentifier = t.identifier("exports");
this.exportedStatements.push(
t.variableDeclaration("var", [
t.variableDeclarator(exportIdentifier, this.exportIdentifier)
])
);
this.exportedStatements.push(util.template("exports-wildcard", {
OBJECT: t.identifier(node.source.value)
}, true));
} else {
// export { foo } from "test";
this._export(variableName.name, t.memberExpression(
t.identifier(node.source.value),
specifier.id
));
}
} else {
// export { foo };
this._export(variableName.name, specifier.id);
}
};

View File

@@ -22,6 +22,7 @@ transform.transformers = {};
transform.moduleFormatters = {
common: require("./modules/common"),
commonInterop: require("./modules/common-interop"),
system: require("./modules/system"),
ignore: require("./modules/ignore"),
amd: require("./modules/amd"),
umd: require("./modules/umd")

View File

@@ -31,7 +31,7 @@ var go = function (getBody, node, file, scope) {
return false;
}
if (node._ignoreAliasFunctions) return;
if (node._ignoreAliasFunctions) return false;
var getId;

View File

@@ -1,3 +1,5 @@
// TODO: Clean up
var t = require("../../types");
var _ = require("lodash");
@@ -183,10 +185,38 @@ exports.ExpressionStatement = function (node, parent, file, scope) {
return nodes;
};
exports.AssignmentExpression = function (node, parent, file) {
exports.AssignmentExpression = function (node, parent, file, scope) {
if (parent.type === "ExpressionStatement") return;
if (!t.isPattern(node.left)) return;
throw file.errorWithNode(node, "AssignmentExpression destructuring outside of a ExpressionStatement is forbidden due to current 6to5 limitations");
var tempName = file.generateUid("temp", scope);
var temp = t.identifier(tempName);
scope.push(tempName, temp);
var nodes = [];
nodes.push(t.assignmentExpression("=", temp, node.right));
push({
kind: false,
file: file,
scope: scope
}, nodes, node.left, temp);
nodes.push(temp);
nodes = nodes.map(function (node) {
if (t.isExpressionStatement(node)) {
return node.expression;
} else if (t.isVariableDeclaration(node)) {
var declar = node.declarations[0];
scope.push(declar.id.name, declar.id);
return t.assignmentExpression("=", declar.id, declar.init);
} else {
return node;
}
});
return t.sequenceExpression(nodes);
};
exports.VariableDeclaration = function (node, parent, file, scope) {

View File

@@ -5,10 +5,10 @@ exports.ImportDeclaration = function (node, parent, file) {
if (node.specifiers.length) {
_.each(node.specifiers, function (specifier) {
file.moduleFormatter.importSpecifier(specifier, node, nodes);
file.moduleFormatter.importSpecifier(specifier, node, nodes, parent);
});
} else {
file.moduleFormatter.import(node, nodes);
file.moduleFormatter.import(node, nodes, parent);
}
return nodes;
@@ -18,10 +18,10 @@ exports.ExportDeclaration = function (node, parent, file) {
var nodes = [];
if (node.declaration) {
file.moduleFormatter.export(node, nodes);
file.moduleFormatter.export(node, nodes, parent);
} else {
_.each(node.specifiers, function (specifier) {
file.moduleFormatter.exportSpecifier(specifier, node, nodes);
file.moduleFormatter.exportSpecifier(specifier, node, nodes, parent);
});
}

View File

@@ -112,7 +112,7 @@ Scope.prototype.push = function (name, id, init) {
init: init
};
} else {
throw new Error("wtf");
throw new TypeError("cannot add a declaration here in node type " + block.type);
}
};

View File

@@ -61,7 +61,7 @@
"UpdateExpression": ["argument"],
"VariableDeclaration": ["declarations"],
"VariableDeclarator": ["id", "init"],
"VirtualPropertyExpression": ["left", "right"],
"VirtualPropertyExpression": ["object", "property"],
"WhileStatement": ["test", "body"],
"WithStatement": ["object", "body"],
"XJSAttribute": ["name", "value"],

View File

@@ -38,9 +38,9 @@ exports.list = function (val) {
};
exports.regexify = function (val) {
if (!val) return new RegExp;
if (!val) return new RegExp(/.^/);
if (_.isArray(val)) val = val.join("|");
if (_.isString(val)) return new RegExp(val || "");
if (_.isString(val)) return new RegExp(val);
if (_.isRegExp(val)) return val;
throw new TypeError("illegal type for regexify");
};

View File

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

View File

@@ -1 +0,0 @@
console.log([x] = [1]);

View File

@@ -1,3 +0,0 @@
{
"throws": "AssignmentExpression destructuring outside of a ExpressionStatement is forbidden due to current 6to5 limitations"
}

View File

@@ -0,0 +1,9 @@
"use strict";
var _ref;
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
};
var _temp;
console.log((_temp = [123], _ref = _toArray(_temp), x = _ref[0], _temp));

View File

@@ -1,3 +0,0 @@
{
"throws": "AssignmentExpression destructuring outside of a ExpressionStatement is forbidden due to current 6to5 limitations"
}

View File

@@ -1,13 +1,13 @@
"use strict";
exports["default"] = 42;
exports["default"] = {};
exports["default"] = [];
exports["default"] = foo;
exports["default"] = function () {};
exports["default"] = function () {};
module.exports = foo;
module.exports = 42;
module.exports = {};
module.exports = [];
module.exports = foo;
module.exports = function () {};
module.exports = function () {};
function foo() {}
exports["default"] = foo;
var Foo = function Foo() {};
exports["default"] = Foo;
module.exports = Foo;

View File

@@ -0,0 +1,8 @@
export default 42;
export default {};
export default [];
export default foo;
export default function () {}
export default class {}
export default function foo () {}
export default class Foo {}

View File

@@ -0,0 +1,32 @@
System.register("actual", [], function (_export) {
"use strict";
var __moduleName = "actual";
function _anonymous() {}
var _anonymous2 = function _anonymous2() {};
function foo() {}
var Foo = function Foo() {};
return {
setters: [],
execute: function () {
_export("default", 42);
_export("default", {});
_export("default", []);
_export("default", foo);
_export("default", _anonymous);
_export("default", _anonymous2);
_export("default", foo);
_export("default", Foo);
}
};
});

View File

@@ -0,0 +1,6 @@
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";

View File

@@ -0,0 +1,31 @@
System.register("actual", [], function (_export) {
"use strict";
var __moduleName = "actual";
return {
setters: [],
execute: function () {
var exports = _export;
(function (obj) {
for (var i in obj) {
exports[i] = obj[i];
}
})(foo);
_export("foo", foo.foo);
_export("foo", foo.foo);
_export("bar", foo.bar);
_export("bar", foo.foo);
_export("default", foo.foo);
_export("default", foo.foo);
_export("bar", foo.bar);
}
};
});

View File

@@ -0,0 +1,5 @@
export {foo};
export {foo, bar};
export {foo as bar};
export {foo as default};
export {foo as default, bar};

View File

@@ -0,0 +1,24 @@
System.register("actual", [], function (_export) {
"use strict";
var __moduleName = "actual";
return {
setters: [],
execute: function () {
_export("foo", foo);
_export("foo", foo);
_export("bar", bar);
_export("bar", foo);
_export("default", foo);
_export("default", foo);
_export("bar", bar);
}
};
});

View File

@@ -0,0 +1,8 @@
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,35 @@
System.register("actual", [], function (_export) {
"use strict";
var __moduleName = "actual";
var foo = 1;
var foo2 = function () {};
var foo3;
var foo4 = 2;
var foo5;
var foo6 = 3;
function foo7() {}
var foo8 = function foo8() {};
return {
setters: [],
execute: function () {
_export("foo", foo);
_export("foo2", foo2);
_export("foo3", foo3);
_export("foo4", foo4);
_export("foo5", foo5);
_export("foo6", foo6);
_export("foo7", foo7);
_export("foo8", foo8);
}
};
});

View File

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

View File

@@ -0,0 +1,25 @@
System.register("actual", ["./evens"], function (_export) {
"use strict";
var __moduleName = "actual";
var isEven;
function nextOdd(n) {
return isEven(n) ? n + 1 : n + 2;
}
var isOdd = (function (isEven) {
return function (n) {
return !isEven(n);
};
})(isEven);return {
setters: [function (m) {
isEven = m.isEven;
}],
execute: function () {
_export("nextOdd", nextOdd);
_export("isOdd", isOdd);
}
};
});

View File

@@ -0,0 +1,2 @@
import foo from "foo";
import {default as foo} from "foo";

View File

@@ -0,0 +1,14 @@
System.register("actual", ["foo"], function (_export) {
"use strict";
var __moduleName = "actual";
var foo;
return {
setters: [function (m) {
foo = m.default;
foo = m.default;
}],
execute: function () {}
};
});

View File

@@ -0,0 +1 @@
import * as foo from "foo";

View File

@@ -0,0 +1,13 @@
System.register("actual", ["foo"], function (_export) {
"use strict";
var __moduleName = "actual";
var foo;
return {
setters: [function (m) {
foo = m;
}],
execute: function () {}
};
});

View File

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

View File

@@ -0,0 +1,14 @@
System.register("actual", ["foo"], function (_export) {
"use strict";
var __moduleName = "actual";
var foo, xyz;
return {
setters: [function (m) {
foo = m.default;
xyz = m.baz;
}],
execute: function () {}
};
});

View File

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

View File

@@ -0,0 +1,18 @@
System.register("actual", ["foo"], function (_export) {
"use strict";
var __moduleName = "actual";
var bar, baz, xyz;
return {
setters: [function (m) {
bar = m.bar;
bar = m.bar;
baz = m.baz;
baz = m.bar;
baz = m.bar;
xyz = m.xyz;
}],
execute: function () {}
};
});

View File

@@ -0,0 +1,3 @@
import "foo";
import "foo-bar";
import "./directory/foo-bar";

View File

@@ -0,0 +1,10 @@
System.register("actual", ["foo", "foo-bar", "./directory/foo-bar"], function (_export) {
"use strict";
var __moduleName = "actual";
return {
setters: [null, null, null],
execute: function () {}
};
});

View File

@@ -0,0 +1,3 @@
{
"modules": "system"
}

View File

@@ -0,0 +1,12 @@
import "foo";
import "foo-bar";
import "./directory/foo-bar";
import foo from "foo";
import * as foo from "foo";
import {bar} from "foo";
import {foo as bar} from "foo";
export {test};
export var test = 5;
export default test;

View File

@@ -0,0 +1,24 @@
System.register("actual", ["foo", "foo-bar", "./directory/foo-bar"], function (_export) {
"use strict";
var __moduleName = "actual";
var foo, bar;
var test = 5;
return {
setters: [function (m) {
foo = m.default;
foo = m;
bar = m.bar;
bar = m.foo;
}, null, null],
execute: function () {
_export("test", test);
_export("test", test);
_export("default", test);
}
};
});

View File

@@ -1,6 +1,5 @@
"use strict";
var _arguments = arguments;
var _argumentsToArray = function (args) {
var target = new Array(args.length);
for (var i = 0; i < args.length; i++) {
@@ -11,5 +10,5 @@ var _argumentsToArray = function (args) {
};
var concat = function () {
var arrs = _argumentsToArray(_arguments);
var arrs = _argumentsToArray(arguments);
};

View File

@@ -58,10 +58,10 @@ suite("util", function () {
});
test("regexify", function () {
assert.deepEqual(util.regexify(undefined), /(?:)/);
assert.deepEqual(util.regexify(false), /(?:)/);
assert.deepEqual(util.regexify(null), /(?:)/);
assert.deepEqual(util.regexify(""), /(?:)/);
assert.deepEqual(util.regexify(undefined), /.^/);
assert.deepEqual(util.regexify(false), /.^/);
assert.deepEqual(util.regexify(null), /.^/);
assert.deepEqual(util.regexify(""), /.^/);
assert.deepEqual(util.regexify(["foo", "bar"]), /foo|bar/);
assert.deepEqual(util.regexify("foobar"), /foobar/);
assert.deepEqual(util.regexify(/foobar/), /foobar/);