Tuesday, August 20, 2013

I learned today that there is now a way to shim other libraries as if they were AMD modules in requirejs.

At work we were apparently wrapping a call to Underscore.js in an AMD module to make it AMD-friendly. Then we moved away from as much given that is no longer needed. This has the following example of prepping the shims in a .config file:

shim: {
   'libs/jquery': {
      exports: '$'
   },
   'libs/underscore': {
      exports: '_'
   },
   'libs/backbone': {
      deps: ['libs/underscore', 'libs/jquery'],
      exports: 'Backbone'
   }
}

 
 

THINK you may hand in the exports values to a define as you would routes to modules... have not yet tried it firsthand...

No comments:

Post a Comment