mirror of
https://github.com/status-im/react-native.git
synced 2025-02-26 16:10:58 +00:00
Bring back "download from server" perf optimization
Reviewed By: @frantic Differential Revision: D2515566 fb-gh-sync-id: 25771888390154e9962d141f872cef85c08cd1d0
This commit is contained in:
parent
799168929c
commit
d30384080a
@ -9,7 +9,7 @@
|
||||
'use strict';
|
||||
|
||||
const log = require('../util/log').out('bundle');
|
||||
const parseCommandLine = require('../../../packager/parseCommandLine');
|
||||
const parseBundleCommandLine = require('./parseBundleCommandLine');
|
||||
const processBundle = require('./processBundle');
|
||||
const Promise = require('promise');
|
||||
const ReactPackager = require('../../../packager/react-packager');
|
||||
@ -25,36 +25,7 @@ function bundle(argv, config) {
|
||||
}
|
||||
|
||||
function _bundle(argv, config, resolve, reject) {
|
||||
const args = parseCommandLine([
|
||||
{
|
||||
command: 'entry-file',
|
||||
description: 'Path to the root JS file, either absolute or relative to JS root',
|
||||
type: 'string',
|
||||
required: true,
|
||||
}, {
|
||||
command: 'platform',
|
||||
description: 'Either "ios" or "android"',
|
||||
type: 'string',
|
||||
required: true,
|
||||
}, {
|
||||
command: 'dev',
|
||||
description: 'If false, warnings are disabled and the bundle is minified',
|
||||
default: true,
|
||||
}, {
|
||||
command: 'bundle-output',
|
||||
description: 'File name where to store the resulting bundle, ex. /tmp/groups.bundle',
|
||||
type: 'string',
|
||||
required: true,
|
||||
}, {
|
||||
command: 'sourcemap-output',
|
||||
description: 'File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map',
|
||||
type: 'string',
|
||||
}, {
|
||||
command: 'assets-dest',
|
||||
description: 'Directory name where to store assets referenced in the bundle',
|
||||
type: 'string',
|
||||
}
|
||||
], argv);
|
||||
const args = parseBundleCommandLine(argv);
|
||||
|
||||
// This is used by a bazillion of npm modules we don't control so we don't
|
||||
// have other choice than defining it as an env variable here.
|
||||
|
44
private-cli/src/bundle/parseBundleCommandLine.js
Normal file
44
private-cli/src/bundle/parseBundleCommandLine.js
Normal file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const parseCommandLine = require('../../../packager/parseCommandLine');
|
||||
|
||||
module.exports = function(argv) {
|
||||
return parseCommandLine([
|
||||
{
|
||||
command: 'entry-file',
|
||||
description: 'Path to the root JS file, either absolute or relative to JS root',
|
||||
type: 'string',
|
||||
required: true,
|
||||
}, {
|
||||
command: 'platform',
|
||||
description: 'Either "ios" or "android"',
|
||||
type: 'string',
|
||||
required: true,
|
||||
}, {
|
||||
command: 'dev',
|
||||
description: 'If false, warnings are disabled and the bundle is minified',
|
||||
default: true,
|
||||
}, {
|
||||
command: 'bundle-output',
|
||||
description: 'File name where to store the resulting bundle, ex. /tmp/groups.bundle',
|
||||
type: 'string',
|
||||
required: true,
|
||||
}, {
|
||||
command: 'sourcemap-output',
|
||||
description: 'File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map',
|
||||
type: 'string',
|
||||
}, {
|
||||
command: 'assets-dest',
|
||||
description: 'Directory name where to store assets referenced in the bundle',
|
||||
type: 'string',
|
||||
}
|
||||
], argv);
|
||||
};
|
@ -29,16 +29,16 @@ const hiddenCommands = {
|
||||
*/
|
||||
function run(command, commandArgs) {
|
||||
if (!command) {
|
||||
throw new Error(helpMessage());
|
||||
return Promise.reject(helpMessage());
|
||||
}
|
||||
commandArgs = commandArgs || [];
|
||||
|
||||
const commandToExec = documentedCommands[command] || hiddenCommands[command];
|
||||
if (!commandToExec) {
|
||||
throw new Error(helpMessage(command));
|
||||
return Promise.reject(helpMessage(command));
|
||||
}
|
||||
|
||||
commandToExec(commandArgs, Config.get()).done();
|
||||
return commandToExec(commandArgs, Config.get());
|
||||
}
|
||||
|
||||
function helpMessage(command) {
|
||||
@ -61,4 +61,7 @@ function help() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
module.exports.run = run;
|
||||
module.exports = {
|
||||
run: run,
|
||||
commands: documentedCommands,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user