Skip to content

Commit

Permalink
Don't let Babel incorrectly clone the input AST (#481)
Browse files Browse the repository at this point in the history
Fixes test failures in #478.
  • Loading branch information
benjamn authored Jul 22, 2021
1 parent cfbd19b commit 34dca95
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ exports.transform = function transform(node, options) {
var result = require("@babel/core").transformFromAstSync(node, null, {
presets: [require("regenerator-preset")],
code: false,
ast: true
ast: true,
// The deep-clone utility that Babel uses (based on V8's Serialization API
// https://nodejs.org/api/v8.html#v8_serialization_api in Node.js) removes
// the prototypes from the cloned node.loc.lines objects that Recast uses
// internally, leading to _blockHoist test failures in tests.transform.js.
// Also, unless cloning is somehow truly necessary, it should be faster to
// skip this step.
cloneInputAst: false
});

node = result.ast;
Expand Down

0 comments on commit 34dca95

Please sign in to comment.