A List of actively-supported, reusable, open-source, AMD-compliant modules in the wild. Let me know if you have another module to add to the list!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(['dojo/parser, wire/Deferred'], function (parser, Promise) { | |
var orig = parser.parse, | |
promise = new Promise(); | |
parser.parse = function (node) { | |
orig.apply(parser, arguments); | |
promise.resolve(); | |
}; | |
return promise; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wire({ | |
// this is a normal module | |
// it is loaded, created, and initialized asap | |
staticModule: { | |
create: { | |
module: 'my/static/module', | |
args: {} | |
}, | |
init: 'startMe' | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global.curl = { | |
baseUrl: baseUrl, | |
paths: { | |
'li/ubox': '../../../../../applications/universal-inbox/src/main/webapp/li/ubox', | |
'li/schema': '../../../../../applications/universal-inbox/src/main/webapp/li/schema', | |
'li/referenceData': '../../../../../applications/universal-inbox/src/main/webapp/li/referenceData', | |
'data': '../../test/webapp/data', | |
/* this is the interesting line: */ | |
'li/core/xhr': '../../test/webapp/mock/li/core/xhr-promise' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (myLib, define) { | |
//Set up myLib here. | |
myLib.add = function (a, b) { return a + b; }; | |
define(myLib); | |
}.call(this, | |
typeof exports == 'object' ? exports : {}, | |
typeof define == 'function' && define.amd ? | |
define : |
CSS AMD plugins
curl/plugin/link: https://github.com/unscriptable/curl/blob/master/src/curl/plugin/link.js
- the link! plugin is ultra-simple, but doesn't wait for the stylesheet to be applied
- should work with any AMD loader, including RequireJS
curl/plugin/css: https://github.com/unscriptable/curl/blob/master/src/curl/plugin/css.js
- loads and waits for CSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MyView.js when concatenated together using cram.js | |
// cram.js needs two new features to make this work: | |
// 1. an option to NOT normalize module ids | |
// 2. an option to more easily exclude modules from the build (wire plugins, for instance) | |
define('./myView/controller', { | |
_onClick: function (e) { | |
this.rootNode.classList.toggle(this.states.selected); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (define) { | |
define(['pkgA/modA', 'pkgB/mod2'], function (modA, mod2) { | |
// define and return module here | |
function myCtor () {} | |
myCtor.prototype = { | |
combine: function () { return modA.aMethod() + mod2.anotherMethod(); | |
}; | |
return myCtor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// google closure compiler turns this: | |
function indexOf (item /*, fromIndex */) { | |
return find(this, item, arguments[1] /* fromIndex */, true); | |
} | |
// into this (notice the new function argument): | |
function q(a,c){b(this,a,c,!0)} | |
/* | |
Q: Why is this bad? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
packages: { | |
pkgA: { | |
path: 'path/to/pkgA', | |
main: 'main/main-module-file', | |
lib: 'location/of/other/modules', | |
config: { | |
packages: { | |
// pkgC1.0 is declared at the top level | |
pkgC: { $ref: 'packages/pkgC1.0' }, |