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.

v2: Dynamic import returns object instead of function

See original GitHub issue

Is 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:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Timercommented, Sep 26, 2018

Yes, see https://medium.com/webpack/webpack-4-import-and-commonjs-d619d626b655. We should document this as breaking behavior and provide migration instructions.

1reaction
Timercommented, Sep 26, 2018

We will add this to the breaking migration instructions.

Read more comments on GitHub >

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

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