Add support for commonjs.

This commit is contained in:
Artem Kozlov 2016-07-25 20:27:53 +02:00
parent edd2464a88
commit 9ef153ca53
2 changed files with 20 additions and 11 deletions

View File

@ -10,6 +10,7 @@
"globals": {
"OpenSeadragon": true,
"define": false
"define": false,
"module": false
}
}

View File

@ -685,19 +685,10 @@
* @param {OpenSeadragon.Options} options - Viewer options.
* @returns {OpenSeadragon.Viewer}
*/
window.OpenSeadragon = window.OpenSeadragon || function( options ){
function OpenSeadragon( options ){
return new OpenSeadragon.Viewer( options );
};
if (typeof define === 'function' && define.amd) {
define(function () {
return (window.OpenSeadragon);
});
}
(function( $ ){
@ -2596,3 +2587,20 @@ if (typeof define === 'function' && define.amd) {
}
}(OpenSeadragon));
// Universal Module Definition, supports CommonJS, AMD and simple script tag
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// expose as amd module
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// expose as commonjs module
module.exports = factory();
} else {
// expose as window.OpenSeadragon
root.OpenSeadragon = factory();
}
}(this, function () {
return OpenSeadragon;
}));