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

Universal Module Definition (UMD) Plugin for DocPad

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

docpad install umd

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 (namecontextdefinition) {
    if (typeof module !== '' && 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 
});

You can discover the history inside the History.md file

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

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