The future of bundling JavaScript modules
This blog post examines how the bundling of modules is affected by two future developments: HTTP/2 and native modules. Why we bundle modules Bundling modules means combining several files with modules into a single file. That is done for three reasons: Fewer files need to be retrieved in order to load all modules. Compressing the bundled file is slightly more efficient than compressing separate files. During bundling, unused exports can be removed, potentially resulting in significant space savings. JavaScript modules With ECMAScript 6, JavaScript finally got built-in modules (I’m calling them JavaScript modules for the remainder of this blog post). However, that feature is currently in a strange position: On one hand, ES6 fully standardized their syntax and much of their semantics. They have become a popular format for writing modules and their static structure enables the automatic omission of unused exports (also known as “tree-shaking” in the JavaScript world). On the other hand, ...