don't block hoist in system module formatter when runtime transformer is enabled - #1105
This commit is contained in:
parent
c14ffb8319
commit
f81e841283
@ -6,6 +6,10 @@ import each from "lodash/collection/each";
|
|||||||
import map from "lodash/collection/map";
|
import map from "lodash/collection/map";
|
||||||
import * as t from "../../types";
|
import * as t from "../../types";
|
||||||
|
|
||||||
|
var canHoist = function (node, file) {
|
||||||
|
return node._blockHoist && !file.transformers.runtime.canTransform();
|
||||||
|
}
|
||||||
|
|
||||||
var hoistVariablesVisitor = {
|
var hoistVariablesVisitor = {
|
||||||
enter(node, parent, scope, hoistDeclarators) {
|
enter(node, parent, scope, hoistDeclarators) {
|
||||||
if (t.isFunction(node)) {
|
if (t.isFunction(node)) {
|
||||||
@ -20,7 +24,7 @@ var hoistVariablesVisitor = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ignore block hoisted nodes as these can be left in
|
// ignore block hoisted nodes as these can be left in
|
||||||
if (node._blockHoist) return;
|
if (canHoist(node, scope.file)) return;
|
||||||
|
|
||||||
var nodes = [];
|
var nodes = [];
|
||||||
|
|
||||||
@ -55,7 +59,7 @@ var hoistFunctionsVisitor = {
|
|||||||
enter(node, parent, scope, handlerBody) {
|
enter(node, parent, scope, handlerBody) {
|
||||||
if (t.isFunction(node)) this.skip();
|
if (t.isFunction(node)) this.skip();
|
||||||
|
|
||||||
if (t.isFunctionDeclaration(node) || node._blockHoist) {
|
if (t.isFunctionDeclaration(node) || canHoist(node, scope.file)) {
|
||||||
handlerBody.push(node);
|
handlerBody.push(node);
|
||||||
this.remove();
|
this.remove();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
export function* generator() {
|
|
||||||
yield 1;
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
System.register([], function (_export) {
|
|
||||||
var generator;
|
|
||||||
|
|
||||||
_export("generator", generator);
|
|
||||||
|
|
||||||
return {
|
|
||||||
setters: [],
|
|
||||||
execute: function () {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
generator = regeneratorRuntime.mark(function generator() {
|
|
||||||
return regeneratorRuntime.wrap(function generator$(context$1$0) {
|
|
||||||
while (1) switch (context$1$0.prev = context$1$0.next) {
|
|
||||||
case 0:
|
|
||||||
context$1$0.next = 2;
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
case "end":
|
|
||||||
return context$1$0.stop();
|
|
||||||
}
|
|
||||||
}, generator, this);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
@ -1 +1,5 @@
|
|||||||
foo(...bar);
|
foo(...bar);
|
||||||
|
|
||||||
|
export function* generator() {
|
||||||
|
yield 1;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,13 +1,31 @@
|
|||||||
System.register(["babel-runtime/helpers/to-consumable-array"], function (_export) {
|
System.register(["babel-runtime/helpers/to-consumable-array", "babel-runtime/regenerator"], function (_export) {
|
||||||
var _toConsumableArray;
|
var _toConsumableArray, _regeneratorRuntime, generator;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setters: [function (_babelRuntimeHelpersToConsumableArray) {
|
setters: [function (_babelRuntimeHelpersToConsumableArray) {
|
||||||
_toConsumableArray = _babelRuntimeHelpersToConsumableArray["default"];
|
_toConsumableArray = _babelRuntimeHelpersToConsumableArray["default"];
|
||||||
|
}, function (_babelRuntimeRegenerator) {
|
||||||
|
_regeneratorRuntime = _babelRuntimeRegenerator["default"];
|
||||||
}],
|
}],
|
||||||
execute: function () {
|
execute: function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
generator = _regeneratorRuntime.mark(function generator() {
|
||||||
|
return _regeneratorRuntime.wrap(function generator$(context$1$0) {
|
||||||
|
while (1) switch (context$1$0.prev = context$1$0.next) {
|
||||||
|
case 0:
|
||||||
|
context$1$0.next = 2;
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
case "end":
|
||||||
|
return context$1$0.stop();
|
||||||
|
}
|
||||||
|
}, generator, this);
|
||||||
|
});
|
||||||
|
|
||||||
|
_export("generator", generator);
|
||||||
|
|
||||||
foo.apply(undefined, _toConsumableArray(bar));
|
foo.apply(undefined, _toConsumableArray(bar));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user