I have some code that I want to require:
define(function(require)
{
return stuff {
my_func: function()
{
return 1;
}
};
});
I try to require it inside a registerSuite.
registerSuite(function()
{
var navigation = require('path/to/navigation.js');
'my test': function()
{
return navigation.my_func();
}
});
This gives me an error of "my_func()" is not found in navigation. I had to convert the "include" code into a class and instantiate an object to get it to work. Is there a reason the require-way isn't working?
When loading an AMD module, the AMD require
function expects a module identifier, not a file path, so you would use:
var navigation = require('something/navigation');
where 'something' is the package containing your module, and the module name doesn't end with '.js'. You can also use a relative identifier, like
var navigation = require('../navigation');