From 1a950be6a8fe3f46f00aa81b74c62ba66cc822ba Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Sat, 21 Jun 2014 10:58:36 +0800 Subject: [PATCH] Update umd.js. --- umdjs.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/umdjs.md b/umdjs.md index 1e4dfa937..ac1a03c0f 100644 --- a/umdjs.md +++ b/umdjs.md @@ -3,7 +3,7 @@ title: Universal JS module loader layout: default --- -### Basic (with dependency) +### [With dependency](https://github.com/umdjs/umd/blob/master/amdWebGlobal.js) ~~~ js ;(function (root, factory) { @@ -21,7 +21,7 @@ layout: default })); ~~~ -### Basic (no dependency) +### No dependencies ~~~ js ;(function (root, factory) { @@ -39,6 +39,23 @@ layout: default })); ~~~ +### [Supports circular references](https://github.com/umdjs/umd/blob/master/commonjsStrict.js) + +~~~ js +(function (root, factory) { + + if (typeof define === 'function' && define.amd) { + define(['exports', 'jquery'], factory); + } else if (typeof exports === 'object') { + factory(exports, require('jquery')); + } else { + factory((root.YourModule = {}), root.jQuery); + } + +}(this, function (exports, jQuery) { + exports.action = function () {}; +})); +~~~ ### Reference