Skip to content

Instantly share code, notes, and snippets.

@kriszyp
Created March 10, 2011 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kriszyp/864958 to your computer and use it in GitHub Desktop.
Save kriszyp/864958 to your computer and use it in GitHub Desktop.
define(function(require, exports){
exports.foo = require("pckg/foo");
alert("loaded another");
});
define([], function(){
return {a:3};
});
define(["bar", "text!resource"], function(bar){
return {b:bar.a};
});
(function(){
var bar = (function(){ // each module factory executed, export assigned to var
return {a:3};
})();
var text = {};
text._resource = "contents of file";
var pckg = {};// nested paths -> nested namespace/sub-objects
pckg.foo = (function(bar){
return {b:bar.a};
})(bar, text._resource);
var another = {};
(function(exports){
exports.foo = pckg.foo;
alert("loaded another");
})(another);
// still is an AMD module if loader present
if(typeof define != "undefined"){
define("another", another);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment