Created
January 17, 2017 13:33
-
-
Save Alex-xd/b8aa1143755f628545a25bdd0079018b to your computer and use it in GitHub Desktop.
A javscript template for writting a different modular specification library. 兼容各种模块化,优雅退化的模块化组件开发模板。
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
;(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