Skip to content

Instantly share code, notes, and snippets.

@caridy
Last active December 11, 2015 16:39
Show Gist options
  • Save caridy/4629575 to your computer and use it in GitHub Desktop.
Save caridy/4629575 to your computer and use it in GitHub Desktop.
This example demonstrate that YUI Loader on the server side will dynamically resolve dependencies, which means requirements do not need to be part of the meta set through `applyConfig`.
YUI.add('bar', function (Y, NAME) {
Y[NAME] = true;
console.log(NAME);
}, '', {requires: ['baz']});
YUI.add('baz', function (Y, NAME) {
Y[NAME] = true;
console.log(NAME);
}, '', {requires: ['foo']});
YUI.add('foo', function (Y, NAME) {
Y[NAME] = true;
console.log(NAME);
}, '', {requires: []});
var YUI = require('yui').YUI;
var Y = YUI({useSync: true});
Y.applyConfig({
groups: {
mojitOne: {
modules: {
foo: {
fullpath: __dirname + '/foo.js'
}
}
},
mojitTwo: {
modules: {
bar: {
fullpath: __dirname + '/bar.js'
},
baz: {
fullpath: __dirname + '/baz.js'
}
}
}
}
});
Y.use('bar');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment