[aerogear-dev] ES6 modules -> ES5 microlib in AeroGear.js 2.1

Lukáš Fryč lukas.fryc at gmail.com
Fri Nov 7 09:00:23 EST 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20141107/7663b849/attachment.html 


More information about the aerogear-dev mailing list