The UMD pattern typically attempts to offer compatibility with the most popular script loaders of the day (e.g RequireJS amongst others). In many cases it uses AMD as a base, with special-casing added to handle CommonJS compatibility.
- amdWeb.js - Defines a module that works with AMD and browser globals. If you also want to export a global even when AMD is in play (useful if you are loading other scripts that still expect that global), use amdWebGlobal.js.
- returnExports.js - Defines a module that works in Node, AMD and browser globals. If you also want to export a global even when AMD is in play (useful if you are loading other scripts that still expect that global), use returnExportsGlobal.js.
- commonjsStrict.js - Defines a module that works with more CommonJS runtimes, and for modules that will have a circular dependency. If you also want to export a global even when AMD is in play (useful if you are loading other scripts that still expect that global), use commonjsStrictGlobal.js
- jqueryPlugin.js - Defines a jQuery plugin that works with AMD and browser globals.
- jqueryPluginCommonjs.js - Defines a jQuery plugin that works with AMD and browser globals, but also in a CommonJS environment. Use this version if you are running jQuery (or the jquip or jquery-untouched projects) in a CommonJS environment that can load jQuery appropriately.
These are useful for using AMD style while still making modules that can be used in Node and installed via npm without extra dependencies to set up the full AMD API.
- nodeAdapter.js - Best for when using AMD style but want it to work in Node without a helper library that sets up AMD.
- commonjsAdapter.js - Similar to nodeAdapter.js, but compatible with more CommonJS runtimes, and if you want to define a circular dependency.
- noConflict. Although with AMD loaders and build tools, it should be possible to get version specific bindings, maybe show a version that has a noConflict option.
- Variation with attaching some functionality to a $ impersonator. Although, it is tempting to say for that case, ask for 'jquery' as a dependency, and if the developer wants to use something different than the actual 'jquery', map that file to the 'jquery' name. That is one of the strengths of module names, they can be mapped to different implementations.
- Usage examples
- Further justifications for usage
- Gotchas/custom-tweaks we're aware of, but would rather not apply to the default UMD boilerplate
Earlier UMD variations were also of influence, ranging from Kit-Cambridge's UMD, through to patterns discussed by Addy Osmani, Thomas Davis and Ryan Florence and most recently the UMD patterns proposed by James Burke.