From 90409770c9487d8e84242b2e409383054f05891f Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Fri, 4 Sep 2015 12:06:44 -0700 Subject: [PATCH] [RectNative][Packager] Cache minification result Summary: The packager just cached the result of the bundle, but would minify it on every request. Change it to cache the minification result. --- packager/react-packager/src/Bundler/Bundle.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packager/react-packager/src/Bundler/Bundle.js b/packager/react-packager/src/Bundler/Bundle.js index 88431cbf6..6f20b49d0 100644 --- a/packager/react-packager/src/Bundler/Bundle.js +++ b/packager/react-packager/src/Bundler/Bundle.js @@ -115,13 +115,18 @@ class Bundle { getMinifiedSourceAndMap() { this._assertFinalized(); + if (this._minifiedSourceAndMap) { + return this._minifiedSourceAndMap; + } + const source = this._getSource(); try { - return UglifyJS.minify(source, { + this._minifiedSourceAndMap = UglifyJS.minify(source, { fromString: true, outSourceMap: 'bundle.js', inSourceMap: this.getSourceMap(), }); + return this._minifiedSourceAndMap; } catch(e) { // Sometimes, when somebody is using a new syntax feature that we // don't yet have transform for, the untransformed line is sent to