Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Use
NodePath#hub
as part of the paths cache key (#15725)"
This reverts commit abb5a7c.
- Loading branch information
1 parent
f02d365
commit c4a1979
Showing
11 changed files
with
22 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,10 @@ | ||
import { transformSync } from "@babel/core"; | ||
import assert from "assert"; | ||
import { Hub } from "../lib/index.js"; | ||
|
||
describe("hub", function () { | ||
it("default buildError should return TypeError", function () { | ||
const hub = new Hub(); | ||
const msg = "test_msg"; | ||
expect(hub.buildError(null, msg)).toEqual(new TypeError(msg)); | ||
}); | ||
|
||
it("should be preserved across nested traversals", function () { | ||
let origHub; | ||
let innerHub = {}; | ||
let exprHub; | ||
function plugin({ types: t, traverse }) { | ||
return { | ||
visitor: { | ||
Identifier(path) { | ||
if (path.node.name !== "foo") return; | ||
origHub = path.hub; | ||
|
||
const mem = t.memberExpression( | ||
t.identifier("property"), | ||
t.identifier("access"), | ||
); | ||
traverse(mem, { | ||
noScope: true, | ||
Identifier(path) { | ||
if (path.node.name === "property") innerHub = path.hub; | ||
}, | ||
}); | ||
const [p2] = path.insertAfter(mem); | ||
|
||
exprHub = p2.get("expression").hub; | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
transformSync("foo;", { configFile: false, plugins: [plugin] }); | ||
|
||
expect(origHub).toBeInstanceOf(Object); | ||
expect(exprHub).toBe(origHub); | ||
expect(innerHub).toBeUndefined(); | ||
assert.deepEqual(hub.buildError(null, msg), new TypeError(msg)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters