umd

UMD (Universal Module Definition) patterns for JavaScript modules that work everywhere.

  • 所有者: umdjs/umd
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

UMD (Universal Module Definition)

Build Status

This repository formalizes the design and implementation of the Universal Module Definition (UMD) API for JavaScript modules. These are modules which are capable of working everywhere, be it in the client, on the server or elsewhere.

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.

Variations

Regular Module

  • 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

jQuery Plugin

  • jqueryPlugin.js -
    Defines a jQuery plugin that works with AMD and browser globals.

AMD with simple Node/CommonJS adapter

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.

This approach does not allow the use of AMD loader plugins,
just basic JS module dependencies. It also does not support the
callback-style require that
is usable in AMD.

  • 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.

Tooling

Build tools

  • docpad-plugin-umd is a DocPad plugin for surrounding JavaScript code with UMD boilerplate
  • grunt-umd is a Grunt task for surrounding JavaScript code with UMD boilerplate
  • gulp-umd is a Gulp task for surrounding JavaScript code with UMD boilerplate
  • grunt-urequire is a Grunt wrapper for uRequire a conversion tool for universal JavaScript modules.
  • generator-umd is an Yeoman Generator that creates a single module project with UMD boilerplate

Testing

Resources

Todos

  • 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

Influences

The basic pattern for the UMD variations in this repository was derived from the approach @kriskowal used for the Q promise library.

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.

License

Copyright (c) the UMD contributors

Licensed under the MIT License.

主要指標

概覽
名稱與所有者umdjs/umd
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2011-10-21 14:08:25
推送於2024-11-26 23:55:09
最后一次提交2024-11-26 15:55:09
發布數1
最新版本名稱v1.0.0 (發布於 2015-11-14 16:57:26)
第一版名稱v1.0.0 (發布於 2015-11-14 16:57:26)
用户参与
星數7.4k
關注者數194
派生數429
提交數85
已啟用問題?
問題數59
打開的問題數24
拉請求數29
打開的拉請求數20
關閉的拉請求數33
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?