To answer your first question: Yes . You can definitely use ES6 modules and still load them asynchronously, but you should use the require() function at any point where you need the code, instead of putting the import at the top of the module, as usual.
Also remember, if you use export default and use babel 6, you will have to call the module using Module.default (Babel 5 considers Module itself as the default export as short, but the new behavior is more direct. More details here
There seem to be 3 potential ingredients:
- entry points
- lumps
- Download async
You can set separate entry points and just include the resulting assemblies separately in your html. But you can also use asynchronous loading based on other things (for example, scrolling to a certain point, the presence of certain classes / identifiers).
There is a short guide to them at the bottom of Pete Hunt on how to do this , which is much easier to understand than the official webpack documentation.
Jonathan Smemer also did a great job in two parts of his Advanced Webpack series.
Damon
source share