Skip to content

Commit

Permalink
Remove socket interface from buildBundle command
Browse files Browse the repository at this point in the history
Reviewed By: davidaurelio

Differential Revision: D3137070

fb-gh-sync-id: 8f3bb4af597bf509d16e5ce26f31fe1646acbc57
fbshipit-source-id: 8f3bb4af597bf509d16e5ce26f31fe1646acbc57
  • Loading branch information
sam-swarr authored and Facebook Github Bot 4 committed Apr 11, 2016
1 parent 838cc48 commit bc81cc4
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions local-cli/bundle/buildBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
const log = require('../util/log').out('bundle');
const outputBundle = require('./output/bundle');
const Promise = require('promise');
const ReactPackager = require('../../packager/react-packager');
const saveAssets = require('./saveAssets');
const Server = require('../../packager/react-packager/src/Server');

function saveBundle(output, bundle, args) {
return Promise.resolve(
Expand All @@ -32,7 +32,7 @@ function buildBundle(args, config, output = outputBundle, packagerInstance) {
blacklistRE: config.getBlacklistRE(args.platform),
getTransformOptionsModulePath: config.getTransformOptionsModulePath,
transformModulePath: args.transformer,
verbose: args.verbose,
nonPersistent: true,
};

const requestOpts = {
Expand All @@ -43,29 +43,22 @@ function buildBundle(args, config, output = outputBundle, packagerInstance) {
platform: args.platform,
};

var bundlePromise;
if (packagerInstance) {
bundlePromise = output.build(packagerInstance, requestOpts)
.then(bundle => saveBundle(output, bundle, args));
} else {
const clientPromise = ReactPackager.createClientFor(options);

// Build and save the bundle
bundlePromise = clientPromise
.then(client => {
log('Created ReactPackager');
return output.build(client, requestOpts);
})
.then(bundle => saveBundle(output, bundle, args));

// When we're done bundling, close the client
Promise.all([clientPromise, bundlePromise])
.then(([client]) => {
log('Closing client');
client.close();
});
// If a packager instance was not provided, then just create one for this
// bundle command and close it down afterwards.
var shouldClosePackager = false;
if (!packagerInstance) {
packagerInstance = new Server(options);
shouldClosePackager = true;
}

const bundlePromise = output.build(packagerInstance, requestOpts)
.then(bundle => {
if (shouldClosePackager) {
packagerInstance.end();
}
return saveBundle(output, bundle, args);
});

// Save the assets of the bundle
const assets = bundlePromise
.then(bundle => bundle.getAssets())
Expand Down

0 comments on commit bc81cc4

Please sign in to comment.