extender icon indicating copy to clipboard operation
extender copied to clipboard

Resulting code is not from Babel

Open Klustre opened this issue 1 year ago • 3 comments

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 https://github.com/fusepilot/babel-preset-extendscript/issues/15

Possible solution: https://github.com/evanw/esbuild/issues/1010#issuecomment-803865232

Klustre avatar Dec 20 '22 10:12 Klustre