docpad-plugin-umd

Wrap specified JavaScript documents in the Universal Module Definition (UMD) allowing them to run in AMD, Require.js, CommonJS/Node.js, Ender and Vanilla environments automatically

npm install docpad-plugin-umd
1 downloads in the last week
10 downloads in the last month

Universal Module Definition (UMD) Plugin for DocPad

Build Status NPM version Flattr donate button PayPayl donate button

Wrap specified JavaScript documents in the Universal Module Definition (UMD) allowing them to run in AMD, Require.js, CommonJS/Node.js, Ender and Vanilla environments automatically

Install

docpad install umd

Usage

For the documents that you want to be wrapped inside UMD, specify umd: true inside your document's meta data header like so:

---
umd: true
---

// your javascript content

and it will be transformed into:

/*global define:false require:false */
(function (name, context, definition) {
    if (typeof module !== 'undefined' && module.exports) module.exports = definition();
    else if (typeof define === 'function' && define.amd) define(definition);
    else if (typeof provide === 'function') provide(name, definition());
    else context[name] = definition();
})('the-javascript-file-basename', this, function(){
    // your javascript content
});

History

You can discover the history inside the History.md file

Backers

You can discover the financial backers of this project inside the Backers.md file

License

Licensed under the incredibly permissive MIT License
Copyright © 2013+ Bevry Pty Ltd

npm loves you