I am in a project where we are in the process of developing a widget system. I will try not to go into too much detail about this, but in this system widgets must be able to specify its dependencies. We have accomplished this by allowing widgets to specify its 3rd party dependencies using RequireJS.
Widgets are used in in-house developed apps. These apps do not use RequireJS for their own dependencies, they merely include RequireJS for the sake of the widgets.
Now, let's say that I have a widget that wants to use the library X. X is a library that specifies an AMD dependency on jQuery (the AMD module jquery
). Now, jQuery is included in every in-house developed app (it's a core part of our apps), so this shouldn't be a problem. However, since jQuery is not loaded via RequireJS (it's loaded manually via a script tag before RequireJS is included), the AMD module is never registered, and library X fails to load because it can't find the jquery
module.
How do I make library X find the AMD module jquery
, even though jQuery is not loaded using RequireJS? I suspect using RequireJS shims (http://requirejs.org/docs/api.html#config-shim) in some way can resolve this, but I have not figured out how yet. Any help is greatly appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…