From fc92348d8bd7c5b68e158af5d40a44bada67b34f Mon Sep 17 00:00:00 2001 From: Amjad Masad Date: Mon, 23 Mar 2015 19:17:22 -0700 Subject: [PATCH] [react-packager] Fix regression with transform errors --- react-packager/src/Server/__tests__/Server-test.js | 1 + react-packager/src/Server/index.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/react-packager/src/Server/__tests__/Server-test.js b/react-packager/src/Server/__tests__/Server-test.js index 8e638311..aa7ca349 100644 --- a/react-packager/src/Server/__tests__/Server-test.js +++ b/react-packager/src/Server/__tests__/Server-test.js @@ -186,6 +186,7 @@ describe('processRequest', function() { expect(packageFunc.mock.calls.length).toBe(1); triggerFileChange('all','path/file.js', options.projectRoots[0]); jest.runAllTimers(); + jest.runAllTimers(); }) .then(function() { expect(packageFunc.mock.calls.length).toBe(2); diff --git a/react-packager/src/Server/index.js b/react-packager/src/Server/index.js index cc4f0bdf..19ec0039 100644 --- a/react-packager/src/Server/index.js +++ b/react-packager/src/Server/index.js @@ -92,8 +92,10 @@ Server.prototype._rebuildPackages = function() { Object.keys(packages).forEach(function(key) { var options = getOptionsFromUrl(key); // Wait for a previous build (if exists) to finish. - packages[key] = (packages[key] || q()).then(function() { - return buildPackage(options).then(function(p) { + packages[key] = (packages[key] || q()).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) { // Make a throwaway call to getSource to cache the source string. p.getSource({ inlineSourceMap: options.dev, @@ -102,6 +104,7 @@ Server.prototype._rebuildPackages = function() { return p; }); }); + return packages[key]; }); };