We are creating a framework that we intend to use across multiple projects. All projects will use require.js to manage modules and dependencies.
Ideally I'd like to use the r.js optimizer to compile the framework into a single file that can be provided to the applications that use it. That file will contain all modules of the framework such that in my application I can write code like:
define(["framework/util/a", "framework/views/b"], function(A, B) {
var a = new A();
// etc...
});
But it appears there are two problems with this approach.
- Depending on
framework/util/a
doesn't tell require.js that it needs to loadframework.js
in which it will findutil/a
- The optimize tool generates names for all modules included in
framework.js
such asdefine("util/a", function() { ... } );
Even if require.js loadedframework.js
there is nothing that tells it that the defined moduleutil/a
is a relative module toframework
and as such is identified asframework/util/a
Am I missing something or is a better approach to structure my framework as a CommonJS package and use require.js's packages
configuration option?