I am trying to wrap some legacy js code in modules so that they can be loaded with RequireJS.
I have three jQuery plugins, let's call them a,b and c.
- Plugin a works with any version of jQuery
- Plugin b works with jQuery version 1.4.2
- Plugin c uses a and b, and works with any version of jQuery.
So anytime the plugin a is required, the jQuery that needs to be loaded is version 1.4.2. My require.config looks something like:
require.config({
paths:{
"jquery": "libs/jquery.1.9.1.min",
"jquery1-4-2" : "libs/jquery1.4.2.min"
});
And the plugins are defined as follows:
plugin a:
define(["jquery"], function($){ (...) });
plugin b:
define(["jquery1-4-2"], function($){ (...) });
plugin c:
define(["jquery", "a","b"], function($){ (...) });
How can I configure this scenario so that if any plugin needs a certain version of jQuery, and the others don't require a version, that and only that certain version is loaded?
Thanks in advance.