I think the right way to do this is to create a configuration module ...
// config.js define(['module', 'path', 'crypto'], function(module, path, crypto) { return { path: path.dirname(module.uri) key: crypto.randomBytes(64) }; });
Then use it in other modules ...
// bar.js define(['config'], function (config) { var key = config.key; });
You can do it as hard as you like!
EDIT: you can pollute the global namespace for this special class ...
define(['module', 'path', 'crypto'], function(module, path, crypto) { window.config = { path: path.dirname(module.uri) key: crypto.randomBytes(64) }; });
Add it to the top level to call:
require(['config', 'main']);
Then you can use it without adding it to your definition:
Felix
source share