Update umdjs.

This commit is contained in:
Rico Sta. Cruz 2014-06-21 10:54:08 +08:00
parent d1525399a1
commit 02e806e4ed
1 changed files with 45 additions and 0 deletions

45
umdjs.md Normal file
View File

@ -0,0 +1,45 @@
---
title: Universal JS module loader
layout: default
---
### Basic (with dependency)
~~~ js
;(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('jquery'));
} else {
root.YourModule = factory(root.jQuery);
}
}(this, function (jquery) {
return {};
}));
~~~
### Basic (no dependency)
~~~ js
;(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.YourModule = factory();
}
}(this, function () {
return {};
}));
~~~
### Reference
* https://github.com/umdjs/umd