The resulting Babel code is somehow transformed after the plugin ran.
I have been trying to figure out the problem but haven't found the solution yet. The relevant test ternary statement is const a = false ? false ? 1 : 2 : 3. After esbuild-plugin-babel's onLoad is called and the content is transformed, I log the results in the onLoad callback and get var a = false ? (false ? 1 : 2) : 3; for that line—which is good. I also double checked with babel.transform to make sure the extendscript preset works well.
But when I check the final esbuild output file, the brackets disappeared. I am somewhat aware that the plugins for esbuild aren't the last line of bundling process, so it probably modified the babel output and removed the brackets. I am not too familiar with what goes on in esbuild between calling the plugins and writing to output, but it would be helpful if you might know the answer.
See fusepilot/babel-preset-extendscript#15
Possible solution: evanw/esbuild#1010 (comment)
The resulting Babel code is somehow transformed after the plugin ran.
See fusepilot/babel-preset-extendscript#15
Possible solution: evanw/esbuild#1010 (comment)