Skip to content

Instantly share code, notes, and snippets.

@Alex-xd
Created January 17, 2017 13:33
Show Gist options
  • Save Alex-xd/b8aa1143755f628545a25bdd0079018b to your computer and use it in GitHub Desktop.
Save Alex-xd/b8aa1143755f628545a25bdd0079018b to your computer and use it in GitHub Desktop.
A javscript template for writting a different modular specification library. 兼容各种模块化,优雅退化的模块化组件开发模板。
;(function (factory) {
var registeredInModuleLoader = false;
if (typeof define === 'function' && define.amd) {
define(factory); // AMD,requireJS
registeredInModuleLoader = true;
}
if (typeof exports === 'object') {
module.exports = factory(); // CMD Node,webpack,bowserfy,seaJS
registeredInModuleLoader = true;
}
if (!registeredInModuleLoader) {
var old = window.namespace; // your namespace name
var api = window.namespace = factory();
api.noConflict = function () {
window.namespace = old;
return api;
};
}
}(function () {
// your code
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment