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.

Add support for dynamic import()

See original GitHub issue

Update: @shubheksha will be working on this. Please coordinate with her on specific parts you want to help with.

Now that it’s stage 3 we can add it. We should also add relevant documentation (add a “Code Splitting” section to User Guide).

Since we use Webpack 1.x for now, I think we need https://github.com/airbnb/babel-plugin-dynamic-import-webpack but I’m not entirely sure.

TODO items here:

  • Figure out which Babel plugin implements current version of https://github.com/tc39/proposal-dynamic-import and compiles down to require.ensure.
  • Add said Babel plugin to babel-preset-react-app.
  • Figure out what should happen in the test environment. Probably need to add some sort of a fallback that turns it into Promise.resolve(require(moduleName)).
  • Add documentation about using code splitting.
  • Ship it!

Let us know if you want to help. I won’t have time to work on this.

Please leave a comment below if you want to work on this. If somebody is already working on it, please offer to collaborate with them if you like. Don’t try to “be there first” if somebody is already working on some part of this. Please collaborate in this issue and split responsibilities.

I’m excited about finally having a way to code split JS code without Webpack-specific syntax! And when we switch to Webpack 2, we’ll change to a different plugin (or maybe won’t need it at all?)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:17
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
karlhorkycommented, Dec 16, 2016

webpack 2 has its first release candidate!

https://medium.com/webpack/webpack-2-2-the-release-candidate-2e614d05d75f#.o50xf63bo

I guess the final stable release will come soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript modules: dynamic import() - CanIUse
"Can I use" provides up-to-date browser support tables for support of front-end web ... Loading JavaScript modules dynamically using the import() syntax.
Read more >
How to Dynamically Import ECMAScript Modules
How to use import(pathToModule) to dynamically import ECMAScript ... one which exports export const func = () => {} and is being imported....
Read more >
Dynamic imports - The Modern JavaScript Tutorial
Export and import statements that we covered in previous chapters are called “static”. The syntax is very simple and strict.
Read more >
Advanced Features: Dynamic Import - Next.js
Dynamically import JavaScript modules and React Components and split your code ... Next.js supports lazy loading external libraries with import() and React ...
Read more >
add support for TypeScript 2.4+ dynamic import expression
add support for TypeScript 2.4+ dynamic import expression · 1. open a ts file · 2. use the new dynamic import support by...
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