Do not guess relative execution status for exported fns (#10417)
This commit is contained in:
parent
8027dca501
commit
610d6bdc62
14
packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/exported-fn/input.mjs
vendored
Normal file
14
packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/exported-fn/input.mjs
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import { foo } from "somewhere";
|
||||
|
||||
// foo might call "bar"
|
||||
foo();
|
||||
|
||||
a;
|
||||
|
||||
let a;
|
||||
|
||||
a;
|
||||
|
||||
export function bar() {
|
||||
return a;
|
||||
}
|
||||
10
packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/exported-fn/output.mjs
vendored
Normal file
10
packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/exported-fn/output.mjs
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
var a = babelHelpers.temporalUndefined;
|
||||
import { foo } from "somewhere"; // foo might call "bar"
|
||||
|
||||
foo();
|
||||
babelHelpers.tdz("a");
|
||||
a = void 0;
|
||||
a;
|
||||
export function bar() {
|
||||
return babelHelpers.temporalRef(a, "a");
|
||||
}
|
||||
6
packages/babel-plugin-transform-spread/test/fixtures/regression/10416/input.mjs
vendored
Normal file
6
packages/babel-plugin-transform-spread/test/fixtures/regression/10416/input.mjs
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
const E_ARR = [];
|
||||
|
||||
export default function () {
|
||||
const someVar = E_ARR;
|
||||
return [...someVar];
|
||||
}
|
||||
5
packages/babel-plugin-transform-spread/test/fixtures/regression/10416/output.mjs
vendored
Normal file
5
packages/babel-plugin-transform-spread/test/fixtures/regression/10416/output.mjs
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
const E_ARR = [];
|
||||
export default function () {
|
||||
const someVar = E_ARR;
|
||||
return babelHelpers.toConsumableArray(someVar);
|
||||
}
|
||||
@ -370,7 +370,12 @@ const executionOrderCheckedNodes = new WeakSet();
|
||||
export function _guessExecutionStatusRelativeToDifferentFunctions(
|
||||
target: NodePath,
|
||||
): RelativeExecutionStatus {
|
||||
if (!target.isFunctionDeclaration()) return "unknown";
|
||||
if (
|
||||
!target.isFunctionDeclaration() ||
|
||||
target.parentPath.isExportDeclaration()
|
||||
) {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
// so we're in a completely different function, if this is a function declaration
|
||||
// then we can be a bit smarter and handle cases where the function is either
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user