Workaround bad #__PURE__ annotation placement on IIFEs (#6999)
Based on a fix suggested by @kzc
This commit is contained in:
parent
2958548c2c
commit
82357d79a7
@ -68,6 +68,8 @@ export default function(path: NodePath, file: Object, helpers: Object) {
|
|||||||
wrapAwait: helpers.wrapAwait,
|
wrapAwait: helpers.wrapAwait,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isIIFE = path.parentPath.isCallExpression({ callee: path.node });
|
||||||
|
|
||||||
path.node.async = false;
|
path.node.async = false;
|
||||||
path.node.generator = true;
|
path.node.generator = true;
|
||||||
|
|
||||||
@ -79,7 +81,7 @@ export default function(path: NodePath, file: Object, helpers: Object) {
|
|||||||
path.parentPath.isObjectProperty() ||
|
path.parentPath.isObjectProperty() ||
|
||||||
path.parentPath.isClassProperty();
|
path.parentPath.isClassProperty();
|
||||||
|
|
||||||
if (!isProperty) {
|
if (!isProperty && !isIIFE) {
|
||||||
annotateAsPure(
|
annotateAsPure(
|
||||||
path.isDeclaration() ? path.get("declarations.0.init") : path,
|
path.isDeclaration() ? path.get("declarations.0.init") : path,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
(async function() { await 'ok' })();
|
||||||
|
(async () => { await 'ok' })();
|
||||||
|
async function notIIFE() { await 'ok' }
|
||||||
|
notIIFE();
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
let notIIFE =
|
||||||
|
/*#__PURE__*/
|
||||||
|
(() => {
|
||||||
|
var _ref3 = babelHelpers.asyncToGenerator(function* () {
|
||||||
|
yield 'ok';
|
||||||
|
});
|
||||||
|
|
||||||
|
return function notIIFE() {
|
||||||
|
return _ref3.apply(this, arguments);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
babelHelpers.asyncToGenerator(function* () {
|
||||||
|
yield 'ok';
|
||||||
|
})();
|
||||||
|
babelHelpers.asyncToGenerator(function* () {
|
||||||
|
yield 'ok';
|
||||||
|
})();
|
||||||
|
notIIFE();
|
||||||
@ -1,6 +1,5 @@
|
|||||||
var _coroutine = require("bluebird").coroutine;
|
var _coroutine = require("bluebird").coroutine;
|
||||||
|
|
||||||
/*#__PURE__*/
|
|
||||||
_coroutine(function* () {
|
_coroutine(function* () {
|
||||||
yield foo();
|
yield foo();
|
||||||
})();
|
})();
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/*#__PURE__*/
|
|
||||||
babelHelpers.asyncToGenerator(function* () {
|
babelHelpers.asyncToGenerator(function* () {
|
||||||
var _iteratorNormalCompletion = true;
|
var _iteratorNormalCompletion = true;
|
||||||
var _didIteratorError = false;
|
var _didIteratorError = false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user