RequireJS and dependencies of 3rd party libraries eg. Backbone dependent on Underscore and jQuery -
i understand backbone dependent on underscore, jquery , maybe json2. possible specify when module dependent on backbone, include dependencies of that? or whats way around this?
requirejs makes easy dependencies can declare when define
module. libraries don't support amd (underscore , backbone being 2 primary examples) use of shim
configuration required.
here example config:
require.config({ baseurl: 'scripts/', paths: { 'backbone': 'lib/backbone', 'jquery': 'lib/jquery', 'underscore': 'lib/underscore' }, shim: { 'backbone': { deps: ['underscore', 'jquery'], exports: 'backbone' } } });
now if require backbone dependency in 1 of modules underscore
, jquery
available.
a lot of is covered in documentation.
Comments
Post a Comment