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 * as t from "../../types";
|
||||
|
||||
var canHoist = function (node, file) {
|
||||
return node._blockHoist && !file.transformers.runtime.canTransform();
|
||||
}
|
||||
|
||||
var hoistVariablesVisitor = {
|
||||
enter(node, parent, scope, hoistDeclarators) {
|
||||
if (t.isFunction(node)) {
|
||||
@ -20,7 +24,7 @@ var hoistVariablesVisitor = {
|
||||
}
|
||||
|
||||
// ignore block hoisted nodes as these can be left in
|
||||
if (node._blockHoist) return;
|
||||
if (canHoist(node, scope.file)) return;
|
||||
|
||||
var nodes = [];
|
||||
|
||||
@ -55,7 +59,7 @@ var hoistFunctionsVisitor = {
|
||||
enter(node, parent, scope, handlerBody) {
|
||||
if (t.isFunction(node)) this.skip();
|
||||
|
||||
if (t.isFunctionDeclaration(node) || node._blockHoist) {
|
||||
if (t.isFunctionDeclaration(node) || canHoist(node, scope.file)) {
|
||||
handlerBody.push(node);
|
||||
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);
|
||||
|
||||
export function* generator() {
|
||||
yield 1;
|
||||
}
|
||||
|
||||
@ -1,14 +1,32 @@
|
||||
System.register(["babel-runtime/helpers/to-consumable-array"], function (_export) {
|
||||
var _toConsumableArray;
|
||||
System.register(["babel-runtime/helpers/to-consumable-array", "babel-runtime/regenerator"], function (_export) {
|
||||
var _toConsumableArray, _regeneratorRuntime, generator;
|
||||
|
||||
return {
|
||||
setters: [function (_babelRuntimeHelpersToConsumableArray) {
|
||||
_toConsumableArray = _babelRuntimeHelpersToConsumableArray["default"];
|
||||
}, function (_babelRuntimeRegenerator) {
|
||||
_regeneratorRuntime = _babelRuntimeRegenerator["default"];
|
||||
}],
|
||||
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);
|
||||
});
|
||||
|
||||
_export("generator", generator);
|
||||
|
||||
foo.apply(undefined, _toConsumableArray(bar));
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user