mirror of https://github.com/status-im/metro.git
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:
parent
30e8f9fd22
commit
ecec0ea842
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue