I have a simple CommonJS module published on NPM and Bower that basically just looks like this:
function Foo(){}
module.exports = new Foo();
now the easiest way to convert to AMD format would be just to publish a second version that was AMD compatible like so:
define(function (require, exports, module) {
function Foo(){}
module.exports = new Foo();
});
but I thought there was a way you can shim the CommonJS module using requirejs.config like so:
requirejs.config({
paths:{
'foo':'assets/vendor/foo'
},
shim:{
'foo' :{
exports: 'Foo'
}
}
});
but this doesn't seem to work. I figure that the shim tool does the wrapping that I did above for you, but I am not entirely sure.