Reputation: 591
I am working on existing application where we have couple of modules(Non AMD) from some third party. They use name space so for example we have below libraries.
Now I am trying to intergrate require js in my project. How do I configure these dependencies. I was looking at shim. But did not really understand it. Can any one give a bit clear explanation about that. Also is it same for using jquery and jquery plugin like scroll?
Upvotes: 2
Views: 178
Reputation: 11588
assuming your public html directory looks like this:
html
- index.html
js
- jquery.js
- main.js
- jquery.scroll.js
- dm.js
- require.js
Then in index.html you want:
<script data-main="js/main" src="js/require.js"></script>
in main.js:
require.config({
shim: {
'dm': {
exports: 'DM'
},
"jquery.scroll": ["jquery"]
}
});
require( [ 'jquery', 'jquery.scroll'], function( $ ) {
// use $ here
});
Upvotes: 2