-
-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support non-ES modules #104
Support non-ES modules #104
Conversation
Codecov Report
@@ Coverage Diff @@
## master #104 +/- ##
==========================================
- Coverage 90.5% 90.45% -0.05%
==========================================
Files 15 15
Lines 200 199 -1
Branches 54 54
==========================================
- Hits 181 180 -1
Misses 17 17
Partials 2 2
Continue to review full report at Codecov.
|
/* eslint-disable no-underscore-dangle */ | ||
const resolveModuleDefault = module => | ||
module.__esModule ? module.default : module | ||
const resolveModuleDefault = module => module.default || module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the real problem - .default
for non ES module, or not .default
for ES module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the real problem - .default for non ES module, or not .default for ES module?
.default
for non ES module.
The problem is inconsistency between dynamic imports of webpack 4 vs. babel-plugin-dynamic-import-node. This is a known issue and currently there are 2 workarounds. Both of them are described here: airbnb/babel-plugin-dynamic-import-node#47.
This PR replaces one of these workarounds (deleted code) with the other one (added code). As a result, loadable-components
will have better support for webpack 4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React-loadable and universal-component are both looking for _esModule
Async and Imported component are looking only for .default
@neoziro - it's your turn.
@sergeysolovev thanks for the fix. I think non ES modules exposing a |
@neoziro thank you for the great lib! |
To fix #103
HOC
loadable
can be used for any modules that webpack can import. I’ve tested it on my project and it works fine for both ES modules and modules containing markdown text.