mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-13 20:37:48 +00:00
Rename combine to hybrid.
Former-commit-id: 39180b07379581db688ddb066807dba1928cb27c
This commit is contained in:
32
build.js
32
build.js
@@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
/** Used to shares values between multiple callbacks */
|
/** Used to shares values between multiple callbacks */
|
||||||
var accumulator = {
|
var accumulator = {
|
||||||
'combined': {},
|
|
||||||
'compiled': {},
|
'compiled': {},
|
||||||
|
'hybrid': {},
|
||||||
'uglified': {}
|
'uglified': {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -203,38 +203,38 @@
|
|||||||
console.log('Done. Size: %d KB.', result.length);
|
console.log('Done. Size: %d KB.', result.length);
|
||||||
|
|
||||||
// next, minify the Closure Compiler minified source using UglifyJS
|
// next, minify the Closure Compiler minified source using UglifyJS
|
||||||
uglify(accumulator.compiled.source, message, onCombine);
|
uglify(accumulator.compiled.source, message, onHybrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The combined `uglify()` callback.
|
* The hybrid `uglify()` callback.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object|Undefined} exception The error object.
|
* @param {Object|Undefined} exception The error object.
|
||||||
* @param {String} result The resulting minified source.
|
* @param {String} result The resulting minified source.
|
||||||
*/
|
*/
|
||||||
function onCombine(exception, result) {
|
function onHybrid(exception, result) {
|
||||||
if (exception) {
|
if (exception) {
|
||||||
throw exception;
|
throw exception;
|
||||||
}
|
}
|
||||||
// store the post-processed Uglified result and gzip it
|
// store the post-processed Uglified result and gzip it
|
||||||
accumulator.combined.source = result = postprocess(result);
|
accumulator.hybrid.source = result = postprocess(result);
|
||||||
gzip(result, onCombineGzip);
|
gzip(result, onHybridGzip);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The combined `gzip` callback.
|
* The hybrid `gzip` callback.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object|Undefined} exception The error object.
|
* @param {Object|Undefined} exception The error object.
|
||||||
* @param {Buffer} result The resulting gzipped source.
|
* @param {Buffer} result The resulting gzipped source.
|
||||||
*/
|
*/
|
||||||
function onCombineGzip(exception, result) {
|
function onHybridGzip(exception, result) {
|
||||||
if (exception) {
|
if (exception) {
|
||||||
throw exception;
|
throw exception;
|
||||||
}
|
}
|
||||||
// store the gzipped result and report the size
|
// store the gzipped result and report the size
|
||||||
accumulator.combined.gzip = result;
|
accumulator.hybrid.gzip = result;
|
||||||
console.log('Done. Size: %d KB.', result.length);
|
console.log('Done. Size: %d KB.', result.length);
|
||||||
|
|
||||||
// finish by choosing the smallest compressed file
|
// finish by choosing the smallest compressed file
|
||||||
@@ -247,8 +247,8 @@
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function onComplete() {
|
function onComplete() {
|
||||||
var combined = accumulator.combined,
|
var compiled = accumulator.compiled,
|
||||||
compiled = accumulator.compiled,
|
hybrid = accumulator.hybrid,
|
||||||
uglified = accumulator.uglified;
|
uglified = accumulator.uglified;
|
||||||
|
|
||||||
// save the Closure Compiled version to disk
|
// save the Closure Compiled version to disk
|
||||||
@@ -259,20 +259,20 @@
|
|||||||
fs.writeFileSync(path.join(distPath, 'lodash.uglify.js'), uglified.source);
|
fs.writeFileSync(path.join(distPath, 'lodash.uglify.js'), uglified.source);
|
||||||
fs.writeFileSync(path.join(distPath, 'lodash.uglify.js.gz'), uglified.gzip);
|
fs.writeFileSync(path.join(distPath, 'lodash.uglify.js.gz'), uglified.gzip);
|
||||||
|
|
||||||
// save the Combined minified version to disk
|
// save the hybrid minified version to disk
|
||||||
fs.writeFileSync(path.join(distPath, 'lodash.combined.js'), combined.source);
|
fs.writeFileSync(path.join(distPath, 'lodash.hybrid.js'), hybrid.source);
|
||||||
fs.writeFileSync(path.join(distPath, 'lodash.combined.js.gz'), combined.gzip);
|
fs.writeFileSync(path.join(distPath, 'lodash.hybrid.js.gz'), hybrid.gzip);
|
||||||
|
|
||||||
// select the smallest gzipped file and use its minified counterpart as the
|
// select the smallest gzipped file and use its minified counterpart as the
|
||||||
// official minified release (ties go to Closure Compiler)
|
// official minified release (ties go to Closure Compiler)
|
||||||
var min = Math.min(combined.gzip.length, compiled.gzip.length, uglified.gzip.length);
|
var min = Math.min(compiled.gzip.length, hybrid.gzip.length, uglified.gzip.length);
|
||||||
|
|
||||||
fs.writeFileSync(path.join(__dirname, 'lodash.min.js'),
|
fs.writeFileSync(path.join(__dirname, 'lodash.min.js'),
|
||||||
compiled.gzip.length == min
|
compiled.gzip.length == min
|
||||||
? compiled.source
|
? compiled.source
|
||||||
: uglified.gzip.length == min
|
: uglified.gzip.length == min
|
||||||
? uglified.source
|
? uglified.source
|
||||||
: combined.source
|
: hybrid.source
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user