[react-packager] Switch from Q to Bluebird as promises library

Summary:
This PR improves performance of `react-packager` by switching the promises library from the [Q](https://github.com/kriskowal/q) to [Bluebird](https://github.com/petkaantonov/bluebird).

[Here is the test result](https://github.com/facebook/react-native/issues/361#issuecomment-87829808) showing a noticeable difference. (2x speed improvement)

Please refer to [this issue](https://github.com/facebook/react-native/issues/361) for more details.
Closes https://github.com/facebook/react-native/pull/516
Github Author: Pilwon Huh <pilwon@gmail.com>

Test Plan:
./runJestTests
start app and click around
This commit is contained in:
Pilwon Huh
2015-03-31 20:23:33 -07:00
parent 6638713d3c
commit 87599bfcd1
14 changed files with 77 additions and 78 deletions

View File

@@ -10,12 +10,10 @@
var EventEmitter = require('events').EventEmitter;
var sane = require('sane');
var q = require('q');
var Promise = require('bluebird');
var util = require('util');
var exec = require('child_process').exec;
var Promise = q.Promise;
var detectingWatcherClass = new Promise(function(resolve) {
exec('which watchman', function(err, out) {
if (err || out.length === 0) {
@@ -41,7 +39,7 @@ function FileWatcher(rootConfigs) {
fileWatcher = this;
this._loading = q.all(
this._loading = Promise.all(
rootConfigs.map(createWatcher)
).then(function(watchers) {
watchers.forEach(function(watcher) {
@@ -59,7 +57,7 @@ util.inherits(FileWatcher, EventEmitter);
FileWatcher.prototype.end = function() {
return this._loading.then(function(watchers) {
watchers.forEach(function(watcher) {
return q.ninvoke(watcher, 'close');
return Promise.promisify(watcher.close, watcher)();
});
});
};
@@ -88,7 +86,7 @@ function createWatcher(rootConfig) {
FileWatcher.createDummyWatcher = function() {
var ev = new EventEmitter();
ev.end = function() {
return q();
return Promise.resolve();
};
return ev;
};