gulp-umd-wrap
Wraps JavaScript and CoffeeScript sources in UMD.
Installation
npm i gulp-umd-wrap
Status
Supports JavaScript and CoffeeScript sources.
Usage
module.coffee
Module = : -> : -> : ->
gulpfile.coffee
gulp = require'gulp'concat = require'gulp-concat'umd = require'gulp-umd-wrap' = -> # For Browser and Web Worker environments global variable will be set on this: # window for Browser, self for Web Worker. # This option is not required. global = 'Module' # For each dependency require and global must be specified: # require: module name in AMD/CommonJS compatible environments; # global: module name in Browser and Web Worker environments. # This option is not required. dependencies = require: 'lodash'global: '_' require: 'jquery'global: '$' # Header for UMD expression. # This option is not required. header = """ ### # module.coffee 1.0.0 | github.com/module-author/module | LICENSE ### """ globaldependenciesheader gulptask 'build'-> gulpsrc'module.coffee' pipe umdumdOptions pipe concat'module-umd.coffee' pipe gulpdest'.'
module-umd.coffee
#### module.coffee 1.0.0 | github.com/module-author/module | LICENSE### __root__ = # The root object for Browser or Web Worker if typeof self is 'object' and self isnt null and selfself is self self # The root object for Server-side JavaScript Runtime else if typeof global is 'object' and global isnt null and globalglobal is global global else Function'return this' # Asynchronous Module Definition (AMD) if typeof define is 'function' and typeof defineamd is 'object' and defineamd isnt null define 'lodash''jquery' __root__.Module = factory__root___$ # Server-side JavaScript Runtime compatible with CommonJS Module Spec else if typeof module is 'object' and module isnt null and typeof moduleexports is 'object' and moduleexports isnt null module.exports = factory__root__require'lodash'require'jquery' # Browser, Web Worker and the rest else __root__.Module = factory__root___$ # No return value return Module = : -> : -> : ->