public
Created

dependency injection

  • Download Gist
common.js
JavaScript
1 2 3 4
var foo = require("foo"),
bar = foo.bar;
 
exports.bar = bar;
commonjs_wrapper.js
JavaScript
1 2 3
define(function(require, exports, module) {
// your file contents here
});
relay_definition.js
JavaScript
1 2
require.setCrossDomain("http://example.com/relay.html",
"http://cdn.example.com/relay.html");
require_provide.js
JavaScript
1 2 3 4 5 6 7 8
// require two modules
require(["requiredModuleOne", "requiredModuleTwo"],
// run this callback when modules are loaded
function(moduleOne, moduletwo) {
// explicitly declare a dependency is available
provide(newModuleName, resultWhenRequired);
}
);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.