mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Correct the minified AMD signature for AMD build optimizers and unescape whitelisted properties from Uglified source.
Former-commit-id: 93ccbb77d376b39a1b5dd38cbe74f9b4d4382e3f
This commit is contained in:
@@ -22,14 +22,32 @@
|
|||||||
* @returns {String} Returns the processed source.
|
* @returns {String} Returns the processed source.
|
||||||
*/
|
*/
|
||||||
function postprocess(source) {
|
function postprocess(source) {
|
||||||
|
// exit early if snippet isn't found
|
||||||
|
var snippet = /VERSION\s*:\s*([\'"])(.*?)\1/.exec(source);
|
||||||
|
if (!snippet) {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
// set the version
|
// set the version
|
||||||
var license = licenseTemplate.replace('@VERSION', (/VERSION\s*:\s*([\'"])(.*?)\1/).exec(source).pop());
|
var license = licenseTemplate.replace('@VERSION', snippet[2]);
|
||||||
|
|
||||||
// move vars exposed by Closure Compiler into the IIFE
|
// move vars exposed by Closure Compiler into the IIFE
|
||||||
source = source.replace(/^([^(\n]+)\s*(\(function[^)]+\){)/, '$2$1');
|
source = source.replace(/^([^(\n]+)\s*(\(function[^)]+\){)/, '$2$1');
|
||||||
|
|
||||||
// use double quotes consistently
|
// use double quotes consistently
|
||||||
source = source.replace(/'use strict'/, '"use strict"');
|
source = source.replace(/'use strict'/, '"use strict"');
|
||||||
|
|
||||||
|
// unescape properties (i.e. foo["bar"] => foo.bar)
|
||||||
|
source = source.replace(/(\w)\["([^."]+)"\]/g, '$1.$2');
|
||||||
|
|
||||||
|
// correct AMD module definition for AMD build optimizers
|
||||||
|
source = source.replace(/("function")==(typeof define)&&\(?("object")==(typeof define\.amd)(&&define\.amd)\)?/, '$2==$1&&$4==$3$5');
|
||||||
|
|
||||||
// add license
|
// add license
|
||||||
return license + '\n;' + source;
|
source = license + '\n;' + source;
|
||||||
|
|
||||||
|
// add trailing semicolon
|
||||||
|
return source.replace(/[\s;]*$/, ';');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user