mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Have build.js remove createCache if it's not called in the source.
Former-commit-id: 399d1e19b96b2084cc8cd459d297129db1bda071
This commit is contained in:
37
build.js
37
build.js
@@ -2698,9 +2698,6 @@
|
|||||||
// unexpose `lodash.support`
|
// unexpose `lodash.support`
|
||||||
source = source.replace(/lodash\.support *= */, '');
|
source = source.replace(/lodash\.support *= */, '');
|
||||||
|
|
||||||
// remove large array optimizations
|
|
||||||
source = removeFunction(source, 'createCache');
|
|
||||||
|
|
||||||
// replace `slice` with `nativeSlice.call`
|
// replace `slice` with `nativeSlice.call`
|
||||||
source = removeFunction(source, 'slice');
|
source = removeFunction(source, 'slice');
|
||||||
source = source.replace(/([^.])\bslice\(/g, '$1nativeSlice.call(');
|
source = source.replace(/([^.])\bslice\(/g, '$1nativeSlice.call(');
|
||||||
@@ -3118,10 +3115,7 @@
|
|||||||
.replace(/(?:\s*\/\/.*)*\n( *)(?:each|forEach)\(\['[\s\S]+?\n\1}.+/g, '')
|
.replace(/(?:\s*\/\/.*)*\n( *)(?:each|forEach)\(\['[\s\S]+?\n\1}.+/g, '')
|
||||||
.replace(/(?:\s*\/\/.*)*\n *lodash\.prototype.[\s\S]+?;/g, '');
|
.replace(/(?:\s*\/\/.*)*\n *lodash\.prototype.[\s\S]+?;/g, '');
|
||||||
}
|
}
|
||||||
if (!/\beach\(/.test(source)) {
|
if (_.size(source.match(/\bcreateIterator\b/g)) < 2) {
|
||||||
source = source.replace(matchFunction(source, 'each'), '');
|
|
||||||
}
|
|
||||||
if ((source.match(/\bcreateIterator\b/g) || []).length < 2) {
|
|
||||||
source = removeFunction(source, 'createIterator');
|
source = removeFunction(source, 'createIterator');
|
||||||
source = removeVar(source, 'defaultsIteratorOptions');
|
source = removeVar(source, 'defaultsIteratorOptions');
|
||||||
source = removeVar(source, 'eachIteratorOptions');
|
source = removeVar(source, 'eachIteratorOptions');
|
||||||
@@ -3130,6 +3124,24 @@
|
|||||||
source = removeVar(source, 'templateIterator');
|
source = removeVar(source, 'templateIterator');
|
||||||
source = removeSupportNonEnumShadows(source);
|
source = removeSupportNonEnumShadows(source);
|
||||||
}
|
}
|
||||||
|
if (_.size(source.match(/\bcreateCache\b/g)) < 2) {
|
||||||
|
source = removeFunction(source, 'createCache');
|
||||||
|
}
|
||||||
|
if (!/\beach\(/.test(source)) {
|
||||||
|
source = source.replace(matchFunction(source, 'each'), '');
|
||||||
|
}
|
||||||
|
if (!/^ *support\.(?:enumErrorProps|nonEnumShadows) *=/m.test(source)) {
|
||||||
|
source = removeVar(source, 'Error');
|
||||||
|
source = removeVar(source, 'errorProto');
|
||||||
|
source = removeFromCreateIterator(source, 'errorClass');
|
||||||
|
source = removeFromCreateIterator(source, 'errorProto');
|
||||||
|
|
||||||
|
// remove 'Error' from the `contextProps` array
|
||||||
|
source = source.replace(/^ *var contextProps *=[\s\S]+?;/m, function(match) {
|
||||||
|
return match.replace(/'Error', */, '');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// remove code used to resolve unneeded `support` properties
|
// remove code used to resolve unneeded `support` properties
|
||||||
source = source.replace(/^ *\(function[\s\S]+?\n(( *)var ctor *= *function[\s\S]+?(?:\n *for.+)+\n)([\s\S]+?)}\(1\)\);\n/m, function(match, setup, indent, body) {
|
source = source.replace(/^ *\(function[\s\S]+?\n(( *)var ctor *= *function[\s\S]+?(?:\n *for.+)+\n)([\s\S]+?)}\(1\)\);\n/m, function(match, setup, indent, body) {
|
||||||
var modified = setup;
|
var modified = setup;
|
||||||
@@ -3163,17 +3175,6 @@
|
|||||||
if (_.size(source.match(/\bfreeExports\b/g)) < 2) {
|
if (_.size(source.match(/\bfreeExports\b/g)) < 2) {
|
||||||
source = removeVar(source, 'freeExports');
|
source = removeVar(source, 'freeExports');
|
||||||
}
|
}
|
||||||
if (!/^ *support\.(?:enumErrorProps|nonEnumShadows) *=/m.test(source)) {
|
|
||||||
source = removeVar(source, 'Error');
|
|
||||||
source = removeVar(source, 'errorProto');
|
|
||||||
source = removeFromCreateIterator(source, 'errorClass');
|
|
||||||
source = removeFromCreateIterator(source, 'errorProto');
|
|
||||||
|
|
||||||
// remove 'Error' from the `contextProps` array
|
|
||||||
source = source.replace(/^ *var contextProps *=[\s\S]+?;/m, function(match) {
|
|
||||||
return match.replace(/'Error', */, '');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
debugSource = cleanupSource(source);
|
debugSource = cleanupSource(source);
|
||||||
source = cleanupSource(source);
|
source = cleanupSource(source);
|
||||||
|
|||||||
Reference in New Issue
Block a user