I have a script.js included in the website of my customer. This customer uses requirejs but he append script.js at the end of the body without explicitly using requirejs to load it.
In script.js i have libraries that are amd compatible and other not. The problem is that requirejs automatically load library which are amd. And i can't access them in my own library which is not amd compatible.
Do you have any idea ?
Thanks
RequireJs has the ability to "shim" configuration. In your requirejs configuration call, use the following (from the requirejs page). Backbone in this case is not a requirejs module and used as an example.
requirejs.config({
shim: {
'backbone': {
//These script dependencies should be loaded before loading
//backbone.js
deps: ['underscore', 'jquery'],
//Once loaded, use the global 'Backbone' as the
//module value.
exports: 'Backbone'
}
})
You can then use Backbone just like any other module:
define(['backbone'], function (Backbone) {
return Backbone.Model.extend({});
});