diff --git a/build.js b/build.js index 97ba1e11c..70c05413e 100755 --- a/build.js +++ b/build.js @@ -263,8 +263,8 @@ ]; /** Collections of method names */ - var excludeMethods, - includeMethods, + var excludeMethods = [], + includeMethods = [], allMethods = Object.keys(dependencyMap); var underscoreMethods = lodash.without.apply(lodash, [allMethods].concat([ @@ -720,6 +720,17 @@ /*--------------------------------------------------------------------------*/ + // don't expose `_.forIn` or `_.forOwn` if `isUnderscore` is `true` unless + // requested by `include` + if (isUnderscore) { + if (includeMethods.indexOf('forIn') == -1) { + source = source.replace(/ *lodash\.forIn *=.+\n/, ''); + } + if (includeMethods.indexOf('forOwn') == -1) { + source = source.replace(/ *lodash\.forOwn *=.+\n/, ''); + } + } + // add methods required by Backbone or Underscore [ { 'flag': isBackbone, 'methodNames': backboneDependencies },