You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wrap specified JavaScript documents in the Universal Module Definition (UMD) allowing them to run in AMD, Require.js, CommonJS/Node.js and Vanilla environments automatically
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
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(typeofmodule!=='undefined'&&module.exports)module.exports=definition();elseif(typeofdefine==='function'&&define.amd)define(definition);elseif(typeofprovide==='function')provide(name,definition());elsecontext[name]=definition();})('the-javascript-file-basename',this,function(){// your javascript content});
Install
Install this DocPad plugin by entering docpad install umd into your terminal.
Wrap specified JavaScript documents in the Universal Module Definition (UMD) allowing them to run in AMD, Require.js, CommonJS/Node.js and Vanilla environments automatically