-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Remove warning about using dynamic imports #453
Comments
Personally I prefer the warning because in a large code base with many dynamic imports it's a good reminder that some of my code might not be as well compiled/codesplit. Then I can adjust the import() to use a ternary or branch so it can have a string instead of a template. This also helps searching the codebase. |
I'm not sure what to think about this. I see both sides. I agree that the warning is annoying, but it's also annoying to have the build silently succeed only for the resulting bundle to be broken without an explanation. A similar warning is also triggered for dynamic For example, many packages expect to be bundled with Webpack's file system emulation where they do expect the bundler to attempt to bundle dynamic imports. This warning will flag these cases. One possible argument could be that One solution that works today is to just call the API and filter the warnings yourself. I agree that's not great. |
Closing it, if someone has something to add, please reopen/create a new one. |
With the latest release, you can now configure the log level for this warning like this:
|
I have an isomorphic library which uses dynamic imports of This pattern of building isomorphic code is legitimate, as it is the "least bad" solution. So it should not cause a warning IMO. |
Hey @evanw, thanks for your excellent job building esbuild, I'd like to discuss one thing:
As mentioned in #56:
I don't think it should be a warning though, as using dynamic
import()
can be a totally valid use case when you need to load an ES module in the browser and you don't want the bundler to touch it at all.I believe, the bundlers should not discourage users from using the standards. I do understand that esbuild needs to know the user's intent, which might indeed be code splitting, so there should be a way to clearly communicate that intent, and it's probably fine to use string templates vs string literals, but once I communicated it I don't expect to see any warnings about it, WDYT?
The text was updated successfully, but these errors were encountered: