Fix modularize legacy builds.

Former-commit-id: 17b09cce67bdf0ec2fd7373beb5b58240b08877b
This commit is contained in:
John-David Dalton
2013-08-03 21:33:29 -07:00
parent 6aa1361b1a
commit 76dcd7d96e

View File

@@ -265,13 +265,13 @@
/** Used to track Lo-Dash property dependencies of identifiers */ /** Used to track Lo-Dash property dependencies of identifiers */
var propDependencyMap = { var propDependencyMap = {
'at': ['support'], 'at': ['support'],
'baseClone': ['support'],
'baseIsEqual': ['support'],
'bind': ['support'], 'bind': ['support'],
'clone': ['support'],
'createBound': ['support'], 'createBound': ['support'],
'forEachRight': ['support'], 'forEachRight': ['support'],
'isArguments': ['support'], 'isArguments': ['support'],
'isEmpty': ['support'], 'isEmpty': ['support'],
'isEqual': ['support'],
'isPlainObject': ['support'], 'isPlainObject': ['support'],
'iteratorTemplate': ['support'], 'iteratorTemplate': ['support'],
'keys': ['support'], 'keys': ['support'],
@@ -1439,22 +1439,6 @@
return result ? result[0] : ''; return result ? result[0] : '';
} }
/**
* Gets the `templateSettings` assignment from `source`.
*
* @private
* @param {String} source The source to inspect.
* @returns {String} Returns the assignment.
*/
function getTemplateSettings(source) {
var result = source.match(RegExp(
multilineComment +
'( *)(?:var +|lodash\\.)templateSettings *=[\\s\\S]+?\\n\\1};\\n'
));
return result ? result[0] : '';
}
/** /**
* Creates a sorted array of all variables defined outside of Lo-Dash functions. * Creates a sorted array of all variables defined outside of Lo-Dash functions.
* *
@@ -3942,7 +3926,7 @@
.replace(/iteratorTemplate *&& */g, '') .replace(/iteratorTemplate *&& */g, '')
.replace(/iteratorTemplate\s*\?\s*([^:]+?)\s*:[^,;]+/g, '$1'); .replace(/iteratorTemplate\s*\?\s*([^:]+?)\s*:[^,;]+/g, '$1');
}); });
}
if (isModern || isUnderscore) { if (isModern || isUnderscore) {
iteratorOptions.forEach(function(prop) { iteratorOptions.forEach(function(prop) {
if (prop != 'array') { if (prop != 'array') {
@@ -4045,6 +4029,7 @@
}, match); }, match);
}); });
} }
}
if (isModularize) { if (isModularize) {
source = removeGetIndexOf(source); source = removeGetIndexOf(source);
@@ -4062,15 +4047,18 @@
return match.replace(/(?: *\/\/.*\n)*( *)if *\(!source[\s\S]+?\n\1}/, ''); return match.replace(/(?: *\/\/.*\n)*( *)if *\(!source[\s\S]+?\n\1}/, '');
}); });
// remove debug sourceURL use in `_.template`
source = source.replace(matchFunction(source, 'template'), function(match) {
return match.replace(/(?:\s*\/\/.*\n)* *var sourceURL[^;]+;|\+ *sourceURL/g, '');
});
// replace `lodash` use in `_.templateSettings.imports` // replace `lodash` use in `_.templateSettings.imports`
source = source.replace(matchProp(source, 'templateSettings'), function(match) { source = source.replace(matchProp(source, 'templateSettings'), function(match) {
return match.replace(/(:\s*)lodash\b/, "$1{ 'escape': escape }"); return match.replace(/(:\s*)lodash\b/, "$1{ 'escape': escape }");
}); });
source = source.replace(matchFunction(source, 'template'), function(match) {
return match
// assign `settings` variable from the reassigned `templateSettings.imports`
.replace(/= *templateSettings\b/, '$&.imports._.templateSettings')
// remove debug sourceURL use in `_.template`
.replace(/(?:\s*\/\/.*\n)* *var sourceURL[^;]+;|\+ *sourceURL/g, '');
});
} }
} }