umd-3.0.3/000077500000000000000000000000001325244643700123145ustar00rootroot00000000000000umd-3.0.3/.gitignore000066400000000000000000000001761325244643700143100ustar00rootroot00000000000000lib-cov *.seed *.log *.csv *.dat *.out *.pid *.gz pids logs results npm-debug.log node_modules /template.min.js /index.js umd-3.0.3/.travis.yml000066400000000000000000000000531325244643700144230ustar00rootroot00000000000000language: node_js node_js: - "6" - "8" umd-3.0.3/HISTORY.md000066400000000000000000000027331325244643700140040ustar00rootroot000000000000003.0.1 / 2015-04-25 ================== - Document and test casing/sanitization behavior (thanks @bendrucker) 3.0.0 / 2015-02-04 ================== - remove dependency on ruglify (thanks to @zertosh) - add `this` as an additional fallback when looking for a global (thanks to @winterbe) - use `options` rather than `true` / `false` for whether to use CommonJS (with fallback for backwards compatibility). - support `$` and `_` in module names (thanks to @fitnr) **(BREAKING CHANGE)** - uglify as a pre-publish step - removing a dependency - brfs as a pre-publish step - allowing this module to be used from the browser. - remove support for streaming **(BREAKING CHANGE)** 2.1.0 / 2014-04-02 ================== - Check for definition of `module` as well as `exports` for CommonJS (fixes some custom RequireJS loaders) - Pass empty array to define for AMD 2.0.0 / 2013-12-29 ================== - Use module name as a namespace for globals if it contains `.` 1.3.1 / 2013-08-25 ================== - Update uglify-js 1.3.0 / 2013-08-01 ================== - Remove SES and Montage bootstrap - Add MIT LICENSE - Handle web workers global - Update uglify-js to fix npm warning 1.2.1 / 2013-06-07 ================== - Fix CLI 1.2.0 / 2013-06-07 ================== - Add CLI 1.1.1 / 2013-04-15 ================== - Update through 1.1.0 / 2013-03-31 ================== - Make Cammel Case less suprising/forcefull 1.0.0 / 2013-03-16 ================== - Initial Release umd-3.0.3/LICENSE000066400000000000000000000020641325244643700133230ustar00rootroot00000000000000Copyright (c) 2013 Forbes Lindesay Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.umd-3.0.3/README.md000066400000000000000000000042261325244643700135770ustar00rootroot00000000000000# umd Universal Module Definition for use in automated build systems - simple synchronous wrapping of a string - `return` style module support - CommonJS support - prevents internal UMDs from conflicting [![Build Status](https://img.shields.io/travis/ForbesLindesay/umd/master.svg)](https://travis-ci.org/ForbesLindesay/umd) [![Dependency Status](https://img.shields.io/david/ForbesLindesay/umd.svg)](https://david-dm.org/ForbesLindesay/umd) [![NPM version](https://img.shields.io/npm/v/umd.svg)](https://www.npmjs.com/package/umd) ## Source Format In order for the UMD wrapper to work the source code for your module should `return` the export, e.g. ```javascript function method() { //code } method.helper = function () { //code } return method; ``` For examples, see the examples directory. The CommonJS module format is also supported by passing true as the second argument to methods. ## API options: - `commonJS` (default: `false`) - If commonJS is `true` then it will accept CommonJS source instead of source code which `return`s the module. ### umd(name, source, [options]) The `name` should the the name of the module. Use a string like name, all lower case with hyphens instead of spaces. If `source` should be a string, that is wrapped in umd and returned as a string. ### umd.prelude(module, [options]) return the text which will be inserted before a module. ### umd.postlude(module, [options]) return the text which will be inserted after a module. ## Command Line ``` Usage: umd [options] Pipe Usage: umd [options] < source > destination Options: -h --help Display usage information -c --commonJS Use CommonJS module format ``` You can easilly pipe unix commands together like: ```js cat my-module.js | umd my-module | uglify-js > my-module.umd.min.js ``` ## Name Casing and Characters The `name` passed to `umd` will be converted to camel case (`my-library` becomes `myLibrary`) and may only contain: * alphanumeric characters * $ * _ The name may not begin with a number. Invalid characters will be stripped. ## License MIT umd-3.0.3/UMD.png000066400000000000000000000512531325244643700134550ustar00rootroot00000000000000PNG  IHDR&wsRGBgAMA a pHYsodtEXtSoftwarePaint.NET v3.5.100rRIDATx^ Te  o""$ *)ZYYq5TVTjT^#z+eQ1-qg}ywf̙3ϙ93~>{ΙpΏL !Ҁ Zh! *B!A@ iE-B!A(yVA\)u!BZ %U"KN!:uJ&|C!!iUn !:Yn$!Bjt洟5s7=az:b !R|Ivܬ9Ŕ,3E]>!BjAv//K zG]bbB! e5 m{%jȈVQoRprMT ?E8:P ҏlJP!ubu^ȹT/a׮]}*b?Ήڪ& B!*Zgt[ ѣԠQ uxX$ K!7MNE 7~'jȰ}ᥭM[]Mk[2. wعsgu GVF꒔*B!9 ZPZ=Q'co?'tOc;Aݷ[aT(Վ%B|ڍZP8On\uN~vۛ݇}+bT$Q%BQIu{AGWܬu?E #a7~Q;S?VxQ$kkZ$h7h:E OMH Z'hж7WZO@)BH Ԡ3P|~ra: &d%BBXLwy^x5Th$ &yAZx>"!D)t#OR'Xנk?P-Ad[[po|g:3Fy#<}7}[% -=б0O9Y |aᆲj{DZhDTl%abA6uecb&Jegn/dqp+ٿ).'mׁ,5!!V=毪:/#ό;O]u5ǏWVH&@۩G8\ ({g&̨#<ӷgvne^MzǗxa`@qGzf<ӯg6iQB:?+a=7/A "ƞkFӢ~:2~qu"8I/[dЧuIPJ2GB]y3=k[t,w3%&e}L JO 4:ʐBH?e-&aR.d[.wLǎ}(j]x\C3N˔<|i&{^yݲ| %=3;LnË<=s4+屎!QD@QhזwmFjm˶sG|L(˳%FnPq8lQb(A^==sq@Q==s(#tYBiЉUiW3zK7_ů-)RImvG8d %0v?^ىC~&AdŞyh(Ay' F >mH!90!4}UvSHWR}]hS;z[gfZ|Om &#Ȗ\Fzn}wt|gz$?^` !7zƐVki tqq;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(SDB!R|G$B <%jAgɎ"!BHlnQB!/j!T7B!)QB!8=B!d?"!BHIrF qeB) [options]') console.log('') console.log('Pipe Usage: umd [options] < source > destination') console.log('') console.log('Options:') console.log('') console.log(' -h --help Display usage information') console.log(' -c --commonJS Use CommonJS module format') console.log('') if (!help) process.exit(1) } else { var source = args[1] ? read(args[1]) : process.stdin var dest = args[2] ? write(args[2]) : process.stdout var prelude = umd.prelude(args[0], {commonJS: commonJS}) var postlude = umd.postlude(args[0], {commonJS: commonJS}) dest.write(prelude) source.on('end', function () { dest.write(postlude + '\n') }).pipe(dest, {end: false}) } umd-3.0.3/examples/000077500000000000000000000000001325244643700141325ustar00rootroot00000000000000umd-3.0.3/examples/build.js000066400000000000000000000015231325244643700155700ustar00rootroot00000000000000var umd = require('../'); var fs = require('fs'); var join = require('path').join; fs.createReadStream(join(__dirname, 'cjs', 'index.js')) .pipe(umd('common-js-module', true)) .pipe(fs.createWriteStream(join(__dirname, 'cjs', 'bundle.js'))) .on('close', end); fs.createReadStream(join(__dirname, 'raw', 'index.js')) .pipe(umd('common-js-module', false)) .pipe(fs.createWriteStream(join(__dirname, 'raw', 'bundle.js'))) .on('close', end); fs.createReadStream(join(__dirname, 'constructor', 'index.js')) .pipe(umd('Common-Js-Module', false)) .pipe(fs.createWriteStream(join(__dirname, 'constructor', 'bundle.js'))) .on('close', end); var remaining = 2; function end() { if (0 !== --remaining) return; console.log(require('./cjs/bundle')); console.log(require('./raw/bundle')); console.log(require('./constructor/bundle')); }umd-3.0.3/examples/cjs/000077500000000000000000000000001325244643700147115ustar00rootroot00000000000000umd-3.0.3/examples/cjs/index.js000066400000000000000000000000451325244643700163550ustar00rootroot00000000000000module.exports = "common JS example";umd-3.0.3/examples/constructor/000077500000000000000000000000001325244643700165175ustar00rootroot00000000000000umd-3.0.3/examples/constructor/index.js000066400000000000000000000000351325244643700201620ustar00rootroot00000000000000return "Constructor example";umd-3.0.3/examples/raw/000077500000000000000000000000001325244643700147235ustar00rootroot00000000000000umd-3.0.3/examples/raw/index.js000066400000000000000000000000251325244643700163650ustar00rootroot00000000000000return "Raw example";umd-3.0.3/package.json000066400000000000000000000012701325244643700146020ustar00rootroot00000000000000{ "name": "umd", "version": "3.0.3", "description": "Universal Module Definition for use in automated build systems", "bin": "./bin/cli.js", "dependencies": {}, "devDependencies": { "brfs": "^1.3.0", "linify": "^1.0.1", "mocha": "*", "uglify-js": "^3.3.15" }, "scripts": { "build": "uglifyjs template.js > template.min.js && brfs source.js > index.js", "test": "npm run build && mocha -R spec", "prepublish": "npm run build && linify transform bin" }, "files": [ "index.js", "bin/cli.js" ], "repository": { "type": "git", "url": "https://github.com/ForbesLindesay/umd.git" }, "author": "ForbesLindesay", "license": "MIT" }umd-3.0.3/source.js000066400000000000000000000044421325244643700141560ustar00rootroot00000000000000'use strict'; var fs = require('fs'); var templateSTR = fs.readFileSync(__dirname + '/template.min.js', 'utf8'); function template(moduleName, options) { if (typeof options === 'boolean') { options = {commonJS: options}; } else if (!options) { options = {}; } var str = templateSTR.replace(/defineNamespace\(\)/g, compileNamespace(moduleName)) .split('source()') str[0] = str[0].trim(); //make sure these are undefined so as to not get confused if modules have inner UMD systems str[0] += 'var define,module,exports;'; if (options.commonJS) str[0] += 'module={exports:(exports={})};'; str[0] += '\n'; if (options.commonJS) str[1] = 'return module.exports;' + str[1]; str[1] = '\n' + str[1]; return str; } exports = module.exports = function (name, src, options) { if (typeof options === 'string' && typeof src === 'object') { var tmp = options; options = src; src = tmp; } return exports.prelude(name, options) + src + exports.postlude(name, options); }; exports.prelude = function (moduleName, options) { return template(moduleName, options)[0]; }; exports.postlude = function (moduleName, options) { return template(moduleName, options)[1]; }; function camelCase(name) { name = name.replace(/\-([a-z])/g, function (_, char) { return char.toUpperCase(); }); if (!/^[a-zA-Z_$]$/.test(name[0])) { name = name.substr(1); } var result = name.replace(/[^\w$]+/g, '') if (!result) { throw new Error('Invalid JavaScript identifier resulted from camel-casing'); } return result } function compileNamespace(name) { var names = name.split('.') // No namespaces, yield the best case 'global.NAME = VALUE' if (names.length === 1) { return 'g.' + camelCase(name) + ' = f()'; // Acceptable case, with reasonable compilation } else if (names.length === 2) { names = names.map(camelCase); return '(g.' + names[0] + ' || (g.' + names[0] + ' = {})).' + names[1] + ' = f()'; // Worst case, too many namespaces to care about } else { var valueContainer = names.pop() return names.map(compileNamespaceStep) .concat(['g.' + camelCase(valueContainer) + ' = f()']) .join(';'); } } function compileNamespaceStep(name) { name = camelCase(name); return 'g=(g.' + name + '||(g.' + name + ' = {}))'; } umd-3.0.3/template.js000066400000000000000000000013201325244643700144610ustar00rootroot00000000000000;(function (f) { // CommonJS if (typeof exports === "object" && typeof module !== "undefined") { module.exports = f(); // RequireJS } else if (typeof define === "function" && define.amd) { define([], f); //