Add helpers: false option to babel-plugin-transform-runtime (#3603)

This commit is contained in:
Sebastian McKenzie
2016-07-27 15:36:58 +01:00
committed by Henry Zhu
parent 0ff1f089bb
commit 8d14f9f4d0
10 changed files with 31 additions and 5 deletions

View File

@@ -11,11 +11,13 @@ export default function ({ types: t }) {
return {
pre(file) {
file.set("helperGenerator", function (name) {
if (HELPER_BLACKLIST.indexOf(name) < 0) {
return file.addImport(`${RUNTIME_MODULE_NAME}/helpers/${name}`, "default", name);
}
});
if (this.opts.helpers !== false) {
file.set("helperGenerator", function (name) {
if (HELPER_BLACKLIST.indexOf(name) < 0) {
return file.addImport(`${RUNTIME_MODULE_NAME}/helpers/${name}`, "default", name);
}
});
}
this.setDynamic("regeneratorIdentifier", function () {
return file.addImport(`${RUNTIME_MODULE_NAME}/regenerator`, "default", "regeneratorRuntime");

View File

@@ -0,0 +1,3 @@
{
"plugins": ["transform-runtime", "transform-regenerator"]
}

View File

@@ -0,0 +1,3 @@
{
"plugins": ["transform-runtime", "transform-regenerator"]
}

View File

@@ -0,0 +1 @@
class Foo {}

View File

@@ -0,0 +1,5 @@
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
let Foo = function Foo() {
_classCallCheck(this, Foo);
};

View File

@@ -0,0 +1,3 @@
{
"plugins": [["transform-runtime", { "helpers": false }], "transform-es2015-classes"]
}

View File

@@ -0,0 +1,3 @@
{
"plugins": ["transform-runtime", "transform-regenerator"]
}

View File

@@ -0,0 +1,3 @@
{
"plugins": ["transform-runtime", "transform-regenerator"]
}

View File

@@ -0,0 +1,3 @@
{
"plugins": ["transform-runtime", "transform-regenerator"]
}