Last active
December 31, 2015 10:39
-
-
Save nuysoft/7974409 to your computer and use it in GitHub Desktop.
模块化 Modular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
/* global window */ | |
/* global define */ | |
/* global KISSY */ | |
/* | |
https://gist.github.com/nuysoft/7974409 | |
*/ | |
(function(factory) { | |
var expose = factory() | |
expose(factory, function() { | |
window.expose = expose | |
}) | |
}(function() { | |
// 模块化 Modular | |
function expose(factory, globals) { | |
if (typeof module === 'object' && module.exports) { | |
// CommonJS | |
module.exports = factory() | |
} else if (typeof define === "function" && define.amd) { | |
// AMD modules | |
define(factory) | |
} else if (typeof define === "function" && define.cmd) { | |
// CMD modules | |
define(factory) | |
} else if (typeof KISSY != 'undefined') { | |
// For KISSY 1.4 | |
KISSY.add(factory) | |
} else { | |
// Browser globals | |
if (globals) globals() | |
} | |
} | |
return expose | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
/* global window: true */ | |
/* global expose */ | |
(function(factory) { | |
expose(factory, function() { | |
// Browser globals | |
window.Hyde = factory() | |
}) | |
}(function() { | |
return { | |
// ... | |
} | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment