mirror of
https://github.com/status-im/react-native.git
synced 2025-02-05 06:04:15 +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 log = require('../util/log').out('bundle');
|
||||||
const outputBundle = require('./output/bundle');
|
const outputBundle = require('./output/bundle');
|
||||||
const Promise = require('promise');
|
const Promise = require('promise');
|
||||||
const ReactPackager = require('../../packager/react-packager');
|
|
||||||
const saveAssets = require('./saveAssets');
|
const saveAssets = require('./saveAssets');
|
||||||
|
const Server = require('../../packager/react-packager/src/Server');
|
||||||
|
|
||||||
function saveBundle(output, bundle, args) {
|
function saveBundle(output, bundle, args) {
|
||||||
return Promise.resolve(
|
return Promise.resolve(
|
||||||
@ -32,7 +32,7 @@ function buildBundle(args, config, output = outputBundle, packagerInstance) {
|
|||||||
blacklistRE: config.getBlacklistRE(args.platform),
|
blacklistRE: config.getBlacklistRE(args.platform),
|
||||||
getTransformOptionsModulePath: config.getTransformOptionsModulePath,
|
getTransformOptionsModulePath: config.getTransformOptionsModulePath,
|
||||||
transformModulePath: args.transformer,
|
transformModulePath: args.transformer,
|
||||||
verbose: args.verbose,
|
nonPersistent: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const requestOpts = {
|
const requestOpts = {
|
||||||
@ -43,29 +43,22 @@ function buildBundle(args, config, output = outputBundle, packagerInstance) {
|
|||||||
platform: args.platform,
|
platform: args.platform,
|
||||||
};
|
};
|
||||||
|
|
||||||
var bundlePromise;
|
// If a packager instance was not provided, then just create one for this
|
||||||
if (packagerInstance) {
|
// bundle command and close it down afterwards.
|
||||||
bundlePromise = output.build(packagerInstance, requestOpts)
|
var shouldClosePackager = false;
|
||||||
.then(bundle => saveBundle(output, bundle, args));
|
if (!packagerInstance) {
|
||||||
} else {
|
packagerInstance = new Server(options);
|
||||||
const clientPromise = ReactPackager.createClientFor(options);
|
shouldClosePackager = true;
|
||||||
|
|
||||||
// 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();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bundlePromise = output.build(packagerInstance, requestOpts)
|
||||||
|
.then(bundle => {
|
||||||
|
if (shouldClosePackager) {
|
||||||
|
packagerInstance.end();
|
||||||
|
}
|
||||||
|
return saveBundle(output, bundle, args);
|
||||||
|
});
|
||||||
|
|
||||||
// Save the assets of the bundle
|
// Save the assets of the bundle
|
||||||
const assets = bundlePromise
|
const assets = bundlePromise
|
||||||
.then(bundle => bundle.getAssets())
|
.then(bundle => bundle.getAssets())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user