[react-packager] Fix regression with transform errors

This commit is contained in:
Amjad Masad 2015-03-23 19:17:22 -07:00
parent 7e2b9bfd77
commit fc92348d8b
2 changed files with 6 additions and 2 deletions

View File

@ -186,6 +186,7 @@ describe('processRequest', function() {
expect(packageFunc.mock.calls.length).toBe(1); expect(packageFunc.mock.calls.length).toBe(1);
triggerFileChange('all','path/file.js', options.projectRoots[0]); triggerFileChange('all','path/file.js', options.projectRoots[0]);
jest.runAllTimers(); jest.runAllTimers();
jest.runAllTimers();
}) })
.then(function() { .then(function() {
expect(packageFunc.mock.calls.length).toBe(2); expect(packageFunc.mock.calls.length).toBe(2);

View File

@ -92,8 +92,10 @@ Server.prototype._rebuildPackages = function() {
Object.keys(packages).forEach(function(key) { Object.keys(packages).forEach(function(key) {
var options = getOptionsFromUrl(key); var options = getOptionsFromUrl(key);
// Wait for a previous build (if exists) to finish. // Wait for a previous build (if exists) to finish.
packages[key] = (packages[key] || q()).then(function() { packages[key] = (packages[key] || q()).finally(function() {
return buildPackage(options).then(function(p) { // 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. // Make a throwaway call to getSource to cache the source string.
p.getSource({ p.getSource({
inlineSourceMap: options.dev, inlineSourceMap: options.dev,
@ -102,6 +104,7 @@ Server.prototype._rebuildPackages = function() {
return p; return p;
}); });
}); });
return packages[key];
}); });
}; };