Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't let Babel incorrectly clone the input AST. #481

Merged
merged 1 commit into from Jul 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/visit.js
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