Skip to content

Instantly share code, notes, and snippets.

@hojberg
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hojberg/fc856dc2c6d8dbab75b8 to your computer and use it in GitHub Desktop.
Save hojberg/fc856dc2c6d8dbab75b8 to your computer and use it in GitHub Desktop.
YUI to ES6 to YUI
YUI.add('models:my_model', function (Y, NAME, __imports__, __exports__) {
"use strict";
var MyOtherModel = __imports__['models/my_other_model']['default'];
var MyModel = Y.Base.create('models:myModel',
MyOtherModel
[],
{
// .. some implementation
},
{
ATTRS: {
name: {}
}
});
__exports['default'] = MyModel;
return __exports__;
},
'@VERSION@',
{
es: true,
requires: [
'base'
'models/my_other_model'
]
});
import 'base';
import MyOtherModel from 'models/my_other_model';
var MyModel = Y.Base.create('models:myModel',
MyOtherModel
[],
{
// .. some implementation
},
{
ATTRS: {
name: {}
}
});
export default MyModel;
YUI.add('models:my_model', function (Y) {
var MyModel = Y.Base.create('models:myModel',
Y.MyOtherModel
[],
{
// .. some implementation
},
{
ATTRS: {
name: {}
}
});
Y.MyModel = MyModel;
},
'0.0.1',
{
requires: [
'base'
'models:my_other_model'
]
});
YUI().require('models/my_model', function (Y, imports) {
var MyModel = imports['models/my_model'].default;
var myModel = new MyModel();
// ....
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment