I have a module (dependencyA) that I want to call from two separate modules (modA & modB) while using RequireJS. In this case, modA is the main.js file. I have mentioned the path of the dependency in the path section of main.js:
paths: {
'dependencyA': 'test/dependencyA',
//other paths
}
I added this dependency in my define function (I am using define and not require in the main.js) - I removed references to other modules for this post:
define(['dependencyA'], function (dependencyA) {
I am able to use this dependency from the main.js file. If I wish to use this dependency from moduleB, should I add it over there in the define section or not? If I add it in the define section, my requireJS module code does not seem to be correct (my javascript code does not get called properly). I do not think the dependency code is incorrect since its being called from the main.js file fine.
This is what I tried in moduleB:
define(["require", './test/dependencyA'],
function(require, dependencyA) {
If I remove the reference to dependencyA from moduleB, I get the error stating that dependencyA is undefined.
The dependency module dependencyA is defined as follows (I did not pass in the name):
define(function() {
Any suggestions on fixing this will be greatly appreciated.