v2: Dynamic import returns object instead of function
See original GitHub issueIs this a bug report?
Yes
Did you try recovering your dependencies?
Yes
Which terms did you search for in User Guide?
Dynamic import
Environment
CRA v2.0.0
Steps to Reproduce / Reproducible Demo
After updating react-scripts to v2 I can see an error Unhandled Rejection (TypeError): throttle is not a function
.
In my code I do a dynamic import of lodash throttle. I created a codesandbox to reproduce what I do: https://codesandbox.io/s/4jp4j3l360 if you test with the deployed version you will notice in the console that an object is returned: https://csb-4jp4j3l360-jfpilaxokx.now.sh/
Expected Behavior vs Actual Behavior
The dynamic import should return a function isntead of an object.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Dynamic imports - The Modern JavaScript Tutorial
The import(module) expression loads the module and returns a promise that resolves into a module object that contains all its exports.
Read more >How to Dynamically Import ECMAScript Modules
You can import modules dynamically if you use import as a function — import(pathToModule) — a feature available starting ES2020.
Read more >How to Use Dynamic Imports in JavaScript - Alex Devero Blog
The idea of dynamic imports is to import some chunk of code only when you know you will need it. For example, to...
Read more >Dynamic Import - For Beginner - YouTube
Static imports is the standard way to import a file at the top of your js module using standard import syntax. import {...
Read more >Dynamic Imports: Am I missing something? - Stack Overflow
To try and have this heavy import loaded in a separate bundle, I tried to instead import these modules using a dynamic import....
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 Free
Top 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
Yes, see https://medium.com/webpack/webpack-4-import-and-commonjs-d619d626b655. We should document this as breaking behavior and provide migration instructions.
We will add this to the breaking migration instructions.