-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[babel 8] Use
NodePath#hub
as part of the paths cache key (#15759)
- Loading branch information
1 parent
b23b0eb
commit 65a6bca
Showing
12 changed files
with
121 additions
and
23 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
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,10 +1,48 @@ | ||
import assert from "assert"; | ||
import { transformSync } from "@babel/core"; | ||
import { Hub } from "../lib/index.js"; | ||
|
||
const itBabel8 = process.env.BABEL_8_BREAKING ? it : it.skip; | ||
|
||
describe("hub", function () { | ||
it("default buildError should return TypeError", function () { | ||
const hub = new Hub(); | ||
const msg = "test_msg"; | ||
assert.deepEqual(hub.buildError(null, msg), new TypeError(msg)); | ||
expect(hub.buildError(null, msg)).toEqual(new TypeError(msg)); | ||
}); | ||
|
||
itBabel8("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(); | ||
}); | ||
}); |
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