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

Checking for existence of require in if throws warning #1153

Closed
k15a opened this issue Apr 14, 2021 · 2 comments · Fixed by #1155
Closed

Checking for existence of require in if throws warning #1153

k15a opened this issue Apr 14, 2021 · 2 comments · Fixed by #1155

Comments

@k15a
Copy link

k15a commented Apr 14, 2021

Sentry checks for require inside an if to throw an if no appName is provided and it can't require Electron. Unfortunately, esbuild thinks that this is a dynamic require and throws a warning.

Screen Shot 2021-04-14 at 14 40 35

Is it possible to not warn in case some code is just checking for the existence of require?

@evanw
Copy link
Owner

evanw commented Apr 14, 2021

Is it possible to not warn in case some code is just checking for the existence of require?

Well this code isn't checking for the existence of require. This code will crash if require is not defined. Checking for the existence of require would involve using typeof require instead.

I should probably just remove this warning since people keep giving me grief about it. The alternative is to silently generate potentially broken bundles. I'll change esbuild to do that instead.

@k15a
Copy link
Author

k15a commented Apr 15, 2021

would involve using typeof require instead

Ohh yes, my bad. I would still expect esbuild to not warn there. Thank you very much!

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

Successfully merging a pull request may close this issue.

2 participants