mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
Remove socket interface from buildBundle command
Reviewed By: davidaurelio Differential Revision: D3137070 fb-gh-sync-id: 8f3bb4af597bf509d16e5ce26f31fe1646acbc57 fbshipit-source-id: 8f3bb4af597bf509d16e5ce26f31fe1646acbc57
This commit is contained in:
parent
838cc48059
commit
bc81cc4073
@ -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(
|
||||
@ -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 = {
|
||||
@ -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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user