We are creating a structure that we intend to use in several projects. All projects will use require.js to manage modules and dependencies.
Ideally, I would like to use the r.js optimizer to compile the framework into a single file, which can be provided to applications that use it. This file will contain all the modules of the framework, so in my application I can write code like:
define(["framework/util/a", "framework/views/b"], function(A, B) {
var a = new A();
});
But there seem to be two problems with this approach.
- Depending on
framework/util/adoes not tell require.js what it needs to load framework.js, in which it will findutil/a - The optimization tool generates names for all modules included in
framework.js, such as define("util/a", function() { ... } );Even if require.js is loaded framework.js, there is nothing that tells it that a particular module util/ais a relative module to frameworkand as such is identified asframework/util/a
Am I missing something or is it better for structuring my infrastructure as a CommonJS package and use the require.js configuration parameter packages?
source
share