const babel = require("@babel/core@7.12.0");
// babel config
const config = {
sourceType: "module",
parserOpts: { errorRecovery: true }
};
// input
const input = `
function foo() {}
function foo() {}
`;
var out = babel.transformSync(input, config).code;
console.log(out);