I have about 3 different errors that can occur while loading the same page. I get different errors when I refresh the same page: jquery ui loads before jquery, or underscore does not load in time to be a dependency. Is there a way to make sure the configuration modules wait until their depenedencies load before loading themselves? I am using the following:
main.js
require.config({
paths: {
jQuery: 'libs/jquery/jquery-wrapper',
Underscore: 'libs/underscore/underscore-wrapper',
Backbone: 'libs/backbone/backbone-wrapper',
}
});
require([
'src/app',
'order!libs/jquery/jquery-min',
'order!libs/jquery/jquery-ui-min',
'order!libs/jquery/jquery.ui.selectmenu',
'order!libs/underscore/underscore-min',
'order!libs/backbone/backbone-min',
], function (App) {
App.initialize();
});
I grab injected dependencies from the page.
app.js
define([
'jQuery',
'src/global'
], function ($) {
var initialize = function () {
var d = $('#dependencies').html();
require($.trim($('#dependencies').html().toString()).split(','), function () {
});
}
return {
initialize: initialize
};
});
I switched to Require 2.0 and employed a shim that is working for the most part.