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

pure + console.log, how to avoid such syntax errors in third-party scripts? #2445

Closed
mirari opened this issue Aug 8, 2022 · 1 comment
Closed

Comments

@mirari
Copy link

mirari commented Aug 8, 2022

source:

function log(...args) {
  debug && console.log(...args);
}

yields:

function log(...args) {
  debug && ...args;
}

cause error:

Uncaught SyntaxError: Unexpected token '...'

I referenced #1879 but don't feel this is quite applicable to my usage scenario.
The code comes from a third-party tool script library under node_modules, and I can't modify its code directly.
debug is a local variable that is passed in when the tool is instantiated and cannot be defined by modifying environment variables.

I also tried drop but it didn't feel right because I only wanted to remove console.log and still needed to keep methods like console.error

@evanw
Copy link
Owner

evanw commented Aug 8, 2022

This is a bug in esbuild. Sorry about that. Will fix.

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