I have two require.js apps. The second uses the first one as a dependency. It looks like that:
in app1/main.js
requirejs.config( {
baseUrl : 'js', // baseUrl relative to app1 folder
paths: {
// paths used for app1
}
});
requirejs(['module'], function (module) {
return module;
});
This file needs to be completely "standalone" and has its own require config so it can load its module and libs.
Then, in app2/main.js
requirejs.config( {
baseUrl : 'js', // baseUrl relative to app2 folder
paths: {
'app1' : '../app1/main' // Using the other app
}
});
requirejs(['app1', 'module'], function (app1, module) {
console.log(app1, module); // The first one should be app1/module.js, the second app2/module.js
});
This second file need to have its config, but also needs to load app1/main.js as a dependency like it was a usual module.
but the two requirejs.config just get mixed and if I require a file in the first one it uses the baseUrl of the second, or other problems like that.
So:
- How can I turn a require.js app into a loadable module that keeps its own config?
- Is it possible to do this without building before? (I need to work on both at the same time and I'd prefer not to have to wait for builds each time I change something)
- I read about namespaces which maybe is a solution but didn't see anything about how to use them for these sort of cases - If I have to add them manually at the start of my files it's not a problem for me.