Let's say I have a bundle common/lib
, where I define RequireJS modules for jQuery and AngularJS.
Now let's suppose I have the following config.js
:
require.config({
baseUrl: 'http://www.some-website.com/scripts/',
paths: {
'common/lib': 'bundles/common/lib',
},
shim: {
'main': ['common/lib']
}
});
Take a look at the configured dependency, main
should wait for common/lib
to load (which defines the angular
module).
Here is my main.js
:
define('main', ['angular'], function (angular)
{
// Use angular here
});
The main
module requires the angular
module, but the angular
module is in the common/lib
bundle, so I'm telling main
to wait for common/lib
so the module is defined.
However, this does not seem to work, main
does not wait for common/lib
, and therefore, tries to locate an undefined angular
module with no luck, raising an error.
So, my question is:
How can I configure dependencies for the main module?
I should note that I'm not using data-main
attribute on the script
tag for main.js
.
Instead, I'm loading it as a normal script after config.js
, and I then execute this line to load the main
module:
require(['main']);