In ES6 each module is defined in its own file.
Does that mean that we will have to do multiple network calls for each javascript module if we go the es6 way?
Is there anyway to concatenate the module files essentially create one minified javascript file for the app in es6?
We can transpile the es6 code to es5 and concatenate the same.
But, without transpiling to es5, does it mean that to use modules, we won't be able to concatenate and minify all javascript files into one?
A module organizes a related set of JavaScript code. A module can contain variables and functions. A module is nothing more than a chunk of JavaScript code written in a file. By default, variables and functions of a module are not available for use.
The ES6 module standard has two parts: Declarative syntax (for importing and exporting) Programmatic loader API: to configure how modules are loaded and to conditionally load modules.
Although usage of ES6 is recommended since it should be advantageous when native support from browsers released. The reason being, you can import partials from one file while with CommonJS you have to require all of the file.
ES6 uses import and export. This means you only load the modules that you need, and the importing of the modules is asynchronous.
Bundling is the way to go.
Modern web applications consist of many, often small, modules. Loading those modules over HTTP impacts performance negatively, because a separate request is needed for each. Therefore, bundling multiple modules as a single file has a long tradition in the web development world. Current approaches are complex and error-prone and only work for JavaScript. Therefore, the W3C Technical Architecture Group is working on a new approach: Arbitrarily nested directories are archived as a single package file. Browsers access files in the package via a new kind of URL:
url-for-package SEPARATOR path-inside-package
Source: http://www.2ality.com/2013/11/es6-modules-browsers.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With