mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Add -n/--no-dep build option.
Former-commit-id: 57571d0df4e17402b9055bae5ccfbc2b94f03613
This commit is contained in:
31
build.js
31
build.js
@@ -1526,6 +1526,7 @@
|
|||||||
'-d', '--debug',
|
'-d', '--debug',
|
||||||
'-h', '--help',
|
'-h', '--help',
|
||||||
'-m', '--minify',
|
'-m', '--minify',
|
||||||
|
'-n', '--no-dep',
|
||||||
'-o', '--output',
|
'-o', '--output',
|
||||||
'-p', '--source-map',
|
'-p', '--source-map',
|
||||||
'-s', '--silent',
|
'-s', '--silent',
|
||||||
@@ -1607,6 +1608,9 @@
|
|||||||
// flag to specify a modularize build
|
// flag to specify a modularize build
|
||||||
var isModularize = _.contains(options, 'modularize');
|
var isModularize = _.contains(options, 'modularize');
|
||||||
|
|
||||||
|
// flag to specify a no-dependency build
|
||||||
|
var isNoDep = _.contains(options, '-n') || _.contains(options, '--no-dep');
|
||||||
|
|
||||||
// flag to specify writing output to standard output
|
// flag to specify writing output to standard output
|
||||||
var isStdOut = _.contains(options, '-c') || _.contains(options, '--stdout');
|
var isStdOut = _.contains(options, '-c') || _.contains(options, '--stdout');
|
||||||
|
|
||||||
@@ -1777,18 +1781,18 @@
|
|||||||
}
|
}
|
||||||
// add method names explicitly
|
// add method names explicitly
|
||||||
if (includeMethods.length) {
|
if (includeMethods.length) {
|
||||||
result = getDependencies(includeMethods);
|
result = includeMethods;
|
||||||
}
|
}
|
||||||
// add method names required by Backbone and Underscore builds
|
// add method names required by Backbone and Underscore builds
|
||||||
if (isBackbone && !result) {
|
if (isBackbone && !result) {
|
||||||
result = getDependencies(backboneDependencies);
|
result = backboneDependencies;
|
||||||
}
|
}
|
||||||
else if (isUnderscore && !result) {
|
else if (isUnderscore && !result) {
|
||||||
result = getDependencies(underscoreMethods);
|
result = underscoreMethods;
|
||||||
}
|
}
|
||||||
// add method names by category
|
// add method names by category
|
||||||
if (categories.length) {
|
if (categories.length) {
|
||||||
result = _.union(result || [], getDependencies(categories.reduce(function(accumulator, category) {
|
result = _.union(result || [], categories.reduce(function(accumulator, category) {
|
||||||
// get method names belonging to each category
|
// get method names belonging to each category
|
||||||
var methodNames = getMethodsByCategory(source, category);
|
var methodNames = getMethodsByCategory(source, category);
|
||||||
|
|
||||||
@@ -1813,16 +1817,22 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return accumulator.concat(methodNames);
|
return accumulator.concat(methodNames);
|
||||||
}, [])));
|
}, []));
|
||||||
}
|
}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
result = lodashMethods.slice();
|
result = lodashMethods.slice();
|
||||||
}
|
}
|
||||||
if (plusMethods.length) {
|
if (plusMethods.length) {
|
||||||
result = _.union(result, getDependencies(plusMethods));
|
result = _.union(result, plusMethods);
|
||||||
}
|
}
|
||||||
if (minusMethods.length) {
|
if (minusMethods.length) {
|
||||||
result = _.without.apply(_, [result].concat(minusMethods, getDependants(minusMethods)));
|
result = _.without.apply(_, [result].concat(minusMethods, isNoDep
|
||||||
|
? minusMethods
|
||||||
|
: getDependants(minusMethods)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if (!isNoDep) {
|
||||||
|
result = getDependencies(result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}());
|
}());
|
||||||
@@ -2786,8 +2796,11 @@
|
|||||||
source = removeFunction(source, 'shimKeys');
|
source = removeFunction(source, 'shimKeys');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'mixin')) {
|
if (isRemoved(source, 'mixin')) {
|
||||||
// inline `_.mixin` call to ensure proper chaining behavior
|
// if possible, inline the `_.mixin` call to ensure proper chaining behavior
|
||||||
source = source.replace(/^( *)mixin\(lodash\).+/m, function(match, indent) {
|
source = source.replace(/^( *)mixin\(lodash\).+/m, function(match, indent) {
|
||||||
|
if (isRemoved(source, 'forOwn')) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return indent + [
|
return indent + [
|
||||||
'forOwn(lodash, function(func, methodName) {',
|
'forOwn(lodash, function(func, methodName) {',
|
||||||
' lodash[methodName] = func;',
|
' lodash[methodName] = func;',
|
||||||
@@ -2884,7 +2897,7 @@
|
|||||||
|
|
||||||
// flag to specify creating a custom build
|
// flag to specify creating a custom build
|
||||||
var isCustom = (
|
var isCustom = (
|
||||||
isLegacy || isMapped || isModern || isStrict || isUnderscore || outputPath ||
|
isLegacy || isMapped || isModern || isNoDep || isStrict || isUnderscore || outputPath ||
|
||||||
/(?:category|exclude|exports|iife|include|minus|plus)=/.test(options) ||
|
/(?:category|exclude|exports|iife|include|minus|plus)=/.test(options) ||
|
||||||
!_.isEqual(exportsOptions, exportsAll)
|
!_.isEqual(exportsOptions, exportsAll)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1270,7 +1270,35 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
QUnit.module('output options');
|
QUnit.module('nodep option');
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var commands = [
|
||||||
|
'-n',
|
||||||
|
'--no-dep'
|
||||||
|
];
|
||||||
|
|
||||||
|
commands.forEach(function(command) {
|
||||||
|
asyncTest('`lodash modern include=each ' + command +'`', function() {
|
||||||
|
var start = _.after(2, _.once(QUnit.start));
|
||||||
|
|
||||||
|
build(['-s', 'modern', 'include=each', command], function(data) {
|
||||||
|
var basename = path.basename(data.outputPath, '.js'),
|
||||||
|
context = createContext();
|
||||||
|
|
||||||
|
vm.runInContext(data.source, context);
|
||||||
|
var lodash = context._;
|
||||||
|
|
||||||
|
deepEqual(_.functions(lodash), ['each', 'forEach'], basename);
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}());
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
QUnit.module('output option');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var nestedPath = path.join(__dirname, 'a', 'b');
|
var nestedPath = path.join(__dirname, 'a', 'b');
|
||||||
@@ -1311,7 +1339,7 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
QUnit.module('stdout options');
|
QUnit.module('stdout option');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var commands = [
|
var commands = [
|
||||||
|
|||||||
Reference in New Issue
Block a user