Developing a web project in JavaScript ES6, I currently use Traceur to compile my modules from ES6 to ES5, thinking that in the future, when browser will support ES6, I would be able to skip that transpilation step.
In the end, because I don't want to download several js pieces at start up, I have a single file that contains all my modules converted into ES5, thanks to Traceur.
But to validate this choice, I was wondering if this could still be possible the day I would keep the source in ES6. If I simply concatenate them, there will be invalid imports and name conflicts.
It looks like it has not been designed for it and it would require a extra processing step to merge them correctly.
How are we suppose to handle ES6 single file project defined with several modules ?
This will be solved by bundling, as described here: http://www.2ality.com/2013/11/es6-modules-browsers.html in chapter 3. So this is possible and validate your approach, although I couldn't find an implementation of the corresponding compilation step on the web, but it should arise when people start using ES6 modules.
In the near future, there won't be anymore the need to build single file project thanks to HTTP/2
.
See: Why bundle optimizations are no longer a concern in HTTP/2
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