Move WPO to the minify step

Summary:
public

The Whole Program Optimisation (WPO) pass is quite slow, and can make it painful
to iterate when having `dev=false`. Move it to happen only when both `dev=false` and `minify=true`.

Reviewed By: davidaurelio

Differential Revision: D2773941

fb-gh-sync-id: ac5ca4e1286e233c2d175eecdbf7494d5d3497b2
This commit is contained in:
Tadeu Zagallo 2015-12-27 06:00:39 -08:00 committed by facebook-github-bot-4
parent 739a6d6be1
commit f546dc3790
1 changed files with 18 additions and 20 deletions

View File

@ -109,24 +109,6 @@ class Bundle {
}
this._source = _.pluck(this._modules, 'code').join('\n');
if (dev) {
return this._source;
}
const wpoActivity = Activity.startEvent('Whole Program Optimisations');
const result = require('babel-core').transform(this._source, {
retainLines: true,
compact: true,
plugins: require('../transforms/whole-program-optimisations'),
inputSourceMap: this.getSourceMap(),
});
this._source = result.code;
this._sourceMap = result.map;
Activity.endEvent(wpoActivity);
return this._source;
}
@ -187,13 +169,29 @@ class Bundle {
return this._minifiedSourceAndMap;
}
const source = this._getSource(dev);
let source = this._getSource(dev);
let map = this.getSourceMap();
if (!dev) {
const wpoActivity = Activity.startEvent('Whole Program Optimisations');
const wpoResult = require('babel-core').transform(source, {
retainLines: true,
compact: true,
plugins: require('../transforms/whole-program-optimisations'),
inputSourceMap: map,
});
Activity.endEvent(wpoActivity);
source = wpoResult.code;
map = wpoResult.map;
}
try {
const minifyActivity = Activity.startEvent('minify');
this._minifiedSourceAndMap = UglifyJS.minify(source, {
fromString: true,
outSourceMap: this._sourceMapUrl,
inSourceMap: this.getSourceMap(),
inSourceMap: map,
output: {ascii_only: true},
});
Activity.endEvent(minifyActivity);