Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0528560d81 | ||
|
|
4362ba93de | ||
|
|
ca12e87370 | ||
|
|
ebaa735adc | ||
|
|
62e406a6fe | ||
|
|
0d45a8975c | ||
|
|
8f64fe2332 | ||
|
|
a8a7587c1f | ||
|
|
7736fa11f2 | ||
|
|
d203924541 | ||
|
|
cd23e500a1 | ||
|
|
bf24a0d6b5 | ||
|
|
279d1affea | ||
|
|
2a1e012240 | ||
|
|
a307a961a6 | ||
|
|
fe5b1dc542 | ||
|
|
f057347ae9 | ||
|
|
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
|
||||
|
||||
20
CHANGELOG.md
20
CHANGELOG.md
@@ -11,6 +11,26 @@
|
||||
|
||||
_Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
## 2.7.3
|
||||
|
||||
* **Polish**
|
||||
* Indent and add newlines to `React.createElement` calls in `react` transformer.
|
||||
* Remove `Object.assign` calls and replace it with an `extends` helper.
|
||||
|
||||
## 2.7.1
|
||||
|
||||
* **New Feature**
|
||||
* Expose `version` on browser and node API.
|
||||
* **Internal**
|
||||
* Upgrade `core-js` to 0.4.1
|
||||
|
||||
## 2.7.0
|
||||
|
||||
* **Spec Compliancy**
|
||||
* Disallow reassignments of imports.
|
||||
* **New Feature**
|
||||
* `reactCompat` option 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
|
||||
node $(ISTANBUL_CMD) $(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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,7 @@
|
||||
var transform = module.exports = require("./transformation/transform");
|
||||
|
||||
transform.version = require("../../package").version;
|
||||
|
||||
transform.transform = transform;
|
||||
|
||||
transform.run = function (code, opts) {
|
||||
|
||||
@@ -35,7 +35,8 @@ File.helpers = [
|
||||
"async-to-generator",
|
||||
"interop-require-wildcard",
|
||||
"typeof",
|
||||
"exports-wildcard"
|
||||
"exports-wildcard",
|
||||
"extends"
|
||||
];
|
||||
|
||||
File.excludeHelpersFromRuntime = [
|
||||
@@ -48,6 +49,7 @@ File.normaliseOptions = function (opts) {
|
||||
|
||||
_.defaults(opts, {
|
||||
experimental: false,
|
||||
reactCompat: false,
|
||||
playground: false,
|
||||
whitespace: true,
|
||||
moduleIds: opts.amdModuleIds || false,
|
||||
|
||||
@@ -57,8 +57,28 @@ exports.ThisExpression = function () {
|
||||
|
||||
exports.CallExpression = function (node, print) {
|
||||
print(node.callee);
|
||||
|
||||
this.push("(");
|
||||
print.join(node.arguments, { separator: ", " });
|
||||
|
||||
var separator = ",";
|
||||
|
||||
if (node._prettyPrint) {
|
||||
separator += "\n";
|
||||
this.newline();
|
||||
this.indent();
|
||||
} else {
|
||||
separator += " ";
|
||||
}
|
||||
|
||||
print.join(node.arguments, {
|
||||
separator: separator
|
||||
});
|
||||
|
||||
if (node._prettyPrint) {
|
||||
this.newline();
|
||||
this.dedent();
|
||||
}
|
||||
|
||||
this.push(")");
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ var util = require("./util");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
exports.version = require("../../package").version;
|
||||
|
||||
exports.types = require("./types");
|
||||
|
||||
exports.runtime = require("./runtime-generator");
|
||||
|
||||
@@ -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(
|
||||
"=",
|
||||
@@ -110,6 +161,9 @@ DefaultFormatter.prototype.getModuleName = function () {
|
||||
|
||||
moduleName += filenameRelative;
|
||||
|
||||
// normalise path separators
|
||||
moduleName = moduleName.replace(/\\/g, "/");
|
||||
|
||||
return moduleName;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -83,10 +83,12 @@ CommonJSFormatter.prototype.exportDeclaration = function (node, nodes) {
|
||||
// this export isn't a function so we can't hoist it to the top so we need to set it
|
||||
// at the very end of the file with something like:
|
||||
//
|
||||
// module.exports = Object.assign(exports["default"], exports)
|
||||
// module.exports = _extends(exports["default"], exports)
|
||||
//
|
||||
|
||||
assign = util.template("common-export-default-assign", true);
|
||||
assign = util.template("common-export-default-assign", {
|
||||
EXTENDS_HELPER: this.file.addHelper("extends")
|
||||
}, true);
|
||||
assign._blockHoist = 0;
|
||||
|
||||
nodes.push(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 +1 @@
|
||||
module.exports = Object.assign(exports["default"], exports);
|
||||
module.exports = EXTENDS_HELPER(exports["default"], exports);
|
||||
|
||||
9
lib/6to5/transformation/templates/extends.js
Normal file
9
lib/6to5/transformation/templates/extends.js
Normal file
@@ -0,0 +1,9 @@
|
||||
(function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var key in source) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
return target;
|
||||
})
|
||||
@@ -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,6 +39,8 @@ transform.moduleFormatters = {
|
||||
};
|
||||
|
||||
_.each({
|
||||
specNoForInOfAssignment: require("./transformers/spec-no-for-in-of-assignment"),
|
||||
|
||||
// playground
|
||||
methodBinding: require("./transformers/playground-method-binding"),
|
||||
memoizationOperator: require("./transformers/playground-memoization-operator"),
|
||||
|
||||
@@ -4,7 +4,7 @@ var t = require("../../types");
|
||||
|
||||
exports.experimental = true;
|
||||
|
||||
exports.ObjectExpression = function (node) {
|
||||
exports.ObjectExpression = function (node, parent, file) {
|
||||
var hasSpread = false;
|
||||
var i;
|
||||
var prop;
|
||||
@@ -42,5 +42,5 @@ exports.ObjectExpression = function (node) {
|
||||
args.unshift(t.objectExpression([]));
|
||||
}
|
||||
|
||||
return t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("assign")), args);
|
||||
return t.callExpression(file.addHelper("extends"), args);
|
||||
};
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
var OBJECT_ASSIGN_MEMBER = t.memberExpression(t.identifier("Object"), t.identifier("assign"));
|
||||
|
||||
var isProtoKey = function (node) {
|
||||
return t.isLiteral(t.toComputedKey(node, node.key), { value: "__proto__" });
|
||||
};
|
||||
@@ -43,7 +41,7 @@ exports.ExpressionStatement = function (node, parent, file) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.ObjectExpression = function (node) {
|
||||
exports.ObjectExpression = function (node, parent, file) {
|
||||
var proto;
|
||||
|
||||
for (var i in node.properties) {
|
||||
@@ -58,6 +56,6 @@ exports.ObjectExpression = function (node) {
|
||||
if (proto) {
|
||||
var args = [t.objectExpression([]), proto];
|
||||
if (node.properties.length) args.push(node);
|
||||
return t.callExpression(OBJECT_ASSIGN_MEMBER, args);
|
||||
return t.callExpression(file.addHelper("extends"), args);
|
||||
}
|
||||
};
|
||||
|
||||
45
lib/6to5/transformation/transformers/react.js
vendored
45
lib/6to5/transformation/transformers/react.js
vendored
@@ -32,12 +32,17 @@ exports.XJSExpressionContainer = function (node) {
|
||||
exports.XJSAttribute = {
|
||||
exit: function (node) {
|
||||
var value = node.value || t.literal(true);
|
||||
return t.property("init", node.name, value);
|
||||
return t.inherits(t.property("init", node.name, value), node);
|
||||
}
|
||||
};
|
||||
|
||||
var isTag = function(tagName) {
|
||||
return (/^[a-z]|\-/).test(tagName);
|
||||
};
|
||||
|
||||
exports.XJSOpeningElement = {
|
||||
exit: function (node) {
|
||||
exit: function (node, parent, file) {
|
||||
var reactCompat = 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,7 +103,21 @@ exports.XJSOpeningElement = {
|
||||
|
||||
args.push(props);
|
||||
|
||||
tagExpr = t.memberExpression(t.identifier("React"), t.identifier("createElement"));
|
||||
if (reactCompat) {
|
||||
if (tagName && isTag(tagName)) {
|
||||
return t.callExpression(
|
||||
t.memberExpression(
|
||||
t.memberExpression(t.identifier("React"), t.identifier("DOM")),
|
||||
tagExpr,
|
||||
t.isLiteral(tagExpr)
|
||||
),
|
||||
args
|
||||
);
|
||||
}
|
||||
} else {
|
||||
tagExpr = t.memberExpression(t.identifier("React"), t.identifier("createElement"));
|
||||
}
|
||||
|
||||
return t.callExpression(tagExpr, args);
|
||||
}
|
||||
};
|
||||
@@ -119,16 +140,16 @@ exports.XJSElement = {
|
||||
var isLastLine = +i === lines.length - 1;
|
||||
|
||||
// replace rendered whitespace tabs with spaces
|
||||
var trimmedLine = line.replace(/\t/g, ' ');
|
||||
var trimmedLine = line.replace(/\t/g, " ");
|
||||
|
||||
// trim whitespace touching a newline
|
||||
if (!isFirstLine) {
|
||||
trimmedLine = trimmedLine.replace(/^[ ]+/, '');
|
||||
trimmedLine = trimmedLine.replace(/^[ ]+/, "");
|
||||
}
|
||||
|
||||
// trim whitespace touching an endline
|
||||
if (!isLastLine) {
|
||||
trimmedLine = trimmedLine.replace(/[ ]+$/, '');
|
||||
trimmedLine = trimmedLine.replace(/[ ]+$/, "");
|
||||
}
|
||||
|
||||
if (trimmedLine) {
|
||||
@@ -144,6 +165,10 @@ exports.XJSElement = {
|
||||
callExpr.arguments.push(child);
|
||||
}
|
||||
|
||||
if (callExpr.arguments.length >= 3) {
|
||||
callExpr._prettyPrint = true;
|
||||
}
|
||||
|
||||
return t.inherits(callExpr, node);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
var t = require("../../types");
|
||||
|
||||
exports.ForInStatement =
|
||||
exports.ForOfStatement = function (node, parent, file) {
|
||||
var left = node.left;
|
||||
if (t.isVariableDeclaration(left)) {
|
||||
var declar = left.declarations[0];
|
||||
if (declar.init) throw file.errorWithNode(declar, "No assignments allowed in for-in/of head");
|
||||
}
|
||||
};
|
||||
@@ -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 = {
|
||||
|
||||
@@ -146,10 +146,10 @@ exports.template = function (name, nodes, keepExpression) {
|
||||
var node = template.body[0];
|
||||
|
||||
if (!keepExpression && t.isExpressionStatement(node)) {
|
||||
node = node.expression;
|
||||
return node.expression;
|
||||
} else {
|
||||
return node;
|
||||
}
|
||||
|
||||
return node;
|
||||
};
|
||||
|
||||
exports.codeFrame = function (lines, lineNumber, colNumber) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "2.6.3",
|
||||
"version": "2.7.3",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/6to5/6to5",
|
||||
"repository": {
|
||||
@@ -43,7 +43,7 @@
|
||||
"ast-types": "~0.6.1",
|
||||
"chokidar": "0.11.1",
|
||||
"commander": "2.5.0",
|
||||
"core-js": "^0.4.0",
|
||||
"core-js": "^0.4.1",
|
||||
"estraverse": "1.8.0",
|
||||
"esutils": "1.1.6",
|
||||
"esvalid": "^1.1.0",
|
||||
|
||||
@@ -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,6 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
var _extends = function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var key in source) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
exports.Cachier = Cachier;
|
||||
exports["default"] = new Cachier();
|
||||
function Cachier(databaseName) {}
|
||||
module.exports = Object.assign(exports["default"], exports);
|
||||
module.exports = _extends(exports["default"], exports);
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
z = Object.assign({ x: x }, y);
|
||||
var _extends = function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var key in source) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
z = _extends({ x: x }, y);
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
Object.assign({ x: x }, y, { a: a }, b, { c: c });
|
||||
var _extends = function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var key in source) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
_extends({ x: x }, y, { a: a }, b, { c: c });
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var z = Object.assign({}, x);
|
||||
var _extends = function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var key in source) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
var z = _extends({}, x);
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
var z = { ...x };
|
||||
@@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequire = function (obj) {
|
||||
return obj && (obj["default"] || obj);
|
||||
};
|
||||
|
||||
var _core = _interopRequire(require("core-js/library"));
|
||||
|
||||
var z = _core.Object.assign({}, x);
|
||||
@@ -1,10 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
var foo = Object.assign({}, bar);
|
||||
var _extends = function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var key in source) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
|
||||
var foo = Object.assign({}, bar, {
|
||||
return target;
|
||||
};
|
||||
|
||||
var foo = _extends({}, bar);
|
||||
|
||||
var foo = _extends({}, bar, {
|
||||
bar: "foo" });
|
||||
|
||||
var foo = Object.assign({}, bar, {
|
||||
var foo = _extends({}, bar, {
|
||||
bar: "foo"
|
||||
});
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
React.createElement(Component, React.__spread({}, this.props, {
|
||||
sound: "moo"
|
||||
}));
|
||||
sound: "moo" }));
|
||||
|
||||
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>
|
||||
1
test/fixtures/transformation/react/compat-convert-component/expected.js
vendored
Normal file
1
test/fixtures/transformation/react/compat-convert-component/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
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>;
|
||||
1
test/fixtures/transformation/react/compat-convert-tags/expected.js
vendored
Normal file
1
test/fixtures/transformation/react/compat-convert-tags/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
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
|
||||
}
|
||||
@@ -1,3 +1 @@
|
||||
React.createElement(Component, {
|
||||
constructor: "foo"
|
||||
});
|
||||
React.createElement(Component, { constructor: "foo" });
|
||||
|
||||
@@ -1,7 +1,23 @@
|
||||
var x = React.createElement("div", null, React.createElement(Component, null));
|
||||
var x = React.createElement(
|
||||
"div",
|
||||
null,
|
||||
React.createElement(Component, null)
|
||||
);
|
||||
|
||||
var x = React.createElement("div", null, this.props.children);
|
||||
var x = React.createElement(
|
||||
"div",
|
||||
null,
|
||||
this.props.children
|
||||
);
|
||||
|
||||
var x = React.createElement(Composite, null, this.props.children);
|
||||
var x = React.createElement(
|
||||
Composite,
|
||||
null,
|
||||
this.props.children
|
||||
);
|
||||
|
||||
var x = React.createElement(Composite, null, React.createElement(Composite2, null));
|
||||
var x = React.createElement(
|
||||
Composite,
|
||||
null,
|
||||
React.createElement(Composite2, null)
|
||||
);
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
var x = React.createElement("div", null, "text");
|
||||
var x = React.createElement(
|
||||
"div",
|
||||
null,
|
||||
"text"
|
||||
);
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
React.createElement("hasOwnProperty", null, "testing");
|
||||
React.createElement(
|
||||
"hasOwnProperty",
|
||||
null,
|
||||
"testing"
|
||||
);
|
||||
|
||||
@@ -1 +1,17 @@
|
||||
var x = React.createElement("div", null, React.createElement("div", null, React.createElement("br", null)), React.createElement(Component, null, foo, React.createElement("br", null), bar), React.createElement("br", null));
|
||||
var x = React.createElement(
|
||||
"div",
|
||||
null,
|
||||
React.createElement(
|
||||
"div",
|
||||
null,
|
||||
React.createElement("br", null)
|
||||
),
|
||||
React.createElement(
|
||||
Component,
|
||||
null,
|
||||
foo,
|
||||
React.createElement("br", null),
|
||||
bar
|
||||
),
|
||||
React.createElement("br", null)
|
||||
);
|
||||
|
||||
@@ -2,5 +2,4 @@ var x = React.createElement("div", {
|
||||
attr1: "foo" + "bar",
|
||||
attr2: "foo" + "bar" + "baz" + "bug",
|
||||
attr3: "foo" + "bar" + "baz" + "bug",
|
||||
attr4: "baz"
|
||||
});
|
||||
attr4: "baz" });
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
React.createElement(Component, React.__spread({}, x, {
|
||||
y: 2,
|
||||
z: true
|
||||
}));
|
||||
React.createElement(Component, React.__spread({}, x, { y: 2, z: true }));
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
React.createElement(Component, React.__spread({
|
||||
y: 2,
|
||||
z: true
|
||||
}, x));
|
||||
React.createElement(Component, React.__spread({ y: 2, z: true }, x));
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
React.createElement(Component, React.__spread({
|
||||
y: 2
|
||||
}, x, {
|
||||
z: true
|
||||
}));
|
||||
React.createElement(Component, React.__spread({ y: 2 }, x, { z: true }));
|
||||
|
||||
3
test/fixtures/transformation/spec/for-in-assignment/actual.js
vendored
Normal file
3
test/fixtures/transformation/spec/for-in-assignment/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
for (var i = 0 in obj) {
|
||||
|
||||
}
|
||||
3
test/fixtures/transformation/spec/for-in-assignment/options.json
vendored
Normal file
3
test/fixtures/transformation/spec/for-in-assignment/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "No assignments allowed in for-in/of head"
|
||||
}
|
||||
3
test/fixtures/transformation/spec/for-of-assignment/actual.js
vendored
Normal file
3
test/fixtures/transformation/spec/for-of-assignment/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
for (var i = 0 of obj) {
|
||||
|
||||
}
|
||||
3
test/fixtures/transformation/spec/for-of-assignment/options.json
vendored
Normal file
3
test/fixtures/transformation/spec/for-of-assignment/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "No assignments allowed in for-in/of head"
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user