Skip to content
This repository has been archived by the owner on Jan 12, 2018. It is now read-only.

Define as an AMD and CommonJS module #90

Open
paglias opened this issue Apr 17, 2013 · 0 comments
Open

Define as an AMD and CommonJS module #90

paglias opened this issue Apr 17, 2013 · 0 comments

Comments

@paglias
Copy link

paglias commented Apr 17, 2013

Making Serenade define itself as an AMD or CommonJS module would be very useful and really easy to implement.

It can be achieved by wrapping the code this way:

(function (root, factory) {
  if (typeof define === 'function' && define.amd) {

    // AMD
    define(['exports'], factory);
  } else if (typeof exports !== 'undefined') {

    // CommonJS
    var target;
    if(typeof module !== undefined){
      target = module.exports;
    }else{
      target = exports;
    }

    factory(target);
  } else {

    // Browser global
    root.Serenade = factory({})
  }
}(this, function (Serenade) {

  // Code goes here

  return Serenade;

}));
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant