My problem is with having redundant RequireJS dependencies that point to the same JS library.
The referenced library is jQuery UI, it\'s referenced both
Looking at the jquery-ui.js
file you are trying to load, I see that it is a combination of a multiple functions that could be in separate files and that it calls define
only once. So it registers as a single module. This is important to know because if it had called define
for each of jquery-ui/mouse
, jquery-ui/draggable
, etc. then the solution would be different because then we'd be talking about a single jQuery UI file that contains multiple modules.
Ok, so this being established, what you can do is use a map
in your RequireJS configuration. I'm assuming you already have a proper paths
configuration that allows loading the jquery-ui.js
file as the jquery.ui
module. Add this map:
map: {
'*': {
'jquery-ui/mouse': 'jquery.ui',
'jquery-ui/draggable': 'jquery.ui',
// And so on for all different cases...
}
}
This says in all modules (*
) whenever jquery-ui/mouse
is requested, then load jquery.ui
instead, and so on for all the other modules that will be listed under *
.