Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minify generates "let" statements in conditions without a block #1

Closed
rsms opened this issue Jan 23, 2020 · 2 comments
Closed

minify generates "let" statements in conditions without a block #1

rsms opened this issue Jan 23, 2020 · 2 comments

Comments

@rsms
Copy link

rsms commented Jan 23, 2020

Repro:

if (something) {
  let x = foo(something)
  // console.log(x)
}

Build with:

esbuild --minify --outfile=test.out.js test.js

Expected output:

if(something){let b=foo(something);}

Actual output:

if(something)let b=foo(something);

Running this in Chrome js console yields this error:

Uncaught SyntaxError: Lexical declaration cannot appear in a single-statement context

Alternatively, the “let” is reduced to nothing (since it's unused) in the expected case:

if(something)foo(something);
@evanw
Copy link
Owner

evanw commented Jan 23, 2020

Thanks for the report! Will fix.

@evanw evanw closed this as completed in 28dcbc4 Jan 26, 2020
@rsms
Copy link
Author

rsms commented Jan 28, 2020

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants