remove dynamic import statements
See original GitHub issueThanks @simov and others for your great work!
Summary
Importing from paths generated at runtime breaks parcel, see (parcel-bundler/parcel#4031), or esbuild, see (evanw/esbuild#480). Building fails or throws a warning like this:
warning: This call to "require" will not be bundled because the argument is not a string literal (surround with a try/catch to silence this warning)
32 │ var handler = require(`./lib/handler/koa-${version}`)
This can lead to problems at runtime.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
How to unload dynamic imports in javascript? - Stack Overflow
I can think of only one possible (fairly) good solution. Just overwrite the module with empty one. Like, loading would be:
Read more >Remove warning about using dynamic imports #453 - GitHub
The dynamic import is passed through to the output code unchanged. I don't think it should be a warning though, as using dynamic...
Read more >Dynamic imports - The Modern JavaScript Tutorial
Export and import statements that we covered in previous chapters are called “static”. ... unused exports can be removed (“tree-shaken”).
Read more >import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are ...
Read more >Dynamically Importing Components with React.lazy
With React.lazy, you can dynamically import components at run time to reduce the ... Switch statements that cycle through IDs and render the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@simov thank you 😃
I did a few tests on my own, fixed in #232