Babel compact mode is broken when used with dprint #16474
-
Hi. i want to let you know that the Babel compact mode is broken in some way, i used it in a file 1Mb large so i have no idea what broke exactly but the behaviour was different. This is the diff where i added babel compact mode and the code is now broken, somewhere in there there is a bug in the transformation. The bug is in none of the plugins but in the compact mode. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Thanks, I'll investigate |
Beta Was this translation helpful? Give feedback.
-
I tried this example, but it seems that |
Beta Was this translation helpful? Give feedback.
-
i think i found one of the issues: test('babel bug?', () => {
expect(
trans(dedent`
if (isPresent2) {
if (initial && animateConfig) {
runEffectAnimation(animateConfig, effect, shouldReduceMotion, ref, appearId,);
}
} else {
if (exit) {
runEffectAnimation(exit, effect, shouldReduceMotion, ref, appearId,).then(() => safeToRemove());
} else {
safeToRemove();
}
}
`),
).toMatchInlineSnapshot(`
"if (isPresent2) if (initial && animateConfig) runEffectAnimation(animateConfig, effect, shouldReduceMotion, ref, appearId,);
else {if (exit) runEffectAnimation(exit, effect, shouldReduceMotion, ref, appearId,).then(() => safeToRemove());
else safeToRemove();}
"
`)
}) Here the transformed code should be if (isPresent2) {
if (initial && animateConfig) {
runEffectAnimation(animateConfig, effect, shouldReduceMotion, ref, appearId,);
}
} else {
if (exit) {
runEffectAnimation(exit, effect, shouldReduceMotion, ref, appearId,).then(() => safeToRemove());
} else {
safeToRemove();
}
} Instead it's this thing, after prettier formatting: if (isPresent2)
if (initial && animateConfig)
runEffectAnimation(
animateConfig,
effect,
shouldReduceMotion,
ref,
appearId,
)
else {
if (exit)
runEffectAnimation(
exit,
effect,
shouldReduceMotion,
ref,
appearId,
).then(() => safeToRemove())
else safeToRemove()
}
``` |
Beta Was this translation helpful? Give feedback.
This is a
dprint
bug. In your test Babel generates this code:And then
dprint
removes the braces.