You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { a, b } from "./foo";
const c = a() ? undefined : b?.();
A bisect shows that this is related to the change in #7956.
The optional chaining is relevant, as without it in the Repl correct output is produced (without optimisation that would potentially simplify the code further).
🤔 Expected Behavior
Code is bundled correctly, the right hand side of the ternary should be wrapped in parens: const c = (0, a)() ? undefined : (0, b)?.();
😯 Current Behavior
The bundler outputs:
const c = (0, a)() ? undefined : 0, b?.();
Code on right hand side of ternary is not wrapped, which changes the behaviour.
This manifests itself initially at build time as a Terser parsing error "Missing initializer in const declaration", because it the resulting JS tries to re-initialise b.
As per above, without the optional chaining in the Parcel repl the output is const c = (0, a)() ? undefined : (0, b)();
🐛 bug report
Code like this produces incorrect output:
A bisect shows that this is related to the change in #7956.
The optional chaining is relevant, as without it in the Repl correct output is produced (without optimisation that would potentially simplify the code further).
🤔 Expected Behavior
Code is bundled correctly, the right hand side of the ternary should be wrapped in parens:
const c = (0, a)() ? undefined : (0, b)?.();
😯 Current Behavior
The bundler outputs:
const c = (0, a)() ? undefined : 0, b?.();
Code on right hand side of ternary is not wrapped, which changes the behaviour.
This manifests itself initially at build time as a Terser parsing error "Missing initializer in const declaration", because it the resulting JS tries to re-initialise
b
.As per above, without the optional chaining in the Parcel repl the output is
const c = (0, a)() ? undefined : (0, b)();
💻 Code Sample
Repro in repl
The text was updated successfully, but these errors were encountered: