I use requirejs to load some libraries and dependencies.
When I just load jQuery, it works fine:
main.js
require.config({
shim: {
jquery: {
exports: '$'
}
},
paths: {
jquery: 'vendor/jquery'
}
});
require([
'vendor/jquery',
'app/init'
]);
application /init.js
define(
['jquery'],
function ($) {
$(document).ready(function () {
console.log('domready');
})
}
)
But when I try to add underline, in the network pane the file is loaded correctly, but in the console I get
Missed error: load timeout for modules: underscore
What's happening? I also tried waitSeconds: 200 parameters inside require.config without any success.
Below is the final (broken) code as a link:
main.js
require.config({
shim: {
jquery: {
exports: '$'
},
underscore: {
exports: '_'
}
},
paths: {
jquery: 'vendor/jquery',
underscore: 'vendor/underscore',
}
})
require([
'vendor/jquery',
'vendor/underscore',
'app/init'
])
application /init.js
define(
['jquery', 'underscore'],
function ($, _) {
$(document).ready(function () {
console.log('domready');
})
}
)
source
share