From de43660243a6aa6d2d3cf6836c40620ff2136c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Wed, 16 Jun 2021 18:09:56 -0400 Subject: [PATCH] fix: remove traverse trap on NODE_ENV == "test" --- packages/babel-traverse/src/context.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/packages/babel-traverse/src/context.ts b/packages/babel-traverse/src/context.ts index 874df2958028..e74d051cd4b1 100644 --- a/packages/babel-traverse/src/context.ts +++ b/packages/babel-traverse/src/context.ts @@ -2,8 +2,6 @@ import NodePath from "./path"; import * as t from "@babel/types"; import type Scope from "./scope"; -const testing = process.env.NODE_ENV === "test"; - export default class TraversalContext { constructor(scope, opts, state, parentPath) { this.parentPath = parentPath; @@ -18,7 +16,6 @@ export default class TraversalContext { declare opts; queue: Array | null = null; priorityQueue: Array | null = null; - declare trap?: boolean; /** * This method does a simple check to determine whether or not we really need to attempt @@ -57,10 +54,6 @@ export default class TraversalContext { } maybeQueue(path, notPriority?: boolean) { - if (this.trap) { - throw new Error("Infinite cycle detected"); - } - if (this.queue) { if (notPriority) { this.queue.push(path); @@ -120,10 +113,6 @@ export default class TraversalContext { // this path no longer belongs to the tree if (path.key === null) continue; - if (testing && queue.length >= 10_000) { - this.trap = true; - } - // ensure we don't visit the same node twice const { node } = path; if (visited.has(node)) continue;