Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit 34dca95

Browse files
authored
Don't let Babel incorrectly clone the input AST (#481)
Fixes test failures in #478.
1 parent cfbd19b commit 34dca95

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/visit.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ exports.transform = function transform(node, options) {
1818
var result = require("@babel/core").transformFromAstSync(node, null, {
1919
presets: [require("regenerator-preset")],
2020
code: false,
21-
ast: true
21+
ast: true,
22+
// The deep-clone utility that Babel uses (based on V8's Serialization API
23+
// https://nodejs.org/api/v8.html#v8_serialization_api in Node.js) removes
24+
// the prototypes from the cloned node.loc.lines objects that Recast uses
25+
// internally, leading to _blockHoist test failures in tests.transform.js.
26+
// Also, unless cloning is somehow truly necessary, it should be faster to
27+
// skip this step.
28+
cloneInputAst: false
2229
});
2330

2431
node = result.ast;

0 commit comments

Comments
 (0)