diff --git a/react-packager/src/Server/index.js b/react-packager/src/Server/index.js index 0ce5c584..3e8ca9e8 100644 --- a/react-packager/src/Server/index.js +++ b/react-packager/src/Server/index.js @@ -131,13 +131,14 @@ Server.prototype._onFileChange = function(type, filepath, root) { Server.prototype._rebuildPackages = function() { var buildPackage = this.buildPackage.bind(this); var packages = this._packages; - Object.keys(packages).forEach(function(key) { - var options = getOptionsFromUrl(key); + + Object.keys(packages).forEach(function(optionsJson) { + var options = JSON.parse(optionsJson); // Wait for a previous build (if exists) to finish. - packages[key] = (packages[key] || Promise.resolve()).finally(function() { + packages[optionsJson] = (packages[optionsJson] || Promise.resolve()).finally(function() { // With finally promise callback we can't change the state of the promise // so we need to reassign the promise. - packages[key] = buildPackage(options).then(function(p) { + packages[optionsJson] = buildPackage(options).then(function(p) { // Make a throwaway call to getSource to cache the source string. p.getSource({ inlineSourceMap: options.inlineSourceMap, @@ -146,7 +147,7 @@ Server.prototype._rebuildPackages = function() { return p; }); }); - return packages[key]; + return packages[optionsJson]; }); }; @@ -228,9 +229,9 @@ Server.prototype._processDebugRequest = function(reqUrl, res) { res.end(ret); } else if (parts[1] === 'packages') { ret += '

Cached Packages

'; - Promise.all(Object.keys(this._packages).map(function(url) { - return this._packages[url].then(function(p) { - ret += '

' + url + '

'; + Promise.all(Object.keys(this._packages).map(function(optionsJson) { + return this._packages[optionsJson].then(function(p) { + ret += '

' + optionsJson + '

'; ret += p.getDebugInfo(); }); }, this)).then( @@ -350,10 +351,11 @@ Server.prototype.processRequest = function(req, res, next) { var startReqEventId = Activity.startEvent('request:' + req.url); var options = getOptionsFromUrl(req.url); - var building = this._packages[req.url] || this.buildPackage(options); + var optionsJson = JSON.stringify(options); + var building = this._packages[optionsJson] || this.buildPackage(options); - this._packages[req.url] = building; - building.then( + this._packages[optionsJson] = building; + building.then( function(p) { if (requestType === 'bundle') { res.end(p.getSource({