Hi! First of all, thanks for this amazing tool!
There might be an issue with async template literals tags (such as https://github.com/porsager/postgres):
const result = await sql`select * from table`
is built as:
const result = (await sql)`select * from table`;
The parenthesis basically break the code and the whole thing just returns a Promise
. instead of the actual result.
I've tried v0.6.30 and v0.6.32. I'm using the Rollup plugin https://github.com/egoist/rollup-plugin-esbuild with TS target es2018
-- same happens for es2016
but with yield
instead of await
.
Edit
This works:
const result = await (sql`select * from table`)
builds as:
const result = await sql`select * from table`;
However, formatters such as Prettier will likely remove those parenthesis before esbuild.
Thanks for reporting this! It looks like the precedence of template literal tags is incorrect. I just fixed the bug and I will do a release later today.
@evanw Thank you so much!
The fix was just released in version 0.6.33.
Most helpful comment
The fix was just released in version 0.6.33.