Created
March 10, 2011 21:22
-
-
Save kriszyp/864958 to your computer and use it in GitHub Desktop.
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(function(require, exports){ | |
exports.foo = require("pckg/foo"); | |
alert("loaded another"); | |
}); |
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([], function(){ | |
return {a:3}; | |
}); |
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(["bar", "text!resource"], function(bar){ | |
return {b:bar.a}; | |
}); |
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(){ | |
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