Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98f2287267 | ||
|
|
e60e0e0b0e | ||
|
|
81fb8647b6 | ||
|
|
e8387c7de5 | ||
|
|
655196f3ce | ||
|
|
eef371c3df | ||
|
|
a3d21f02c6 | ||
|
|
ad4386c0ed | ||
|
|
3c82a61af1 | ||
|
|
3c154f9f6d | ||
|
|
22c972e85b | ||
|
|
6d7e14fb2b | ||
|
|
9287449372 | ||
|
|
44a35400f5 | ||
|
|
2305e2447f | ||
|
|
c420d1ffc3 | ||
|
|
fa42b076a7 | ||
|
|
0d23c1cfdb | ||
|
|
0dafdd6969 | ||
|
|
a9af8d39a2 | ||
|
|
1cc606d4d0 | ||
|
|
2a09c0a5a5 | ||
|
|
92359520cd | ||
|
|
50e5bd4680 | ||
|
|
dfa51954b8 | ||
|
|
216b8c2fd1 | ||
|
|
abc90778e8 | ||
|
|
56f1683f06 | ||
|
|
520dd7e947 | ||
|
|
17ce21509d | ||
|
|
a4c8895dc3 | ||
|
|
af4009694a | ||
|
|
941a8cc5ea | ||
|
|
359c4e8786 | ||
|
|
7ac98c1532 | ||
|
|
61c3e0a3de |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -4,3 +4,6 @@
|
||||
[submodule "vendor/regenerator"]
|
||||
path = vendor/regenerator
|
||||
url = https://github.com/facebook/regenerator
|
||||
[submodule "vendor/test262"]
|
||||
path = vendor/test262
|
||||
url = https://github.com/tc39/test262
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
|
||||
_Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
## 2.7.0
|
||||
|
||||
* **Spec Compliancy**
|
||||
* Disallow reassignments of imports.
|
||||
* **New Feature**
|
||||
* `reactCompat` to enable pre-v0.12 react components.
|
||||
|
||||
## 2.6.3
|
||||
|
||||
* **Bug Fix**
|
||||
|
||||
25
Makefile
25
Makefile
@@ -6,7 +6,7 @@ MOCHA_CMD = node_modules/mocha/bin/_mocha
|
||||
|
||||
export NODE_ENV = test
|
||||
|
||||
.PHONY: clean test test-cov test-clean lint test-travis test-spec test-browser publish bench build bootstrap
|
||||
.PHONY: clean test test-cov test-clean lint test-travis test-simple test-all test-browser publish build bootstrap
|
||||
|
||||
build:
|
||||
mkdir -p dist
|
||||
@@ -27,12 +27,8 @@ build:
|
||||
clean:
|
||||
rm -rf coverage templates.json test/tmp dist
|
||||
|
||||
bench:
|
||||
npm install es6-transpiler traceur esnext es6now jstransform
|
||||
node node_modules/matcha/bin/_matcha
|
||||
|
||||
lint:
|
||||
$(JSHINT_CMD) --reporter node_modules/jshint-stylish/stylish.js lib bin benchmark/index.js
|
||||
$(JSHINT_CMD) --reporter node_modules/jshint-stylish/stylish.js lib bin
|
||||
|
||||
test-clean:
|
||||
rm -rf test/tmp
|
||||
@@ -41,14 +37,23 @@ test: lint
|
||||
$(MOCHA_CMD)
|
||||
make test-clean
|
||||
|
||||
test-simple:
|
||||
# excludes test262
|
||||
export SIMPLE_6TO5_TESTS=1
|
||||
make test
|
||||
|
||||
test-all:
|
||||
# includes traceur, esnext, regenerator
|
||||
export ALL_6TO5_TESTS=1
|
||||
make test
|
||||
|
||||
test-cov:
|
||||
export SIMPLE_6TO5_TESTS=1
|
||||
rm -rf coverage
|
||||
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
|
||||
|
||||
test-spec:
|
||||
node $(ISTANBUL_CMD) $(MOCHA_CMD) -- --reporter spec
|
||||
|
||||
test-travis: test-spec
|
||||
test-travis: bootstrap
|
||||
$(MOCHA_CMD)
|
||||
if test -n "$$CODECLIMATE_REPO_TOKEN"; then codeclimate < coverage/lcov.info; fi
|
||||
|
||||
test-browser:
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
var obj = {};
|
||||
var foo = "foo";
|
||||
var bar = "bar";
|
||||
|
||||
// constants
|
||||
const MULTIPLIER = 5;
|
||||
|
||||
// classes
|
||||
class Foo {
|
||||
constructor() {
|
||||
this.foo = "bar";
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
// default parameters
|
||||
go(foo = "bar", bar = "foo") {
|
||||
|
||||
}
|
||||
|
||||
// not supported by jstransform
|
||||
//get foo() {
|
||||
// return this._foo;
|
||||
//}
|
||||
//set foo(val) {
|
||||
// this._foo = val + " foo!";
|
||||
//}
|
||||
}
|
||||
|
||||
// arrow functions
|
||||
arr.map(x => x * x);
|
||||
|
||||
// block binding
|
||||
for (let key in arr) {
|
||||
let val = arr[key];
|
||||
console.log(key, val);
|
||||
}
|
||||
|
||||
// computed property names
|
||||
obj = {
|
||||
["foo" + bar]: "foobar"
|
||||
};
|
||||
|
||||
// destructuring
|
||||
var [a, [b], c, d] = ["hello", [", ", "junk"], ["world"]];
|
||||
console.log(a + b + c);
|
||||
|
||||
// array comprehension
|
||||
// [for (i of [1, 2, 3]) i * i]; // not supported by es6now
|
||||
|
||||
// for-of
|
||||
for (var i of [1, 2, 3]) {
|
||||
console.log(i * i);
|
||||
}
|
||||
|
||||
// property method assignment
|
||||
obj = {
|
||||
foo() {
|
||||
return "foobar";
|
||||
},
|
||||
|
||||
get bar() {
|
||||
return this._bar;
|
||||
},
|
||||
|
||||
set bar(val) {
|
||||
this._bar = val;
|
||||
}
|
||||
};
|
||||
|
||||
// property name shorthand
|
||||
function f(x, y) {
|
||||
return { x, y };
|
||||
}
|
||||
|
||||
// rest parameters
|
||||
function printList(name, ...items) {
|
||||
console.log("list %s has the following items", name);
|
||||
items.forEach(function (item) {
|
||||
console.log(item);
|
||||
});
|
||||
}
|
||||
|
||||
// spread
|
||||
function add(x, y) {
|
||||
return x + y;
|
||||
}
|
||||
var numbers = [5, 10];
|
||||
add(...numbers);
|
||||
|
||||
// template literals
|
||||
var x = 5;
|
||||
var y = 10;
|
||||
console.log(`${x} + ${y} = ${x + y}`);
|
||||
@@ -1,168 +0,0 @@
|
||||
Error.stackTraceLimit = Infinity;
|
||||
|
||||
var jsTrans = require("jstransform");
|
||||
var traceur = require("traceur");
|
||||
//var es6tr = require("es6-transpiler");
|
||||
var es6now = require("es6now");
|
||||
//var esnext = require("esnext");
|
||||
var to5 = require("../lib/6to5");
|
||||
|
||||
//var uglify = require("uglify-js");
|
||||
var matcha = require("matcha");
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
var readResolve = function (filename) {
|
||||
try {
|
||||
filename = require.resolve(filename);
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
return fs.readFileSync(filename, "utf8");
|
||||
};
|
||||
|
||||
var getVersion = function (name) {
|
||||
return require(name + "/package.json").version;
|
||||
};
|
||||
|
||||
var jsTransVisitors = [];
|
||||
|
||||
_.each([
|
||||
"arrow-function-visitors", "class-visitors", "destructuring-visitors",
|
||||
"object-concise-method-visitors", "object-short-notation-visitors",
|
||||
"rest-param-visitors", "template-visitors"
|
||||
], function (name) {
|
||||
var mod = require("jstransform/visitors/es6-" + name);
|
||||
jsTransVisitors = jsTransVisitors.concat(mod.visitorList);
|
||||
});
|
||||
|
||||
|
||||
var compilers = {
|
||||
"6to5": {
|
||||
version: getVersion(".."),
|
||||
compile: function (code, filename) {
|
||||
return to5.transform(code, { filename: filename }).code;
|
||||
}
|
||||
},
|
||||
|
||||
traceur: {
|
||||
runtime: readResolve("traceur/bin/traceur-runtime.js"),
|
||||
compile: function (code) {
|
||||
return traceur.compile(code, {
|
||||
modules: "commonjs",
|
||||
experimental: true
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/*esnext: {
|
||||
runtime: readResolve("esnext/node_modules/regenerator/runtime.js") || readResolve("regenerator/runtime.js"),
|
||||
compile: function (code) {
|
||||
return esnext.compile(code).code;
|
||||
}
|
||||
},*/
|
||||
|
||||
es6now: {
|
||||
runtime: readResolve("es6now/runtime/ES6.js"),
|
||||
compile: function (code) {
|
||||
return es6now.translate(code);
|
||||
}
|
||||
},
|
||||
|
||||
/*"es6-transpiler": {
|
||||
compile: function (code) {
|
||||
var result = es6tr.run({ src: code });
|
||||
if (result.errors.length) throw new Error(result.join("; "));
|
||||
return result.src;
|
||||
}
|
||||
},*/
|
||||
|
||||
jstransform: {
|
||||
compile: function (code) {
|
||||
return jsTrans.transform(jsTransVisitors, code).code;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// versions
|
||||
|
||||
//var uglifyTitle = "uglify v" + getVersion("uglify-js");
|
||||
|
||||
_.each(compilers, function (compiler, name) {
|
||||
compiler.title = name + " v" + (compiler.version || getVersion(name));
|
||||
});
|
||||
|
||||
//
|
||||
|
||||
var sizeBenchmark = function (code, loc, name, compiler) {
|
||||
var log = function (output, title) {
|
||||
title = [compiler.title].concat(title || []).join(" + ");
|
||||
|
||||
var text;
|
||||
var color;
|
||||
if (output.stack) {
|
||||
text = "error";
|
||||
color = "red";
|
||||
} else {
|
||||
var kilo = (output.length / 1024).toFixed(2);
|
||||
text = kilo + "KB";
|
||||
color = "cyan";
|
||||
}
|
||||
|
||||
text = matcha.utils.color(matcha.utils.padBefore(text, 22), color);
|
||||
|
||||
console.log(text, matcha.utils.color("» " + title, "gray"));
|
||||
|
||||
if (output.stack) {
|
||||
console.error(output.stack);
|
||||
}
|
||||
};
|
||||
|
||||
var go = function (getOutput, title) {
|
||||
var code;
|
||||
try {
|
||||
code = getOutput();
|
||||
} catch (err) {
|
||||
log(err, title);
|
||||
return;
|
||||
}
|
||||
|
||||
log(code, title);
|
||||
};
|
||||
|
||||
var output;
|
||||
go(function () {
|
||||
return output = compiler.compile(code, loc);
|
||||
});
|
||||
if (!output) return;
|
||||
|
||||
//go(function () {
|
||||
// return uglify.minify(output, { fromString: true }).code;
|
||||
//}, uglifyTitle);
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
_.each(fs.readdirSync(__dirname + "/fixtures"), function (name) {
|
||||
var alias = path.basename(name, path.extname(name));
|
||||
|
||||
suite(alias, function () {
|
||||
set("delay", 0);
|
||||
|
||||
var loc = __dirname + "/fixtures/" + name;
|
||||
var code = fs.readFileSync(loc, "utf8");
|
||||
|
||||
before(function () {
|
||||
_.each(compilers, function (compiler, name) {
|
||||
sizeBenchmark(code, loc, name, compiler);
|
||||
});
|
||||
});
|
||||
|
||||
_.each(compilers, function (compiler) {
|
||||
bench(compiler.title, function () {
|
||||
compiler.compile(code, loc);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -9,7 +9,11 @@ function DefaultFormatter(file) {
|
||||
this.file = file;
|
||||
|
||||
this.localExports = this.getLocalExports();
|
||||
this.localImports = this.getLocalImports();
|
||||
|
||||
this.remapAssignments();
|
||||
|
||||
this.checkCollisions();
|
||||
}
|
||||
|
||||
DefaultFormatter.prototype.getLocalExports = function () {
|
||||
@@ -27,6 +31,53 @@ DefaultFormatter.prototype.getLocalExports = function () {
|
||||
return localExports;
|
||||
};
|
||||
|
||||
DefaultFormatter.prototype.getLocalImports = function () {
|
||||
var localImports = {};
|
||||
|
||||
traverse(this.file.ast, {
|
||||
enter: function (node) {
|
||||
if (t.isImportDeclaration(node)) {
|
||||
_.extend(localImports, t.getIds(node, true));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return localImports;
|
||||
};
|
||||
|
||||
DefaultFormatter.prototype.checkCollisions = function () {
|
||||
// todo: all check export collissions
|
||||
|
||||
var localImports = this.localImports;
|
||||
var file = this.file;
|
||||
|
||||
var isLocalReference = function (node) {
|
||||
return t.isIdentifier(node) && _.has(localImports, node.name) && localImports[node.name] !== node;
|
||||
};
|
||||
|
||||
var check = function (node) {
|
||||
if (isLocalReference(node)) {
|
||||
throw file.errorWithNode(node, "Illegal assignment of module import");
|
||||
}
|
||||
};
|
||||
|
||||
traverse(file.ast, {
|
||||
enter: function (node) {
|
||||
if (t.isAssignmentExpression(node)) {
|
||||
|
||||
var left = node.left;
|
||||
if (t.isMemberExpression(left)) {
|
||||
while (left.object) left = left.object;
|
||||
}
|
||||
|
||||
check(left);
|
||||
} else if (t.isDeclaration(node)) {
|
||||
_.each(t.getIds(node, true), check);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
DefaultFormatter.prototype.remapExportAssignment = function (node) {
|
||||
return t.assignmentExpression(
|
||||
"=",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
module.exports = AMDFormatter;
|
||||
|
||||
var DefaultFormatter = require("./_default");
|
||||
var CommonFormatter = require("./common");
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
@@ -30,12 +31,15 @@ AMDFormatter.prototype.transform = function (ast) {
|
||||
|
||||
// build an array of module names
|
||||
|
||||
var names = [t.literal("exports")].concat(this.buildDependencyLiterals());
|
||||
var names = [t.literal("exports")];
|
||||
if (this.passModuleArg) names.push(t.literal("module"));
|
||||
names = names.concat(this.buildDependencyLiterals());
|
||||
names = t.arrayExpression(names);
|
||||
|
||||
// build up define container
|
||||
|
||||
var params = _.values(this.ids);
|
||||
if (this.passModuleArg) params.unshift(t.identifier("module"));
|
||||
params.unshift(t.identifier("exports"));
|
||||
|
||||
var container = t.functionExpression(null, params, t.blockStatement(body));
|
||||
@@ -96,6 +100,14 @@ AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
|
||||
]));
|
||||
};
|
||||
|
||||
AMDFormatter.prototype.exportDeclaration = function (node) {
|
||||
if (node.default) {
|
||||
this.passModuleArg = true;
|
||||
}
|
||||
|
||||
CommonFormatter.prototype.exportDeclaration.apply(this, arguments);
|
||||
};
|
||||
|
||||
AMDFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
|
||||
var self = this;
|
||||
return this._exportSpecifier(function () {
|
||||
|
||||
@@ -61,7 +61,7 @@ CommonJSFormatter.prototype.importDeclaration = function (node, nodes) {
|
||||
};
|
||||
|
||||
CommonJSFormatter.prototype.exportDeclaration = function (node, nodes) {
|
||||
if (node.default) {
|
||||
if (node.default && !this.exportIdentifier) {
|
||||
var declar = node.declaration;
|
||||
var assign;
|
||||
|
||||
|
||||
@@ -25,22 +25,37 @@ UMDFormatter.prototype.transform = function (ast) {
|
||||
// factory
|
||||
|
||||
var ids = _.values(this.ids);
|
||||
var args = [t.identifier("exports")].concat(ids);
|
||||
var args = [t.identifier("exports")];
|
||||
if (this.passModuleArg) args.push(t.identifier("module"));
|
||||
args = args.concat(ids);
|
||||
|
||||
var factory = t.functionExpression(null, args, t.blockStatement(body));
|
||||
|
||||
// runner
|
||||
|
||||
var defineArgs = [t.arrayExpression([t.literal("exports")].concat(names))];
|
||||
var defineArgs = [t.literal("exports")];
|
||||
if (this.passModuleArg) defineArgs.push(t.literal("module"));
|
||||
defineArgs = defineArgs.concat(names);
|
||||
defineArgs = [t.arrayExpression(defineArgs)];
|
||||
|
||||
// typeof exports !== "undefined" && typeof module !== "undefined"
|
||||
var testExports = t.binaryExpression("!==", t.unaryExpression("typeof", t.identifier("exports"), true), t.literal("undefined")),
|
||||
testModule = t.binaryExpression("!==", t.unaryExpression("typeof", t.identifier("module"), true), t.literal("undefined")),
|
||||
commonTests = this.passModuleArg ? t.logicalExpression("&&", testExports, testModule) : testExports;
|
||||
|
||||
var commonArgs = [t.identifier("exports")];
|
||||
if (this.passModuleArg) commonArgs.push(t.identifier("module"));
|
||||
commonArgs = commonArgs.concat(names.map(function (name) {
|
||||
return t.callExpression(t.identifier("require"), [name]);
|
||||
}));
|
||||
|
||||
var moduleName = this.getModuleName();
|
||||
if (moduleName) defineArgs.unshift(t.literal(moduleName));
|
||||
|
||||
var runner = util.template("umd-runner-body", {
|
||||
AMD_ARGUMENTS: defineArgs,
|
||||
|
||||
COMMON_ARGUMENTS: names.map(function (name) {
|
||||
return t.callExpression(t.identifier("require"), [name]);
|
||||
})
|
||||
COMMON_TEST: commonTests,
|
||||
COMMON_ARGUMENTS: commonArgs
|
||||
});
|
||||
|
||||
//
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(AMD_ARGUMENTS, factory);
|
||||
} else if (typeof exports !== "undefined") {
|
||||
factory(exports, COMMON_ARGUMENTS);
|
||||
} else if (COMMON_TEST) {
|
||||
factory(COMMON_ARGUMENTS);
|
||||
}
|
||||
});
|
||||
|
||||
39
lib/6to5/transformation/transformers/react.js
vendored
39
lib/6to5/transformation/transformers/react.js
vendored
@@ -36,8 +36,13 @@ exports.XJSAttribute = {
|
||||
}
|
||||
};
|
||||
|
||||
var isTag = function(tagName) {
|
||||
return (/^[a-z]|\-/).test(tagName);
|
||||
};
|
||||
|
||||
exports.XJSOpeningElement = {
|
||||
exit: function (node) {
|
||||
exit: function (node, parent, file) {
|
||||
var reactCompat = file.opts && file.opts.reactCompat;
|
||||
var tagExpr = node.name;
|
||||
var args = [];
|
||||
|
||||
@@ -48,10 +53,12 @@ exports.XJSOpeningElement = {
|
||||
tagName = tagExpr.value;
|
||||
}
|
||||
|
||||
if (tagName && (/[a-z]/.exec(tagName[0]) || tagName.indexOf("-") >= 0)) {
|
||||
args.push(t.literal(tagName));
|
||||
} else {
|
||||
args.push(tagExpr);
|
||||
if (!reactCompat) {
|
||||
if (tagName && isTag(tagName)) {
|
||||
args.push(t.literal(tagName));
|
||||
} else {
|
||||
args.push(tagExpr);
|
||||
}
|
||||
}
|
||||
|
||||
var props = node.attributes;
|
||||
@@ -96,6 +103,28 @@ exports.XJSOpeningElement = {
|
||||
|
||||
args.push(props);
|
||||
|
||||
if (reactCompat) {
|
||||
if (tagName && isTag(tagName)) {
|
||||
return t.callExpression(
|
||||
t.memberExpression(
|
||||
t.memberExpression(
|
||||
t.identifier('React'),
|
||||
t.identifier('DOM'),
|
||||
false
|
||||
),
|
||||
tagExpr,
|
||||
t.isLiteral(tagExpr)
|
||||
),
|
||||
args
|
||||
);
|
||||
} else {
|
||||
return t.callExpression(
|
||||
tagExpr,
|
||||
args
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
tagExpr = t.memberExpression(t.identifier("React"), t.identifier("createElement"));
|
||||
return t.callExpression(tagExpr, args);
|
||||
}
|
||||
|
||||
@@ -355,16 +355,24 @@ t.getIds = function (node, map, ignoreTypes) {
|
||||
if (!id) continue;
|
||||
if (_.contains(ignoreTypes, id.type)) continue;
|
||||
|
||||
var nodeKey = t.getIds.nodes[id.type];
|
||||
var nodeKeys = t.getIds.nodes[id.type];
|
||||
var arrKeys = t.getIds.arrays[id.type];
|
||||
|
||||
var i, key;
|
||||
|
||||
if (t.isIdentifier(id)) {
|
||||
ids[id.name] = id;
|
||||
} else if (nodeKey) {
|
||||
if (id[nodeKey]) search.push(id[nodeKey]);
|
||||
} else if (nodeKeys) {
|
||||
for (i in nodeKeys) {
|
||||
key = nodeKeys[i];
|
||||
if (id[key]) {
|
||||
search.push(id[key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (arrKeys) {
|
||||
for (var i in arrKeys) {
|
||||
var key = arrKeys[i];
|
||||
for (i in arrKeys) {
|
||||
key = arrKeys[i];
|
||||
search = search.concat(id[key] || []);
|
||||
}
|
||||
}
|
||||
@@ -375,15 +383,16 @@ t.getIds = function (node, map, ignoreTypes) {
|
||||
};
|
||||
|
||||
t.getIds.nodes = {
|
||||
AssignmentExpression: "left",
|
||||
ImportSpecifier: "name",
|
||||
ExportSpecifier: "name",
|
||||
VariableDeclarator: "id",
|
||||
FunctionDeclaration: "id",
|
||||
ClassDeclaration: "id",
|
||||
MemeberExpression: "object",
|
||||
SpreadElement: "argument",
|
||||
Property: "value"
|
||||
AssignmentExpression: ["left"],
|
||||
ImportBatchSpecifier: ["name"],
|
||||
ImportSpecifier: ["name", "id"],
|
||||
ExportSpecifier: ["name", "id"],
|
||||
VariableDeclarator: ["id"],
|
||||
FunctionDeclaration: ["id"],
|
||||
ClassDeclaration: ["id"],
|
||||
MemeberExpression: ["object"],
|
||||
SpreadElement: ["argument"],
|
||||
Property: ["value"]
|
||||
};
|
||||
|
||||
t.getIds.arrays = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "2.6.3",
|
||||
"version": "2.7.0",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/6to5/6to5",
|
||||
"repository": {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
define(["exports"], function (exports) {
|
||||
define(["exports", "module"], function (exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports["default"] = foo;
|
||||
exports["default"] = 42;
|
||||
exports["default"] = {};
|
||||
exports["default"] = [];
|
||||
exports["default"] = foo;
|
||||
exports["default"] = function () {};
|
||||
module.exports = foo;
|
||||
module.exports = 42;
|
||||
module.exports = {};
|
||||
module.exports = [];
|
||||
module.exports = foo;
|
||||
module.exports = function () {};
|
||||
|
||||
exports["default"] = function () {};
|
||||
module.exports = function () {};
|
||||
|
||||
function foo() {}
|
||||
var Foo = function Foo() {};
|
||||
|
||||
exports["default"] = Foo;
|
||||
});
|
||||
module.exports = Foo;
|
||||
});
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
import foo from "foo";
|
||||
import {default as foo} from "foo";
|
||||
import {default as foo2} from "foo";
|
||||
|
||||
@@ -7,5 +7,5 @@ define(["exports", "foo"], function (exports, _foo) {
|
||||
|
||||
var foo = _interopRequire(_foo);
|
||||
|
||||
var foo = _interopRequire(_foo);
|
||||
});
|
||||
var foo2 = _interopRequire(_foo);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {bar} from "foo";
|
||||
import {bar, baz} from "foo";
|
||||
import {bar as baz} from "foo";
|
||||
import {bar as baz, xyz} from "foo";
|
||||
import {bar2, baz} from "foo";
|
||||
import {bar as baz2} from "foo";
|
||||
import {bar as baz3, xyz} from "foo";
|
||||
|
||||
@@ -2,9 +2,9 @@ define(["exports", "foo"], function (exports, _foo) {
|
||||
"use strict";
|
||||
|
||||
var bar = _foo.bar;
|
||||
var bar = _foo.bar;
|
||||
var bar2 = _foo.bar2;
|
||||
var baz = _foo.baz;
|
||||
var baz = _foo.bar;
|
||||
var baz = _foo.bar;
|
||||
var baz2 = _foo.bar;
|
||||
var baz3 = _foo.bar;
|
||||
var xyz = _foo.xyz;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,11 +2,11 @@ import "foo";
|
||||
import "foo-bar";
|
||||
import "./directory/foo-bar";
|
||||
import foo from "foo";
|
||||
import * as foo from "foo";
|
||||
import * as foo2 from "foo";
|
||||
import {bar} from "foo";
|
||||
import {foo as bar} from "foo";
|
||||
import {foo as bar2} from "foo";
|
||||
|
||||
export {test};
|
||||
export var test = 5;
|
||||
export var test2 = 5;
|
||||
|
||||
export default test;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(["exports", "foo", "foo-bar", "./directory/foo-bar"], function (exports, _foo, _fooBar, _directoryFooBar) {
|
||||
define(["exports", "module", "foo", "foo-bar", "./directory/foo-bar"], function (exports, module, _foo, _fooBar, _directoryFooBar) {
|
||||
"use strict";
|
||||
|
||||
var _interopRequire = function (obj) {
|
||||
@@ -7,11 +7,11 @@ define(["exports", "foo", "foo-bar", "./directory/foo-bar"], function (exports,
|
||||
|
||||
var foo = _interopRequire(_foo);
|
||||
|
||||
var foo = _foo;
|
||||
var foo2 = _foo;
|
||||
var bar = _foo.bar;
|
||||
var bar = _foo.foo;
|
||||
var bar2 = _foo.foo;
|
||||
exports.test = test;
|
||||
var test = exports.test = 5;
|
||||
var test2 = exports.test2 = 5;
|
||||
|
||||
exports["default"] = test;
|
||||
});
|
||||
module.exports = test;
|
||||
});
|
||||
|
||||
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-2/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-2/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { foo } from "foo";
|
||||
var foo;
|
||||
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-2/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-2/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-3/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-3/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { foo } from "foo";
|
||||
foo.bar = 1;
|
||||
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-3/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-3/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-4/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-4/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import * as foo from "foo";
|
||||
foo = 1;
|
||||
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-4/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-4/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-5/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-5/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import * as foo from "foo";
|
||||
var foo;
|
||||
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-5/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-5/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-6/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-6/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { foo as bar } from "foo";
|
||||
var bar;
|
||||
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-6/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-6/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-7/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-7/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { foo as bar } from "foo";
|
||||
bar = 1;
|
||||
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-7/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-7/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-8/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-8/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { foo } from "foo";
|
||||
import { foo } from "bar";
|
||||
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-8/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-8/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-9/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-9/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { foo as bar } from "foo";
|
||||
import { foo as bar } from "bar";
|
||||
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-9/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping-9/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-modules-common/disallow-import-remapping/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { foo } from "foo";
|
||||
foo = 1;
|
||||
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/disallow-import-remapping/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
import foo from "foo";
|
||||
import {default as foo} from "foo";
|
||||
import {default as foo2} from "foo";
|
||||
|
||||
@@ -6,4 +6,4 @@ var _interopRequire = function (obj) {
|
||||
|
||||
var foo = _interopRequire(require("foo"));
|
||||
|
||||
var foo = _interopRequire(require("foo"));
|
||||
var foo2 = _interopRequire(require("foo"));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {bar} from "foo";
|
||||
import {bar, baz} from "foo";
|
||||
import {bar as baz} from "foo";
|
||||
import {bar as baz, xyz} from "foo";
|
||||
import {bar2, baz} from "foo";
|
||||
import {bar as baz2} from "foo";
|
||||
import {bar as baz3, xyz} from "foo";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var bar = require("foo").bar;
|
||||
var bar = require("foo").bar;
|
||||
var bar2 = require("foo").bar2;
|
||||
var baz = require("foo").baz;
|
||||
var baz = require("foo").bar;
|
||||
var baz = require("foo").bar;
|
||||
var baz2 = require("foo").bar;
|
||||
var baz3 = require("foo").bar;
|
||||
var xyz = require("foo").xyz;
|
||||
|
||||
@@ -2,9 +2,9 @@ import "foo";
|
||||
import "foo-bar";
|
||||
import "./directory/foo-bar";
|
||||
import foo from "foo";
|
||||
import * as foo from "foo";
|
||||
import * as foo2 from "foo";
|
||||
import {bar} from "foo";
|
||||
import {foo as bar} from "foo";
|
||||
import {foo as bar2} from "foo";
|
||||
|
||||
export {test};
|
||||
export var test = 5;
|
||||
|
||||
@@ -18,9 +18,9 @@ require("./directory/foo-bar");
|
||||
|
||||
var foo = _interopRequire(require("foo"));
|
||||
|
||||
var foo = _interopRequireWildcard(require("foo"));
|
||||
var foo2 = _interopRequireWildcard(require("foo"));
|
||||
|
||||
var bar = require("foo").bar;
|
||||
var bar = require("foo").foo;
|
||||
var bar2 = require("foo").foo;
|
||||
exports.test = test;
|
||||
var test = exports.test = 5;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
import foo from "foo";
|
||||
import {default as foo} from "foo";
|
||||
import {default as foo2} from "foo";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {bar} from "foo";
|
||||
import {bar, baz} from "foo";
|
||||
import {bar as baz} from "foo";
|
||||
import {bar as baz, xyz} from "foo";
|
||||
import {bar2, baz} from "foo";
|
||||
import {bar as baz2} from "foo";
|
||||
import {bar as baz3, xyz} from "foo";
|
||||
|
||||
@@ -2,11 +2,11 @@ import "foo";
|
||||
import "foo-bar";
|
||||
import "./directory/foo-bar";
|
||||
import foo from "foo";
|
||||
import * as foo from "foo";
|
||||
import * as foo2 from "foo";
|
||||
import {bar} from "foo";
|
||||
import {foo as bar} from "foo";
|
||||
import {foo as bar2} from "foo";
|
||||
|
||||
export {test};
|
||||
export var test = 5;
|
||||
export var test2 = 5;
|
||||
|
||||
export default test;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
var test = 5;
|
||||
var test2 = 5;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
import foo from "foo";
|
||||
import {default as foo} from "foo";
|
||||
import {default as foo2} from "foo";
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
System.register(["foo"], function (_export) {
|
||||
"use strict";
|
||||
|
||||
var foo, foo;
|
||||
var foo, foo2;
|
||||
return {
|
||||
setters: [function (_foo) {
|
||||
foo = _foo["default"];
|
||||
foo = _foo["default"];
|
||||
foo2 = _foo["default"];
|
||||
}],
|
||||
execute: function () {}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {bar} from "foo";
|
||||
import {bar, baz} from "foo";
|
||||
import {bar as baz} from "foo";
|
||||
import {bar as baz, xyz} from "foo";
|
||||
import {bar2, baz} from "foo";
|
||||
import {bar as baz2} from "foo";
|
||||
import {bar as baz3, xyz} from "foo";
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
System.register(["foo"], function (_export) {
|
||||
"use strict";
|
||||
|
||||
var bar, bar, baz, baz, baz, xyz;
|
||||
var bar, bar2, baz, baz2, baz3, xyz;
|
||||
return {
|
||||
setters: [function (_foo) {
|
||||
bar = _foo.bar;
|
||||
bar = _foo.bar;
|
||||
bar2 = _foo.bar2;
|
||||
baz = _foo.baz;
|
||||
baz = _foo.bar;
|
||||
baz = _foo.bar;
|
||||
baz2 = _foo.bar;
|
||||
baz3 = _foo.bar;
|
||||
xyz = _foo.xyz;
|
||||
}],
|
||||
execute: function () {}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,11 +2,11 @@ import "foo";
|
||||
import "foo-bar";
|
||||
import "./directory/foo-bar";
|
||||
import foo from "foo";
|
||||
import * as foo from "foo";
|
||||
import * as foo2 from "foo";
|
||||
import {bar} from "foo";
|
||||
import {foo as bar} from "foo";
|
||||
import {foo as bar2} from "foo";
|
||||
|
||||
export {test};
|
||||
export var test = 5;
|
||||
export var test2 = 5;
|
||||
|
||||
export default test;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
System.register(["foo", "foo-bar", "./directory/foo-bar"], function (_export) {
|
||||
"use strict";
|
||||
|
||||
var foo, foo, bar, bar, test;
|
||||
var foo, foo2, bar, bar2, test2;
|
||||
return {
|
||||
setters: [function (_foo) {
|
||||
foo = _foo["default"];
|
||||
foo = _foo;
|
||||
foo2 = _foo;
|
||||
bar = _foo.bar;
|
||||
bar = _foo.foo;
|
||||
bar2 = _foo.foo;
|
||||
}, function (_fooBar) {}, function (_directoryFooBar) {}],
|
||||
execute: function () {
|
||||
_export("test", test);
|
||||
|
||||
test = _export("test", 5);
|
||||
test2 = _export("test2", 5);
|
||||
_export("default", test);
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports"], factory);
|
||||
} else if (typeof exports !== "undefined") {
|
||||
factory(exports);
|
||||
define(["exports", "module"], factory);
|
||||
} else if (typeof exports !== "undefined" && typeof module !== "undefined") {
|
||||
factory(exports, module);
|
||||
}
|
||||
})(function (exports) {
|
||||
})(function (exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports["default"] = foo;
|
||||
exports["default"] = 42;
|
||||
exports["default"] = {};
|
||||
exports["default"] = [];
|
||||
exports["default"] = foo;
|
||||
exports["default"] = function () {};
|
||||
module.exports = foo;
|
||||
module.exports = 42;
|
||||
module.exports = {};
|
||||
module.exports = [];
|
||||
module.exports = foo;
|
||||
module.exports = function () {};
|
||||
|
||||
exports["default"] = function () {};
|
||||
module.exports = function () {};
|
||||
|
||||
function foo() {}
|
||||
var Foo = function Foo() {};
|
||||
|
||||
exports["default"] = Foo;
|
||||
});
|
||||
module.exports = Foo;
|
||||
});
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
import foo from "foo";
|
||||
import {default as foo} from "foo";
|
||||
import {default as foo2} from "foo";
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
|
||||
var foo = _interopRequire(_foo);
|
||||
|
||||
var foo = _interopRequire(_foo);
|
||||
});
|
||||
var foo2 = _interopRequire(_foo);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {bar} from "foo";
|
||||
import {bar, baz} from "foo";
|
||||
import {bar as baz} from "foo";
|
||||
import {bar as baz, xyz} from "foo";
|
||||
import {bar2, baz} from "foo";
|
||||
import {bar as baz2} from "foo";
|
||||
import {bar as baz3, xyz} from "foo";
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
"use strict";
|
||||
|
||||
var bar = _foo.bar;
|
||||
var bar = _foo.bar;
|
||||
var bar2 = _foo.bar2;
|
||||
var baz = _foo.baz;
|
||||
var baz = _foo.bar;
|
||||
var baz = _foo.bar;
|
||||
var baz2 = _foo.bar;
|
||||
var baz3 = _foo.bar;
|
||||
var xyz = _foo.xyz;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,11 +2,11 @@ import "foo";
|
||||
import "foo-bar";
|
||||
import "./directory/foo-bar";
|
||||
import foo from "foo";
|
||||
import * as foo from "foo";
|
||||
import * as foo2 from "foo";
|
||||
import {bar} from "foo";
|
||||
import {foo as bar} from "foo";
|
||||
import {foo as bar2} from "foo";
|
||||
|
||||
export {test};
|
||||
export var test = 5;
|
||||
export var test2 = 5;
|
||||
|
||||
export default test;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports", "foo", "foo-bar", "./directory/foo-bar"], factory);
|
||||
} else if (typeof exports !== "undefined") {
|
||||
factory(exports, require("foo"), require("foo-bar"), require("./directory/foo-bar"));
|
||||
define(["exports", "module", "foo", "foo-bar", "./directory/foo-bar"], factory);
|
||||
} else if (typeof exports !== "undefined" && typeof module !== "undefined") {
|
||||
factory(exports, module, require("foo"), require("foo-bar"), require("./directory/foo-bar"));
|
||||
}
|
||||
})(function (exports, _foo, _fooBar, _directoryFooBar) {
|
||||
})(function (exports, module, _foo, _fooBar, _directoryFooBar) {
|
||||
"use strict";
|
||||
|
||||
var _interopRequire = function (obj) {
|
||||
@@ -13,11 +13,11 @@
|
||||
|
||||
var foo = _interopRequire(_foo);
|
||||
|
||||
var foo = _foo;
|
||||
var foo2 = _foo;
|
||||
var bar = _foo.bar;
|
||||
var bar = _foo.foo;
|
||||
var bar2 = _foo.foo;
|
||||
exports.test = test;
|
||||
var test = exports.test = 5;
|
||||
var test2 = exports.test2 = 5;
|
||||
|
||||
exports["default"] = test;
|
||||
});
|
||||
module.exports = test;
|
||||
});
|
||||
|
||||
3
test/fixtures/transformation/react/compat-convert-component/actual.js
vendored
Normal file
3
test/fixtures/transformation/react/compat-convert-component/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var x = <Component foo="bar">
|
||||
<Namespace.Component />
|
||||
</Component>
|
||||
3
test/fixtures/transformation/react/compat-convert-component/expected.js
vendored
Normal file
3
test/fixtures/transformation/react/compat-convert-component/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var x = Component({
|
||||
foo: "bar"
|
||||
}, Namespace.Component(null));
|
||||
3
test/fixtures/transformation/react/compat-convert-component/options.json
vendored
Normal file
3
test/fixtures/transformation/react/compat-convert-component/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"reactCompat": true
|
||||
}
|
||||
1
test/fixtures/transformation/react/compat-convert-tags/actual.js
vendored
Normal file
1
test/fixtures/transformation/react/compat-convert-tags/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var x = <div foo="bar"><font-face></font-face></div>;
|
||||
3
test/fixtures/transformation/react/compat-convert-tags/expected.js
vendored
Normal file
3
test/fixtures/transformation/react/compat-convert-tags/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var x = React.DOM.div({
|
||||
foo: "bar"
|
||||
}, React.DOM["font-face"](null));
|
||||
3
test/fixtures/transformation/react/compat-convert-tags/options.json
vendored
Normal file
3
test/fixtures/transformation/react/compat-convert-tags/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"reactCompat": true
|
||||
}
|
||||
@@ -12,7 +12,7 @@ var _ = require("lodash");
|
||||
var regeneratorLoc = __dirname + "/../vendor/regenerator";
|
||||
|
||||
if (!fs.existsSync(regeneratorLoc)) {
|
||||
console.error("No vendor/regenerator - run `git submodule update --init && cd vendor/regenerator && npm install`");
|
||||
console.error("No vendor/regenerator - run `make bootstrap`");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
59
test/test262.js
Normal file
59
test/test262.js
Normal file
@@ -0,0 +1,59 @@
|
||||
if (process.env.SIMPLE_6TO5_TESTS) return;
|
||||
|
||||
var transform = require("../lib/6to5/transformation/transform");
|
||||
var readdir = require("fs-readdir-recursive");
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
var test262Loc = __dirname + "/../vendor/test262";
|
||||
if (!fs.existsSync(test262Loc)) {
|
||||
console.error("No vendor/test262 - run `make bootstrap`");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var read = function (loc) {
|
||||
return readdir(loc).map(function (filename) {
|
||||
return path.join(loc, filename);
|
||||
});
|
||||
};
|
||||
|
||||
var exec = function (loc) {
|
||||
try {
|
||||
var file = fs.readFileSync(loc, "utf8");
|
||||
|
||||
// this normalises syntax and early runtime reference errors since they're
|
||||
// both thrown as SyntaxErrors in acorn
|
||||
// SyntaxError: var null;
|
||||
// ReferenceError: 1++; (runtime)
|
||||
var lazyError = /negative: (\S+)/.test(file);
|
||||
|
||||
var compiled = transform(file, {
|
||||
filename: loc,
|
||||
blacklist: ["useStrict"]
|
||||
});
|
||||
|
||||
global.eval(compiled);
|
||||
} catch (err) {
|
||||
if (err && lazyError && err instanceof SyntaxError) {
|
||||
return;
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// harness
|
||||
var harness = read(test262Loc + "/harness");
|
||||
_.each(harness, exec);
|
||||
|
||||
// tests!
|
||||
var tests = read(test262Loc + "/test");
|
||||
_.each(tests, function (loc) {
|
||||
var alias = path.relative(test262Loc + "/test", loc);
|
||||
alias = alias.replace(/\.([^\.]+)$/g, "");
|
||||
test(alias, function () {
|
||||
this.timeout(0);
|
||||
exec(loc);
|
||||
});
|
||||
});
|
||||
@@ -5,7 +5,7 @@ var _ = require("lodash");
|
||||
|
||||
var traceurLoc = __dirname + "/../vendor/traceur";
|
||||
if (!fs.existsSync(traceurLoc)) {
|
||||
console.error("No vendor/traceur - run `git submodule update --init`");
|
||||
console.error("No vendor/traceur - run `make bootstrap`");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
1
vendor/test262
vendored
Submodule
1
vendor/test262
vendored
Submodule
Submodule vendor/test262 added at d075338699
Reference in New Issue
Block a user