I'm trying to better understand requirejs and have a question on how define() works. I have a simple html page the loads requirejs via the following script tag.
<script data-main="scripts/main.js" src="scripts/require.js"></script>
main.js contains:
console.log("in main");
require.config({
baseUrl: 'scripts'
});
define('temp_module', ['module3'], function(t) {
console.log("ta: ", t);
return {
"sundry": t.input
}
});
module3.js contains:
define(function() {
return {
input: "output"
}
});
What I expected is the the define statement will define and cache a new module named 'temp_module' depending on what is returned from the callback function. The callback function takes in the return value of module3. At this point both temp_module and module3 are cached if needed later.
Clearly that is not how this is supposed to behave as I only get the "in main" output in the console and not the console.log from the callback function.
Can anyone correct my understanding on how this should work?
Thanks.