dynamic imports IE10 (preset-env core-js@3)
See original GitHub issueBug Report
Current Behavior
Dynamic imports are not working in IE10. The following error is shown in the console: “Unhandled promise rejectionTypeError: Target is not iterable”. @babel/preset-env is used with core-js@3. .browserslistrc
contains ie <= 10
.
Input Code https://github.com/jorenvanhee/dynamic-imports-with-preset-env-test
Run npm i && npm run build
and visit /index.html
in IE10.
import('./answer').then((module) => {
console.log(module.default);
});
Expected behavior/code
42
should be logged in the console.
Babel Configuration (.babelrc, package.json, cli command)
https://github.com/jorenvanhee/dynamic-imports-with-preset-env-test
Environment
- Babel version(s): 7.4.3
- Node/npm version: Node 10.15.1/npm 6.5
- How you are using Babel: loader
Additional context/Screenshots
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Target browser option in useBuiltIns/babel polyfill
I want to use 'useBuiltIns' option to load polyfills only for IE11 browser. [ '@babel/preset-env', { useBuiltIns: 'entry', debug: ...
Read more >@babel/plugin-proposal-dynamic-import - Package Manager
Fast, reliable, and secure dependency management.
Read more >babel/plugin-syntax-dynamic-import
Working with Webpack and @babel/preset-env. Currently, @babel/preset-env is unaware that using import() with Webpack relies on Promise internally.
Read more >Browser Compatibility of JavaScript modules: dynamic import()
JavaScript modules: dynamic import() shows a browser compatibility score of 88. This is a collective score out of 100 to represent overall ...
Read more >@babel/plugin-syntax-dynamic-import: Versions | Openbase
7.7.4 · babel-runtime-corejs2 , babel-runtime-corejs3 , babel-runtime · babel-preset-env · babel-parser · babel-preset-env-standalone · babel-plugin-transform- ...
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
Wrote a small plugin to add
array.iterator
polyfill automatically:Repo: babel-plugin-dynamic-import-polyfill.
Example
In
Out
Installation
Usage
.babelrc
@jorenvanhee adding an entry with ‘core-js/modules/es.array.iterator’ in your webpack config should workaround the issue: