Skip to content

Commit 6a15d7a

Browse files
Ensure that requeueComputedKeyAndDecorators is available (#16695)
* Ensure that `requeueComputedKeyAndDecorators` is available * Try fixing cycle * import path/context first --------- Co-authored-by: Huáng Jùnliàng <[email protected]>
1 parent 9f7e29a commit 6a15d7a

4 files changed

Lines changed: 31 additions & 5 deletions

File tree

packages/babel-core/src/config/files/configuration.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ function* readConfigCode(
9090

9191
// @ts-expect-error todo(flow->ts)
9292
if (typeof options.then === "function") {
93-
// @ts-expect-error We use ?. in case options is a thenable
94-
// but not a promise
93+
// @ts-expect-error We use ?. in case options is a thenable but not a promise
9594
options.catch?.(() => {});
9695

9796
throw new ConfigError(

packages/babel-traverse/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./path/context.ts"; // We have some cycles, this ensures correct order to avoid TDZ
12
import * as visitors from "./visitors.ts";
23
import {
34
VISITOR_KEYS,

packages/babel-traverse/src/scope/lib/renamer.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { NodePath, Visitor } from "../../index.ts";
44
import { traverseNode } from "../../traverse-node.ts";
55
import { explode } from "../../visitors.ts";
66
import type { Identifier } from "@babel/types";
7+
import { requeueComputedKeyAndDecorators } from "../../path/context.ts";
78

89
const renameVisitor: Visitor<Renamer> = {
910
ReferencedIdentifier({ node }, state) {
@@ -21,7 +22,15 @@ const renameVisitor: Visitor<Renamer> = {
2122
) {
2223
path.skip();
2324
if (path.isMethod()) {
24-
path.requeueComputedKeyAndDecorators();
25+
if (
26+
!process.env.BABEL_8_BREAKING &&
27+
!path.requeueComputedKeyAndDecorators
28+
) {
29+
// See https://github.com/babel/babel/issues/16694
30+
requeueComputedKeyAndDecorators.call(path);
31+
} else {
32+
path.requeueComputedKeyAndDecorators();
33+
}
2534
}
2635
}
2736
},

packages/babel-traverse/src/visitors.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from "@babel/types";
1111
import type { ExplodedVisitor, NodePath, Visitor } from "./index.ts";
1212
import type { ExplVisitNode, VisitNodeFunction, VisitPhase } from "./types.ts";
13+
import { requeueComputedKeyAndDecorators } from "./path/context.ts";
1314

1415
type VIRTUAL_TYPES = keyof typeof virtualTypes;
1516
function isVirtualType(type: string): type is VIRTUAL_TYPES {
@@ -406,13 +407,29 @@ const _environmentVisitor: Visitor = {
406407

407408
path.skip();
408409
if (path.isMethod()) {
409-
path.requeueComputedKeyAndDecorators();
410+
if (
411+
!process.env.BABEL_8_BREAKING &&
412+
!path.requeueComputedKeyAndDecorators
413+
) {
414+
// See https://github.com/babel/babel/issues/16694
415+
requeueComputedKeyAndDecorators.call(path);
416+
} else {
417+
path.requeueComputedKeyAndDecorators();
418+
}
410419
}
411420
},
412421
Property(path) {
413422
if (path.isObjectProperty()) return;
414423
path.skip();
415-
path.requeueComputedKeyAndDecorators();
424+
if (
425+
!process.env.BABEL_8_BREAKING &&
426+
!path.requeueComputedKeyAndDecorators
427+
) {
428+
// See https://github.com/babel/babel/issues/16694
429+
requeueComputedKeyAndDecorators.call(path);
430+
} else {
431+
path.requeueComputedKeyAndDecorators();
432+
}
416433
},
417434
};
418435

0 commit comments

Comments
 (0)