question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

remove dynamic import statements

See original GitHub issue

Thanks @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:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
raphaelschwingercommented, Mar 20, 2021

@simov thank you 😃

0reactions
simovcommented, Mar 20, 2021

I did a few tests on my own, fixed in #232

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found