better blacklist tests and expose register cache - closes #344
This commit is contained in:
parent
ceb32816d7
commit
c8cf7ff286
@ -250,6 +250,10 @@ require("6to5/register")({
|
||||
|
||||
// This will remove the currently hooked extensions of .es6 and .js so you'll
|
||||
// have to add them back if you want them to be used again.
|
||||
extensions: [".js", ".es6"]
|
||||
extensions: [".js", ".es6"],
|
||||
|
||||
// Enables `roadrunner` cache that will save to a `.roadrunner.json` file in your cwd
|
||||
// Do not check this into git as it's user-specific
|
||||
cache: true
|
||||
});
|
||||
```
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
require("./polyfill");
|
||||
|
||||
var sourceMapSupport = require("source-map-support");
|
||||
var roadrunner = require("roadrunner");
|
||||
var util = require("./util");
|
||||
var to5 = require("./index");
|
||||
var fs = require("fs");
|
||||
@ -38,15 +39,22 @@ var blacklistTest = function (transformer, code) {
|
||||
};
|
||||
|
||||
blacklistTest("arrayComprehension", "var foo = [for (foo of bar) foo * foo];");
|
||||
//blacklistTest("generatorComprehension", "");
|
||||
blacklistTest("generatorComprehension", "var foo = (for (foo of bar) foo * foo)");
|
||||
blacklistTest("arrowFunctions", "var foo = x => x * x;");
|
||||
blacklistTest("classes", "class Foo {}");
|
||||
blacklistTest("computedPropertyNames", "var foo = { [foo]: bar };");
|
||||
//blacklistTest("constants", "const foo = 0;");
|
||||
blacklistTest("constants", function () {
|
||||
try {
|
||||
new Function("const foo = 'foo';\nfoo = 'wow';");
|
||||
} catch (err) {
|
||||
return; // constants are supported
|
||||
}
|
||||
throw new SyntaxError;
|
||||
});
|
||||
blacklistTest("defaultParamaters", "var foo = function (bar = 0) {};");
|
||||
blacklistTest("destructuring", "var { x, y } = { x: 0, y: 0 };");
|
||||
blacklistTest("forOf", "for (var foo of bar) {}");
|
||||
blacklistTest("generators", "function* foo() {}");
|
||||
blacklistTest("generators", "function* foo() {}\nasync function bar() {}"); // generators/async functions delegated to same transformer
|
||||
blacklistTest("letScoping", "let foo = 0;");
|
||||
blacklistTest("modules", 'import foo from "from";');
|
||||
blacklistTest("propertyMethodAssignment", "{ get foo() {} }");
|
||||
@ -130,6 +138,11 @@ module.exports = function (opts) {
|
||||
|
||||
if (opts.cache) cache = opts.cache;
|
||||
if (opts.cache === false) cache = null;
|
||||
if (opts.cache === true) {
|
||||
roadrunner.load();
|
||||
roadrunner.setup();
|
||||
cache = roadrunner.get("6to5");
|
||||
}
|
||||
|
||||
_.extend(transformOpts, opts);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user