This was rather long journey, but I was finally able to make the ES6
modules branch work with the build's features as rich as the previous build:
https://github.com/aerogear/aerogear-js/pull/154
After some minor fixes and spring-cleaning we are ready to go, so please
test and comment now if you have any concerns. :-)
On Fri, Nov 7, 2014 at 3:00 PM, Lukáš Fryč <lukas.fryc(a)gmail.com> wrote:
Hey guys,
as you may know, for AeroGear.js 2.1 we are in the middle of refactoring
into ES6 module syntax, so finally we will be able to use following in ES6
based projects:
import Authorization from 'aerogear.authorization;
I've finished a prototype of how ES6 (JavaScript.tomorrow) module
transpilation to ES5 (JavaScript.today) could work., the code and sample
lives here:
https://github.com/aerogear/aerogear-js/pull/154
It basically takes ES6 classes and compiles them to AMD module syntax
(which is a browser-oriented module system, implemented e.g. in RequireJS
module loader).
These AMD modules can already be consumed by end-user who uses AMD in his
project:
require(['aerogear.authorization'], function( Authorization ) {
...
});
(Note that similarly we could compile to CommonJS module syntax, that
could be leveraged in Browserify projects today, but we agree with Luke to
do not dive into that atm).
We take it even further by allowing to leverage globally accessible API
AeroGear.Authorization without any module loader in your project. This way
you will be able to use AeroGear.js 1.3/2.0-like API as it is with no code
modifications.
AeroGear.Authorization
This is made to work by taking all the AMD modules, concatenating them and
wrapping them into minimal loader ("microlib") that exposes all the modules
on global AeroGear object.
Cheers,
~ Lukas