Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcbd315bc1 | ||
|
|
71646f4ade | ||
|
|
e5f1eb64b6 | ||
|
|
6145f0a03b | ||
|
|
54f901f131 | ||
|
|
5deeae1aa2 | ||
|
|
c17878913b | ||
|
|
c8139317ee | ||
|
|
74f11dfddf | ||
|
|
6332e725fe | ||
|
|
89ecd46b77 | ||
|
|
7e8c5cd20f | ||
|
|
ddbb522392 | ||
|
|
288cfd1f00 | ||
|
|
1841f5c8a0 | ||
|
|
33f8988313 | ||
|
|
af997b9945 | ||
|
|
a2332f08bc | ||
|
|
115dca56b6 | ||
|
|
251e4d01c8 | ||
|
|
530ad78428 | ||
|
|
51f72ace57 | ||
|
|
2fa36b30d5 | ||
|
|
6f8cbf0ad1 | ||
|
|
6696d5fcf4 | ||
|
|
ecedc23892 | ||
|
|
163c68dd6a | ||
|
|
4dc6147348 | ||
|
|
fa6e50ea28 | ||
|
|
a72c839a73 | ||
|
|
32b5edb711 | ||
|
|
8cbb121e3f | ||
|
|
75ece96475 | ||
|
|
b016fda8af | ||
|
|
2cffad61fa | ||
|
|
4e248c0a16 | ||
|
|
4f5026101b | ||
|
|
4ce38eab37 | ||
|
|
0a7ce115ff | ||
|
|
21ed438fd8 | ||
|
|
5f9e954d21 | ||
|
|
a03fd0f43a | ||
|
|
dcc5eaa95e | ||
|
|
3b7ce5aaa1 | ||
|
|
6811f071a9 | ||
|
|
9abda34e59 | ||
|
|
417ba2bd92 | ||
|
|
e23f8e92ba |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,5 +4,6 @@ test/tmp
|
||||
*.log
|
||||
*.cache
|
||||
/templates.json
|
||||
/browser.js
|
||||
coverage
|
||||
dist
|
||||
|
||||
@@ -17,5 +17,12 @@
|
||||
"loopfunc": true,
|
||||
"white": true,
|
||||
"maxparams": 5,
|
||||
"maxdepth": 4
|
||||
"maxdepth": 4,
|
||||
|
||||
"globals": {
|
||||
"suite": true,
|
||||
"set": true,
|
||||
"before": true,
|
||||
"bench": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ node_js:
|
||||
- "0.10"
|
||||
- "0.11"
|
||||
|
||||
branches:
|
||||
except:
|
||||
- experimental
|
||||
|
||||
before_script: "npm install -g codeclimate-test-reporter"
|
||||
script: "make test-travis"
|
||||
|
||||
|
||||
9
Makefile
9
Makefile
@@ -14,7 +14,7 @@ bench:
|
||||
node node_modules/matcha/bin/_matcha
|
||||
|
||||
test:
|
||||
$(JSHINT_CMD) lib
|
||||
$(JSHINT_CMD) lib bin benchmark/index.js
|
||||
$(MOCHA_CMD)
|
||||
|
||||
test-cov:
|
||||
@@ -35,7 +35,7 @@ build:
|
||||
|
||||
node bin/cache-templates
|
||||
|
||||
browserify lib/6to5/transform.js -s to5 >dist/6to5.js
|
||||
browserify lib/6to5/browser.js -s to5 >dist/6to5.js
|
||||
uglifyjs dist/6to5.js >dist/6to5.min.js
|
||||
|
||||
rm -rf templates.json
|
||||
@@ -45,6 +45,9 @@ publish:
|
||||
|
||||
make test
|
||||
|
||||
make build
|
||||
cp dist/6to5.js browser.js
|
||||
|
||||
node bin/cache-templates
|
||||
test -f templates.json
|
||||
|
||||
@@ -54,4 +57,4 @@ publish:
|
||||
|
||||
git push --follow-tags
|
||||
|
||||
rm -rf templates.json
|
||||
rm -rf templates.json browser.js
|
||||
|
||||
58
README.md
58
README.md
@@ -4,7 +4,7 @@
|
||||
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/sebmck/6to5">
|
||||
<img alt="Travis Status" src="http://img.shields.io/travis/sebmck/6to5.svg?style=flat&label=travis">
|
||||
<img alt="Travis Status" src="http://img.shields.io/travis/sebmck/6to5.svg?branch=master&style=flat&label=travis">
|
||||
</a>
|
||||
|
||||
<a href="https://codeclimate.com/github/sebmck/6to5">
|
||||
@@ -103,6 +103,10 @@ Compile the entire `src` directory and output it to the `lib` directory.
|
||||
|
||||
$ 6to5 src --out-dir lib
|
||||
|
||||
Compile the entire `src` directory and output it to the one concatenated file.
|
||||
|
||||
$ 6to5 src --out-file script-compiled.js
|
||||
|
||||
Pipe a file in via stdin and output it to `script-compiled.js`
|
||||
|
||||
$ 6to5 --out-file script-compiled.js < script.js
|
||||
@@ -186,21 +190,34 @@ require("6to5/register");
|
||||
```
|
||||
|
||||
**NOTE:** By default all requires to `node_modules` will be ignored. You can
|
||||
override this by passing an ignore regex via:
|
||||
|
||||
```javascript
|
||||
require("6to5/register")(/regex/);
|
||||
```
|
||||
|
||||
You can also customise the file extensions that the require hook will use via:
|
||||
override this by passing an ignore regex via options.
|
||||
|
||||
```javascript
|
||||
require("6to5/register")({
|
||||
// optional ignore regex
|
||||
ignoreRegex: /regex/,
|
||||
// This will override `node_modules` ignoring - you can alternatively pass
|
||||
// a regex
|
||||
ignore: false
|
||||
});
|
||||
```
|
||||
|
||||
// this will remove the currently hooked extensions of .es6 and .js so you'll
|
||||
// have to add them back if you want them to be used again
|
||||
##### Options
|
||||
|
||||
```javascript
|
||||
require("6to5/register")({
|
||||
// Optional ignore regex - if any filenames **do** match this regex then they
|
||||
// aren't compiled
|
||||
ignore: /regex/,
|
||||
|
||||
// Optional only regex - if any filenames **don't** match this regex then they
|
||||
// aren't compiled
|
||||
only: /my_es6_folder/,
|
||||
|
||||
// See options above for usage
|
||||
whitelist: [],
|
||||
blacklist: [],
|
||||
|
||||
// This will remove the currently hooked extensions of .es6 and .js so you'll
|
||||
// have to add them back if you want them to be used again.
|
||||
extensions: [".js", ".es6"]
|
||||
});
|
||||
```
|
||||
@@ -279,6 +296,23 @@ If you're inheriting from a class then static properties are inherited from it
|
||||
via [\_\_proto\_\_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto),
|
||||
this is widely supported but you may run into problems with much older browsers.
|
||||
|
||||
**NOTE:** `__proto__` is not supported on IE <= 9 so static properties
|
||||
**will not** be inherited. A possible workaround is to use `super();`:
|
||||
|
||||
```javascript
|
||||
class Foo {
|
||||
static foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
static foo() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Generators
|
||||
|
||||
The [regenerator runtime](https://github.com/facebook/regenerator/blob/master/runtime.js)
|
||||
|
||||
@@ -7,13 +7,10 @@ var es6now = require("es6now");
|
||||
var esnext = require("esnext");
|
||||
var to5 = require("../lib/6to5");
|
||||
|
||||
var uglify = require("uglify-js");
|
||||
//var uglify = require("uglify-js");
|
||||
var matcha = require("matcha");
|
||||
var stream = require("stream");
|
||||
var path = require("path");
|
||||
var zlib = require("zlib");
|
||||
var fs = require("fs");
|
||||
var vm = require("vm");
|
||||
var _ = require("lodash");
|
||||
|
||||
var readResolve = function (filename) {
|
||||
@@ -51,7 +48,7 @@ var compilers = {
|
||||
|
||||
traceur: {
|
||||
runtime: readResolve("traceur/bin/traceur-runtime.js"),
|
||||
compile: function (code, filename) {
|
||||
compile: function (code) {
|
||||
return traceur.compile(code, {
|
||||
modules: "commonjs",
|
||||
experimental: true
|
||||
@@ -61,20 +58,20 @@ var compilers = {
|
||||
|
||||
esnext: {
|
||||
runtime: readResolve("esnext/node_modules/regenerator/runtime.js") || readResolve("regenerator/runtime.js"),
|
||||
compile: function (code, filename) {
|
||||
compile: function (code) {
|
||||
return esnext.compile(code).code;
|
||||
}
|
||||
},
|
||||
|
||||
es6now: {
|
||||
runtime: readResolve("es6now/runtime/ES6.js"),
|
||||
compile: function (code, filename) {
|
||||
compile: function (code) {
|
||||
return es6now.translate(code);
|
||||
}
|
||||
},
|
||||
|
||||
"es6-transpiler": {
|
||||
compile: function (code, filename) {
|
||||
compile: function (code) {
|
||||
var result = es6tr.run({ src: code });
|
||||
if (result.errors.length) throw new Error(result.join("; "));
|
||||
return result.src;
|
||||
@@ -82,7 +79,7 @@ var compilers = {
|
||||
},
|
||||
|
||||
jstransform: {
|
||||
compile: function (code, filename) {
|
||||
compile: function (code) {
|
||||
return jsTrans.transform(jsTransVisitors, code).code;
|
||||
}
|
||||
}
|
||||
@@ -90,7 +87,7 @@ var compilers = {
|
||||
|
||||
// versions
|
||||
|
||||
var uglifyTitle = "uglify v" + getVersion("uglify-js");
|
||||
//var uglifyTitle = "uglify v" + getVersion("uglify-js");
|
||||
|
||||
_.each(compilers, function (compiler, name) {
|
||||
compiler.title = name + " v" + (compiler.version || getVersion(name));
|
||||
@@ -140,9 +137,9 @@ var sizeBenchmark = function (code, loc, name, compiler) {
|
||||
});
|
||||
if (!output) return;
|
||||
|
||||
go(function () {
|
||||
return uglify.minify(output, { fromString: true }).code;
|
||||
}, uglifyTitle);
|
||||
//go(function () {
|
||||
// return uglify.minify(output, { fromString: true }).code;
|
||||
//}, uglifyTitle);
|
||||
};
|
||||
|
||||
//
|
||||
@@ -162,7 +159,7 @@ _.each(fs.readdirSync(__dirname + "/fixtures"), function (name) {
|
||||
});
|
||||
});
|
||||
|
||||
_.each(compilers, function (compiler, name) {
|
||||
_.each(compilers, function (compiler) {
|
||||
bench(compiler.title, function () {
|
||||
compiler.compile(code, loc);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var commander = require("commander");
|
||||
var Module = require("module");
|
||||
var util = require("../lib/6to5/util");
|
||||
var path = require("path");
|
||||
var repl = require("repl");
|
||||
|
||||
@@ -6,7 +6,7 @@ var util = require("./util");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
module.exports = function (commander, filenames, opts) {
|
||||
module.exports = function (commander, filenames) {
|
||||
var results = [];
|
||||
|
||||
var buildResult = function () {
|
||||
@@ -48,7 +48,7 @@ module.exports = function (commander, filenames, opts) {
|
||||
return {
|
||||
map: map,
|
||||
code: code
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var output = function () {
|
||||
@@ -100,8 +100,8 @@ module.exports = function (commander, filenames, opts) {
|
||||
}
|
||||
});
|
||||
|
||||
_.each(_filenames, function (filename, i) {
|
||||
results.push(util.compile(filename, { _noStrict: i != 0 }));
|
||||
_.each(_filenames, function (filename) {
|
||||
results.push(util.compile(filename));
|
||||
});
|
||||
|
||||
output();
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var commander = require("commander");
|
||||
var sourceMap = require("source-map");
|
||||
var transform = require("../../lib/6to5/transform");
|
||||
var chokidar = require("chokidar");
|
||||
var mkdirp = require("mkdirp");
|
||||
var util2 = require("../../lib/6to5/util");
|
||||
var util = require("./util");
|
||||
var path = require("path");
|
||||
var util = require("../../lib/6to5/util");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
@@ -17,8 +12,8 @@ commander.option("-f, --filename [filename]", "Filename to use when reading from
|
||||
commander.option("-w, --watch", "Recompile files on changes");
|
||||
|
||||
commander.option("-m, --modules [modules]", "Module formatter type to use [common]", "common");
|
||||
commander.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util2.list);
|
||||
commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util2.list);
|
||||
commander.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list);
|
||||
commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list);
|
||||
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
|
||||
commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
|
||||
|
||||
|
||||
3
lib/6to5/browser.js
Normal file
3
lib/6to5/browser.js
Normal file
@@ -0,0 +1,3 @@
|
||||
var transform = require("./transform");
|
||||
|
||||
module.exports = transform;
|
||||
@@ -84,7 +84,8 @@ File.prototype.parse = function (code) {
|
||||
code = this.parseShebang(code);
|
||||
|
||||
return util.parse(this.opts, code, function (tree) {
|
||||
return self.transform(tree);
|
||||
self.transform(tree);
|
||||
return self.generate();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -96,8 +97,6 @@ File.prototype.transform = function (ast) {
|
||||
_.each(transform.transformers, function (transformer) {
|
||||
transformer.transform(self);
|
||||
});
|
||||
|
||||
return this.generate();
|
||||
};
|
||||
|
||||
File.prototype.generate = function () {
|
||||
|
||||
@@ -20,17 +20,56 @@ sourceMapSupport.install({
|
||||
|
||||
//
|
||||
|
||||
var blacklist = [];
|
||||
|
||||
var blacklistTest = function (transformer, code) {
|
||||
try {
|
||||
if (_.isFunction(code)) {
|
||||
code();
|
||||
} else {
|
||||
new Function(code);
|
||||
}
|
||||
blacklist.push(transformer);
|
||||
} catch (err) {
|
||||
if (err.name !== "SyntaxError") throw err;
|
||||
}
|
||||
};
|
||||
|
||||
blacklistTest("arrayComprehension", "var foo = [for (foo of bar) foo * foo];");
|
||||
blacklistTest("arrowFunctions", "var foo = x => x * x;");
|
||||
blacklistTest("classes", "class Foo {}");
|
||||
blacklistTest("computedPropertyNames", "var foo = { [foo]: bar };");
|
||||
//blacklistTest("constants", "const foo = 0;");
|
||||
blacklistTest("defaultParamaters", "var foo = function (bar = 0) {};");
|
||||
blacklistTest("destructuring", "var { x, y } = { x: 0, y: 0 };");
|
||||
blacklistTest("forOf", "for (var foo of bar) {}");
|
||||
blacklistTest("generators", "function* foo() {}");
|
||||
blacklistTest("letScoping", "let foo = 0;");
|
||||
blacklistTest("modules", 'import foo from "from";');
|
||||
blacklistTest("propertyMethodAssignment", "{ get foo() {} }");
|
||||
blacklistTest("propertyNameShorthand", "var foo = { x, y };");
|
||||
blacklistTest("restParameters", "function foo(...bar) {}");
|
||||
blacklistTest("spread", "foo(...bar);");
|
||||
blacklistTest("templateLiterals", "`foo`");
|
||||
blacklistTest("unicodeRegex", function () { new RegExp("foo", "u"); });
|
||||
|
||||
//
|
||||
|
||||
var ignoreRegex = /node_modules/;
|
||||
var onlyRegex;
|
||||
var whitelist = [];
|
||||
var exts = {};
|
||||
var maps = {};
|
||||
var old = require.extensions[".js"];
|
||||
|
||||
var loader = function (m, filename) {
|
||||
if (ignoreRegex && ignoreRegex.test(filename)) {
|
||||
if ((ignoreRegex && ignoreRegex.test(filename)) || (onlyRegex && !onlyRegex.test(filename))) {
|
||||
return old.apply(this, arguments);
|
||||
}
|
||||
|
||||
var result = to5.transformFileSync(filename, {
|
||||
whitelist: whitelist,
|
||||
blacklist: blacklist,
|
||||
sourceMap: true
|
||||
});
|
||||
|
||||
@@ -55,12 +94,16 @@ var hookExtensions = function (_exts) {
|
||||
hookExtensions([".es6", ".js"]);
|
||||
|
||||
module.exports = function (opts) {
|
||||
// normalise options
|
||||
opts = opts || {};
|
||||
if (_.isRegExp(opts)) opts = { ignoreRegex: opts };
|
||||
if (_.isRegExp(opts)) opts = { ignore: opts };
|
||||
if (opts.ignoreRegex != null) opts.ignore = opts.ignoreRegex;
|
||||
|
||||
if (opts.ignoreRegex != null) {
|
||||
ignoreRegex = opts.ignoreRegex;
|
||||
}
|
||||
if (opts.only != null) onlyRegex = opts.only;
|
||||
if (opts.ignore != null) ignoreRegex = opts.ignore;
|
||||
|
||||
if (opts.extensions) hookExtensions(opts.extensions);
|
||||
|
||||
if (opts.blacklist) blacklist = opts.blacklist;
|
||||
if (opts.whitelist) whitelist = opts.whitelist;
|
||||
};
|
||||
|
||||
4
lib/6to5/templates/class-props.js
Normal file
4
lib/6to5/templates/class-props.js
Normal file
@@ -0,0 +1,4 @@
|
||||
(function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
})
|
||||
@@ -71,7 +71,7 @@ transform.test = function (task, assert) {
|
||||
|
||||
transform._ensureTransformerNames = function (type, keys) {
|
||||
_.each(keys, function (key) {
|
||||
if (key[0] === "_" || !_.has(transform.transformers, key)) {
|
||||
if (!_.has(transform.transformers, key)) {
|
||||
throw new ReferenceError("unknown transformer " + key + " specified in " + type);
|
||||
}
|
||||
});
|
||||
@@ -95,6 +95,7 @@ transform.transformers = {
|
||||
forOf: require("./transformers/for-of"),
|
||||
unicodeRegex: require("./transformers/unicode-regex"),
|
||||
generators: require("./transformers/generators"),
|
||||
numericLiterals: require("./transformers/numeric-literals"),
|
||||
|
||||
react: require("./transformers/react"),
|
||||
jsx: require("./transformers/jsx"),
|
||||
@@ -102,9 +103,10 @@ transform.transformers = {
|
||||
_aliasFunctions: require("./transformers/_alias-functions"),
|
||||
_blockHoist: require("./transformers/_block-hoist"),
|
||||
_declarations: require("./transformers/_declarations"),
|
||||
_moduleFormatter: require("./transformers/_module-formatter"),
|
||||
|
||||
useStrict: require("./transformers/use-strict")
|
||||
useStrict: require("./transformers/use-strict"),
|
||||
|
||||
_moduleFormatter: require("./transformers/_module-formatter")
|
||||
};
|
||||
|
||||
transform.moduleFormatters = {
|
||||
|
||||
@@ -15,7 +15,7 @@ var go = function (getBody, node, file) {
|
||||
};
|
||||
|
||||
// traverse the function and find all alias functions so we can alias
|
||||
// arguments and this if neccesary
|
||||
// arguments and this if necessary
|
||||
traverse(node, function (node) {
|
||||
var _aliasFunction = node._aliasFunction;
|
||||
if (!_aliasFunction) {
|
||||
@@ -35,6 +35,8 @@ var go = function (getBody, node, file) {
|
||||
}
|
||||
}
|
||||
|
||||
if (node._ignoreAliasFunctions) return;
|
||||
|
||||
var getId;
|
||||
|
||||
if (node.type === "Identifier" && node.name === "arguments") {
|
||||
|
||||
@@ -56,14 +56,14 @@ var buildClass = function (node, file) {
|
||||
container.callee.params.push(superClassCallee);
|
||||
}
|
||||
|
||||
buildClassBody(body, className, superName, node);
|
||||
buildClassBody(file, body, className, superName, node);
|
||||
|
||||
body.push(returnStatement);
|
||||
|
||||
return container;
|
||||
};
|
||||
|
||||
var buildClassBody = function (body, className, superName, node) {
|
||||
var buildClassBody = function (file, body, className, superName, node) {
|
||||
var instanceMutatorMap = {};
|
||||
var staticMutatorMap = {};
|
||||
var hasConstructor = false;
|
||||
@@ -105,16 +105,28 @@ var buildClassBody = function (body, className, superName, node) {
|
||||
}, true));
|
||||
}
|
||||
|
||||
var instanceProps;
|
||||
var staticProps;
|
||||
|
||||
if (!_.isEmpty(instanceMutatorMap)) {
|
||||
var protoId = util.template("prototype-identifier", {
|
||||
CLASS_NAME: className
|
||||
});
|
||||
|
||||
body.push(util.buildDefineProperties(instanceMutatorMap, protoId));
|
||||
instanceProps = util.buildDefineProperties(instanceMutatorMap, protoId);
|
||||
}
|
||||
|
||||
if (!_.isEmpty(staticMutatorMap)) {
|
||||
body.push(util.buildDefineProperties(staticMutatorMap, className));
|
||||
staticProps = util.buildDefineProperties(staticMutatorMap, className);
|
||||
}
|
||||
|
||||
if (instanceProps || staticProps) {
|
||||
instanceProps = instanceProps || b.literal(null);
|
||||
staticProps = staticProps || b.literal(null);
|
||||
|
||||
body.push(b.expressionStatement(
|
||||
b.callExpression(file.addDeclaration("class-props"), [className, staticProps, instanceProps])
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -13,11 +13,15 @@ var buildVariableAssign = function (kind, id, init) {
|
||||
}
|
||||
};
|
||||
|
||||
var push = function (kind, nodes, pattern, parentId) {
|
||||
if (pattern.type === "ObjectPattern") {
|
||||
pushObjectPattern(kind, nodes, pattern, parentId);
|
||||
} else if (pattern.type === "ArrayPattern") {
|
||||
pushArrayPattern(kind, nodes, pattern, parentId);
|
||||
var push = function (kind, nodes, elem, parentId) {
|
||||
if (elem.type === "ObjectPattern") {
|
||||
pushObjectPattern(kind, nodes, elem, parentId);
|
||||
} else if (elem.type === "ArrayPattern") {
|
||||
pushArrayPattern(kind, nodes, elem, parentId);
|
||||
} else if (elem.type === "MemberExpression") {
|
||||
nodes.push(buildVariableAssign(false, elem, parentId));
|
||||
} else {
|
||||
nodes.push(buildVariableAssign(kind, elem, parentId));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,12 +43,7 @@ var pushArrayPattern = function (kind, nodes, pattern, parentId) {
|
||||
if (!elem) return;
|
||||
|
||||
var newPatternId = b.memberExpression(parentId, b.literal(i), true);
|
||||
|
||||
if (elem.type === "Identifier") {
|
||||
nodes.push(buildVariableAssign(kind, elem, newPatternId));
|
||||
} else {
|
||||
push(kind, nodes, elem, newPatternId);
|
||||
}
|
||||
push(kind, nodes, elem, newPatternId);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -149,5 +148,22 @@ exports.VariableDeclaration = function (node, parent, file) {
|
||||
}
|
||||
});
|
||||
|
||||
if (parent.type !== "Program" && parent.type !== "BlockStatement") {
|
||||
var declar;
|
||||
|
||||
_.each(nodes, function (node) {
|
||||
declar = declar || b.variableDeclaration(node.kind, []);
|
||||
|
||||
if (node.type !== "VariableDeclaration" && declar.kind !== node.kind) {
|
||||
throw util.errorWithNode(node, "Cannot use this node within the current parent");
|
||||
}
|
||||
|
||||
declar.declarations = declar.declarations.concat(node.declarations);
|
||||
});
|
||||
|
||||
return declar;
|
||||
}
|
||||
|
||||
return nodes;
|
||||
};
|
||||
|
||||
|
||||
@@ -42,9 +42,11 @@ exports.VariableDeclaration = function (node, parent, file) {
|
||||
if (node.type === "FunctionDeclaration") {
|
||||
throw new Error("`FunctionDeclaration`s that use `let` and `constant` references aren't allowed outside of the root scope");
|
||||
} else {
|
||||
return b.callExpression(b.functionExpression(null, letReferences, b.blockStatement([
|
||||
var func = b.functionExpression(null, letReferences, b.blockStatement([
|
||||
b.returnStatement(node)
|
||||
])), letReferences);
|
||||
]));
|
||||
func._aliasFunction = true;
|
||||
return b.callExpression(func, letReferences);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
|
||||
6
lib/6to5/transformers/numeric-literals.js
Normal file
6
lib/6to5/transformers/numeric-literals.js
Normal file
@@ -0,0 +1,6 @@
|
||||
var _ = require("lodash");
|
||||
|
||||
exports.Literal = function (node) {
|
||||
// TODO: remove this when the new code generator is released
|
||||
if (_.isNumber(node.value)) delete node.raw;
|
||||
};
|
||||
@@ -24,6 +24,9 @@ exports.ObjectExpression = function (node, parent, file) {
|
||||
return util.template("object-define-properties-closure", {
|
||||
KEY: objId,
|
||||
OBJECT: node,
|
||||
CONTENT: util.buildDefineProperties(mutatorMap, objId).expression
|
||||
CONTENT: util.template("object-define-properties", {
|
||||
OBJECT: objId,
|
||||
PROPS: util.buildDefineProperties(mutatorMap)
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
@@ -11,9 +11,14 @@ exports.Function = function (node, parent, file) {
|
||||
if (node.params.length) templateName += "-arg";
|
||||
|
||||
util.ensureBlock(node);
|
||||
node.body.body.unshift(util.template(templateName, {
|
||||
|
||||
var template = util.template(templateName, {
|
||||
SLICE_KEY: file.addDeclaration("slice"),
|
||||
VARIABLE_NAME: rest,
|
||||
SLICE_ARG: b.literal(node.params.length)
|
||||
}));
|
||||
});
|
||||
|
||||
template.declarations[0].init.arguments[0]._ignoreAliasFunctions = true;
|
||||
|
||||
node.body.body.unshift(template);
|
||||
};
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
var b = require("acorn-ast-types").builders;
|
||||
|
||||
module.exports = function (ast, file) {
|
||||
module.exports = function (ast) {
|
||||
var body = ast.program.body;
|
||||
var first = body[0];
|
||||
|
||||
var noStrict = !first || first.type !== "ExpressionStatement" || first.expression.type !== "Literal" || first.expression.value !== "use strict";
|
||||
|
||||
if (noStrict) {
|
||||
if (file.opts._noStrict) return;
|
||||
body.unshift(b.expressionStatement(b.literal("use strict")));
|
||||
} else {
|
||||
if (file.opts._noStrict) body.shift();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -147,7 +147,7 @@ exports.pushMutatorMap = function (mutatorMap, key, kind, method) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.buildDefineProperties = function (mutatorMap, keyNode) {
|
||||
exports.buildDefineProperties = function (mutatorMap) {
|
||||
var objExpr = b.objectExpression([]);
|
||||
|
||||
_.each(mutatorMap, function (map, key) {
|
||||
@@ -164,10 +164,7 @@ exports.buildDefineProperties = function (mutatorMap, keyNode) {
|
||||
objExpr.properties.push(propNode);
|
||||
});
|
||||
|
||||
return exports.template("object-define-properties", {
|
||||
OBJECT: keyNode,
|
||||
PROPS: objExpr
|
||||
}, true);
|
||||
return objExpr;
|
||||
};
|
||||
|
||||
exports.template = function (name, nodes, keepExpression) {
|
||||
@@ -275,7 +272,7 @@ exports.parse = function (opts, code, callback) {
|
||||
message += frame;
|
||||
}
|
||||
|
||||
err.stack = err.stack.replace(err.message, message);
|
||||
err.stack = err.stack.replace(err.message, message);
|
||||
err.message = message;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "1.10.2",
|
||||
"version": "1.10.12",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/sebmck/6to5",
|
||||
"repository": {
|
||||
@@ -48,7 +48,7 @@
|
||||
"source-map-support": "0.2.7",
|
||||
"esutils": "1.1.4",
|
||||
"acorn-jsx": "https://github.com/sebmck/acorn-jsx/archive/master.tar.gz",
|
||||
"acorn-recast": "0.8.0-3",
|
||||
"acorn-recast": "0.8.0-4",
|
||||
"acorn-ast-types": "0.5.3-1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -59,6 +59,7 @@
|
||||
"browserify": "6.1.0",
|
||||
"proclaim": "2.0.0",
|
||||
"rimraf": "2.2.8",
|
||||
"jshint": "2.5.6"
|
||||
"jshint": "2.5.6",
|
||||
"chai": "^1.9.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ var rimraf = require("rimraf");
|
||||
var mkdirp = require("mkdirp");
|
||||
var child = require("child_process");
|
||||
var path = require("path");
|
||||
var chai = require("chai");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
@@ -42,7 +43,7 @@ var assertTest = function (stdout, stderr, opts) {
|
||||
if (opts.stderrContains) {
|
||||
assert.ok(_.contains(stderr, expectStderr), "stderr " + JSON.stringify(stderr) + " didn't contain " + JSON.stringify(expectStderr));
|
||||
} else {
|
||||
assert.equal(stderr, expectStderr, "stderr didn't match");
|
||||
chai.expect(stderr).to.equal(expectStderr, "stderr didn't match");
|
||||
}
|
||||
} else if (stderr) {
|
||||
throw new Error("stderr: " + JSON.stringify(stderr));
|
||||
@@ -55,7 +56,7 @@ var assertTest = function (stdout, stderr, opts) {
|
||||
if (opts.stdoutContains) {
|
||||
assert.ok(_.contains(stdout, expectStdout), "stdout " + JSON.stringify(stdout) + " didn't contain " + JSON.stringify(expectStdout));
|
||||
} else {
|
||||
assert.equal(stdout, expectStdout, "stdout didn't match");
|
||||
chai.expect(stdout).to.equal(expectStdout, "stdout didn't match");
|
||||
}
|
||||
} else if (stdout) {
|
||||
throw new Error("stdout: " + JSON.stringify(stdout));
|
||||
@@ -63,7 +64,7 @@ var assertTest = function (stdout, stderr, opts) {
|
||||
|
||||
_.each(opts.outFiles, function (expect, filename) {
|
||||
var actual = readFile(filename);
|
||||
assert.equal(actual, expect, "out-file " + filename);
|
||||
chai.expect(actual).to.equal(expect, "out-file " + filename);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -4,8 +4,9 @@ var Test = function() {
|
||||
var Test = function Test() {};
|
||||
return Test;
|
||||
}();
|
||||
"use strict";
|
||||
arr.map(function(x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyIsInNjcmlwdDIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7SUFBTSxDQUFDLENBQUMsQ0FBQztNQUFILENBQUMsQ0FBQyxDQUFDLGFBQUgsQ0FBQyxDQUFDLENBQUM7U0FBSCxDQUFDLENBQUMsQ0FBQzs7O0FDQVQsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxVQUFDO1NBQUssRUFBRSxFQUFFLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO0NBQUMsQ0FBQyIsImZpbGUiOiJzY3JpcHQzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgVGVzdCB7XG5cbn0iLCJhcnIubWFwKHggPT4geCAqIE1VTFRJUExJRVIpOyJdfQ==
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyIsInNjcmlwdDIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7SUFBTSxDQUFDLENBQUMsQ0FBQztNQUFILENBQUMsQ0FBQyxDQUFDLGFBQUgsQ0FBQyxDQUFDLENBQUM7U0FBSCxDQUFDLENBQUMsQ0FBQzs7OztBQ0FULENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsVUFBQztTQUFLLEVBQUUsRUFBRSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztDQUFDLENBQUMiLCJmaWxlIjoic2NyaXB0My5qcyIsInNvdXJjZXNDb250ZW50IjpbImNsYXNzIFRlc3Qge1xuXG59IiwiYXJyLm1hcCh4ID0+IHggKiBNVUxUSVBMSUVSKTsiXX0=
|
||||
|
||||
@@ -4,6 +4,7 @@ var Test = function() {
|
||||
var Test = function Test() {};
|
||||
return Test;
|
||||
}();
|
||||
"use strict";
|
||||
arr.map(function(x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["script.js","script2.js"],"names":[],"mappings":";;IAAM,CAAC,CAAC,CAAC;MAAH,CAAC,CAAC,CAAC,aAAH,CAAC,CAAC,CAAC;SAAH,CAAC,CAAC,CAAC;;;ACAT,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAC;SAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAC,CAAC","file":"script3.js","sourcesContent":["class Test {\n\n}","arr.map(x => x * MULTIPLIER);"]}
|
||||
{"version":3,"sources":["script.js","script2.js"],"names":[],"mappings":";;IAAM,CAAC,CAAC,CAAC;MAAH,CAAC,CAAC,CAAC,aAAH,CAAC,CAAC,CAAC;SAAH,CAAC,CAAC,CAAC;;;;ACAT,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAC;SAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAC,CAAC","file":"script3.js","sourcesContent":["class Test {\n\n}","arr.map(x => x * MULTIPLIER);"]}
|
||||
|
||||
@@ -4,6 +4,7 @@ var Test = function() {
|
||||
var Test = function Test() {};
|
||||
return Test;
|
||||
}();
|
||||
"use strict";
|
||||
arr.map(function(x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var _slice = Array.prototype.slice;
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
};
|
||||
|
||||
var _extends = function (child, parent) {
|
||||
child.prototype = Object.create(parent.prototype, {
|
||||
constructor: {
|
||||
@@ -27,7 +34,17 @@ var Test = function(Foo) {
|
||||
|
||||
_extends(Test, Foo);
|
||||
|
||||
Object.defineProperties(Test.prototype, {
|
||||
_classProps(Test, {
|
||||
foo: {
|
||||
writable: true,
|
||||
|
||||
value: function() {
|
||||
Foo.foo.call(this);
|
||||
Foo.foo.call.apply(Foo.foo, [this].concat(_slice.call(arguments)));
|
||||
Foo.foo.call.apply(Foo.foo, [this, "test"].concat(_slice.call(arguments)));
|
||||
}
|
||||
}
|
||||
}, {
|
||||
test: {
|
||||
writable: true,
|
||||
|
||||
@@ -39,17 +56,5 @@ var Test = function(Foo) {
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperties(Test, {
|
||||
foo: {
|
||||
writable: true,
|
||||
|
||||
value: function() {
|
||||
Foo.foo.call(this);
|
||||
Foo.foo.call.apply(Foo.foo, [this].concat(_slice.call(arguments)));
|
||||
Foo.foo.call.apply(Foo.foo, [this, "test"].concat(_slice.call(arguments)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return Test;
|
||||
}(Foo);
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
};
|
||||
|
||||
var _extends = function (child, parent) {
|
||||
child.prototype = Object.create(parent.prototype, {
|
||||
constructor: {
|
||||
@@ -13,7 +18,6 @@ var _extends = function (child, parent) {
|
||||
child.__proto__ = parent;
|
||||
};
|
||||
|
||||
|
||||
var Test = function(Foo) {
|
||||
var Test = function Test() {
|
||||
Foo.prototype.test.whatever();
|
||||
@@ -22,7 +26,7 @@ var Test = function(Foo) {
|
||||
|
||||
_extends(Test, Foo);
|
||||
|
||||
Object.defineProperties(Test, {
|
||||
_classProps(Test, {
|
||||
test: {
|
||||
writable: true,
|
||||
|
||||
@@ -30,7 +34,7 @@ var Test = function(Foo) {
|
||||
return Foo.wow.call(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, null);
|
||||
|
||||
return Test;
|
||||
}(Foo);
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
};
|
||||
|
||||
var Test = function() {
|
||||
var Test = function Test() {};
|
||||
|
||||
Object.defineProperties(Test.prototype, {
|
||||
_classProps(Test, null, {
|
||||
test: {
|
||||
get: function() {
|
||||
return 5 + 5;
|
||||
@@ -16,4 +21,4 @@ var Test = function() {
|
||||
});
|
||||
|
||||
return Test;
|
||||
}();
|
||||
}();
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
};
|
||||
|
||||
var Test = function() {
|
||||
var Test = function Test() {};
|
||||
|
||||
Object.defineProperties(Test.prototype, {
|
||||
_classProps(Test, null, {
|
||||
test: {
|
||||
get: function() {
|
||||
return 5 + 5;
|
||||
@@ -12,4 +17,4 @@ var Test = function() {
|
||||
});
|
||||
|
||||
return Test;
|
||||
}();
|
||||
}();
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
};
|
||||
|
||||
var Test = function() {
|
||||
var Test = function Test() {};
|
||||
|
||||
Object.defineProperties(Test.prototype, {
|
||||
_classProps(Test, null, {
|
||||
test: {
|
||||
writable: true,
|
||||
|
||||
@@ -14,4 +19,4 @@ var Test = function() {
|
||||
});
|
||||
|
||||
return Test;
|
||||
}();
|
||||
}();
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
};
|
||||
|
||||
var Test = function() {
|
||||
var Test = function Test() {};
|
||||
|
||||
Object.defineProperties(Test.prototype, {
|
||||
_classProps(Test, null, {
|
||||
test: {
|
||||
set: function(val) {
|
||||
this._test = val;
|
||||
@@ -12,4 +17,4 @@ var Test = function() {
|
||||
});
|
||||
|
||||
return Test;
|
||||
}();
|
||||
}();
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
};
|
||||
|
||||
var A = function() {
|
||||
var A = function A() {};
|
||||
|
||||
Object.defineProperties(A, {
|
||||
_classProps(A, {
|
||||
a: {
|
||||
writable: true,
|
||||
value: function() {}
|
||||
@@ -13,7 +18,7 @@ var A = function() {
|
||||
get: function() {},
|
||||
set: function(b) {}
|
||||
}
|
||||
});
|
||||
}, null);
|
||||
|
||||
return A;
|
||||
}();
|
||||
}();
|
||||
|
||||
1
test/fixtures/transformation/destructuring/member-expression/actual.js
vendored
Normal file
1
test/fixtures/transformation/destructuring/member-expression/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[this.foo, this.bar] = [1, 2];
|
||||
4
test/fixtures/transformation/destructuring/member-expression/expected.js
vendored
Normal file
4
test/fixtures/transformation/destructuring/member-expression/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
var _ref = [1, 2];
|
||||
this.foo = _ref[0];
|
||||
this.bar = _ref[1];
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(["exports"], function (exports) {
|
||||
"use strict";
|
||||
|
||||
exports.default = 42;
|
||||
exports.default = {};
|
||||
exports.default = [];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(["exports", "foo"], function (exports, _foo) {
|
||||
"use strict";
|
||||
|
||||
(function(obj) {
|
||||
for (var i in obj) {
|
||||
exports[i] = obj[i];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(["exports"], function (exports) {
|
||||
"use strict";
|
||||
|
||||
exports.foo = foo;
|
||||
exports.foo = foo;
|
||||
exports.bar = bar;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(["exports"], function (exports) {
|
||||
"use strict";
|
||||
|
||||
exports.foo7 = foo7;
|
||||
var foo = 1;
|
||||
exports.foo = foo;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(["exports", "./evens"], function (exports, _evens) {
|
||||
"use strict";
|
||||
|
||||
exports.nextOdd = nextOdd;
|
||||
var isEven = _evens.isEven;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
define(["exports", "foo"], function (exports, _foo) {
|
||||
"use strict";
|
||||
var foo = _foo.default;
|
||||
var foo = _foo.default;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
"use strict";
|
||||
|
||||
define(["exports", "foo"], function (exports, _foo) {
|
||||
"use strict";
|
||||
var foo = _foo;
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(["exports", "foo"], function (exports, _foo) {
|
||||
"use strict";
|
||||
|
||||
var foo = _foo.default;
|
||||
var xyz = _foo.baz;
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(["exports", "foo"], function (exports, _foo) {
|
||||
"use strict";
|
||||
|
||||
var bar = _foo.bar;
|
||||
var bar = _foo.bar;
|
||||
var baz = _foo.baz;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
define(["exports", "foo", "foo-bar", "./directory/foo-bar"], function (exports, _foo, _fooBar, _directoryFooBar) {
|
||||
|
||||
"use strict";
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(["exports", "foo", "foo-bar", "./directory/foo-bar"], function (exports, _foo, _fooBar, _directoryFooBar) {
|
||||
"use strict";
|
||||
|
||||
var foo = _foo.default;
|
||||
var foo = _foo;
|
||||
var bar = _foo.bar;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports"], factory);
|
||||
@@ -7,6 +5,8 @@
|
||||
factory(exports);
|
||||
}
|
||||
})(function (exports) {
|
||||
"use strict";
|
||||
|
||||
exports.default = 42;
|
||||
exports.default = {};
|
||||
exports.default = [];
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports", "foo"], factory);
|
||||
@@ -7,6 +5,8 @@
|
||||
factory(exports, require("foo"));
|
||||
}
|
||||
})(function (exports, _foo) {
|
||||
"use strict";
|
||||
|
||||
(function(obj) {
|
||||
for (var i in obj) {
|
||||
exports[i] = obj[i];
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports"], factory);
|
||||
@@ -7,6 +5,8 @@
|
||||
factory(exports);
|
||||
}
|
||||
})(function (exports) {
|
||||
"use strict";
|
||||
|
||||
exports.foo = foo;
|
||||
exports.foo = foo;
|
||||
exports.bar = bar;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports"], factory);
|
||||
@@ -7,6 +5,8 @@
|
||||
factory(exports);
|
||||
}
|
||||
})(function (exports) {
|
||||
"use strict";
|
||||
|
||||
exports.foo7 = foo7;
|
||||
var foo = 1;
|
||||
exports.foo = foo;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports", "./evens"], factory);
|
||||
@@ -7,6 +5,8 @@
|
||||
factory(exports, require("./evens"));
|
||||
}
|
||||
})(function (exports, _evens) {
|
||||
"use strict";
|
||||
|
||||
exports.nextOdd = nextOdd;
|
||||
var isEven = _evens.isEven;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports", "foo"], factory);
|
||||
@@ -7,6 +5,8 @@
|
||||
factory(exports, require("foo"));
|
||||
}
|
||||
})(function (exports, _foo) {
|
||||
"use strict";
|
||||
|
||||
var foo = _foo.default;
|
||||
var foo = _foo.default;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports", "foo"], factory);
|
||||
@@ -7,5 +5,6 @@
|
||||
factory(exports, require("foo"));
|
||||
}
|
||||
})(function (exports, _foo) {
|
||||
"use strict";
|
||||
var foo = _foo;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports", "foo"], factory);
|
||||
@@ -7,6 +5,7 @@
|
||||
factory(exports, require("foo"));
|
||||
}
|
||||
})(function (exports, _foo) {
|
||||
"use strict";
|
||||
var foo = _foo.default;
|
||||
var xyz = _foo.baz;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports", "foo"], factory);
|
||||
@@ -7,6 +5,7 @@
|
||||
factory(exports, require("foo"));
|
||||
}
|
||||
})(function (exports, _foo) {
|
||||
"use strict";
|
||||
var bar = _foo.bar;
|
||||
var bar = _foo.bar;
|
||||
var baz = _foo.baz;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports", "foo", "foo-bar", "./directory/foo-bar"], factory);
|
||||
@@ -7,5 +5,5 @@
|
||||
factory(exports, require("foo"), require("foo-bar"), require("./directory/foo-bar"));
|
||||
}
|
||||
})(function (exports, _foo, _fooBar, _directoryFooBar) {
|
||||
|
||||
"use strict";
|
||||
});
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports", "foo", "foo-bar", "./directory/foo-bar"], factory);
|
||||
@@ -7,6 +5,7 @@
|
||||
factory(exports, require("foo"), require("foo-bar"), require("./directory/foo-bar"));
|
||||
}
|
||||
})(function (exports, _foo, _fooBar, _directoryFooBar) {
|
||||
"use strict";
|
||||
var foo = _foo.default;
|
||||
var foo = _foo;
|
||||
var bar = _foo.bar;
|
||||
|
||||
3
test/fixtures/transformation/rest-parameters/arrow-functions/actual.js
vendored
Normal file
3
test/fixtures/transformation/rest-parameters/arrow-functions/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var concat = (...arrs) => {
|
||||
|
||||
};
|
||||
5
test/fixtures/transformation/rest-parameters/arrow-functions/expected.js
vendored
Normal file
5
test/fixtures/transformation/rest-parameters/arrow-functions/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
var _slice = Array.prototype.slice;
|
||||
var concat = function () {
|
||||
var arrs = _slice.call(arguments);
|
||||
};
|
||||
@@ -1,9 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
};
|
||||
|
||||
var Test = function() {
|
||||
var Test = function Test() {};
|
||||
|
||||
Object.defineProperties(Test.prototype, {
|
||||
_classProps(Test, null, {
|
||||
bar: {
|
||||
get: function() {
|
||||
throw new Error("wow");
|
||||
@@ -15,4 +20,4 @@ var Test = function() {
|
||||
}();
|
||||
|
||||
var test = new Test();
|
||||
test.bar;
|
||||
test.bar;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"column": 11
|
||||
},
|
||||
"generated": {
|
||||
"line": 9,
|
||||
"line": 17,
|
||||
"column": 15
|
||||
}
|
||||
}]
|
||||
|
||||
Reference in New Issue
Block a user