From cfa187f7d90e8586b2683734c3f4b0876f6dfa4f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 7 Jul 2013 17:29:54 -0700 Subject: [PATCH] Create a /lodash.js module when using `modularize`. Former-commit-id: f2d1222fb9ccaed019a712448c2144c90327a4f0 --- build.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/build.js b/build.js index 830e027c7..4df218bc3 100755 --- a/build.js +++ b/build.js @@ -805,7 +805,7 @@ return /^exports=.*$/.test(value) ? optionToArray(value).sort() : result; }, []); - var categories = _.uniq(_.compact(identifiers.map(getCategory))), + var categories = _.uniq(_.compact(identifiers.map(getCategory))).sort(), isAMD = _.contains(exportsOptions, 'amd'), outputPath = options[_.indexOf(options, '-o') + 1], sep = '/'; @@ -884,6 +884,29 @@ '-o', path.join(outputPath, category.toLowerCase() + '.js') )); }); + + // create lodash module + (function() { + var deps = _.invoke(categories, 'toLowerCase'), + depArgs = deps.join(', '), + depPaths = "['" + deps.join("', './") + "'], ", + iife = []; + + if (isAMD) { + iife.push( + 'define(' + depPaths + 'function(' + depArgs + ') {', + " return objects.assign(function lodash() {}, { 'VERSION': '" + _.VERSION + "' }, " + depArgs + ');', + '});' + ); + } + build(options.concat( + '-d', '-n', '-s', + 'exports=none', + 'include=none', + 'iife=' + iife.join('\n'), + '-o', path.join(outputPath, 'lodash.js') + )); + }()); } /**