Bug Report
Input Code
import { parse } from "@babel/parser";
import generator from "@babel/generator";
import t from "@babel/types";
const code1 = `
// hello!
a();
`;
const code2 = `
// hello
b();
`;
let ast1 = parse(code1).program;
let ast2 = parse(code2).program;
let ast = t.program([...ast1.body, ...ast2.body]);
console.log(generator.default(ast).code);
Expected behavior
// hello!
a();
// hello
b();
Current behavior
Environment
"@babel/generator": "7.12.15",
"@babel/parser": "7.12.15",
Possible Solution
Additional context
I was surprised that there are cases where comment exists twice (as leading and trailing), e.g.
if (1) {
a();
}
// /* */
else {
b();
}
. Looks like babel-generators "workaround" for this isn't quite right.
Distantly related to parcel-bundler/parcel#5787
Bug Report
Input Code
Expected behavior
Current behavior
Environment
Possible Solution
Additional context
I was surprised that there are cases where comment exists twice (as leading and trailing), e.g.
. Looks like babel-generators "workaround" for this isn't quite right.
Distantly related to parcel-bundler/parcel#5787