[FEATURE] Support dynamic import
See original GitHub issueSupport dynamic import :
https://developers.google.com/web/updates/2017/11/dynamic-import
module.js :
export const foo = _ => {
console.log('foo');
}
main.js :
const main = async _ => {
const m = await import('module.js');
m.foo();
(await import('module.js')).foo();
}
main();
Should display :
foo
foo
The thing is about supporting ‘export’ and ‘import’ keywords.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:21
- Comments:30 (7 by maintainers)
Top Results From Across the Web
Advanced Features: Dynamic Import - Next.js
Dynamically import JavaScript modules and React Components and split your code into manageable chunks.
Read more >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 >[Feature] Support dynamic imports via plugins #700 - GitHub
My suggestion to support dynamic imports with only a little extra API surface would be to instead yield the generation of an intermediary ......
Read more >Dynamic import() - V8 JavaScript engine
Dynamic import () introduces a new function-like form of import that caters to those use cases. import(moduleSpecifier) returns a promise for the ...
Read more >What are Dynamic Imports and how to use them? - Initialyze
Dynamic imports or Code Splitting is the practice of breaking up your JavaScript modules into smaller bundles and loading them dynamically ...
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 FreeTop 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
Top GitHub Comments
This is fully supported as of the 20210505 version
Most of JS developers now use Rollup instead of Closure Compiler.
Rollup does a great job in handling await import instructions and moving all your imports at the same level on the disk.
As a result, code splitting leads to faster load times.
File size matters, but code splitting really is on another level. The benefits are impressive.
In addition, Rollup understands ESNext and respects property names, which leads to fewer bugs.
As of July 2019, I would recommend Rollup over Closure Compiler.