Esbuild: Breaks async template literal tags

Created on 8 Sep 2020  路  3Comments  路  Source: evanw/esbuild

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.

Most helpful comment

The fix was just released in version 0.6.33.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aelbore picture aelbore  路  3Comments

ojanvafai picture ojanvafai  路  3Comments

iamakulov picture iamakulov  路  4Comments

qnp picture qnp  路  4Comments

ayox picture ayox  路  4Comments