Bring back "download from server" perf optimization
Reviewed By: @frantic Differential Revision: D2515566 fb-gh-sync-id: 25771888390154e9962d141f872cef85c08cd1d0
This commit is contained in:
Родитель
799168929c
Коммит
d30384080a
|
@ -9,7 +9,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const log = require('../util/log').out('bundle');
|
const log = require('../util/log').out('bundle');
|
||||||
const parseCommandLine = require('../../../packager/parseCommandLine');
|
const parseBundleCommandLine = require('./parseBundleCommandLine');
|
||||||
const processBundle = require('./processBundle');
|
const processBundle = require('./processBundle');
|
||||||
const Promise = require('promise');
|
const Promise = require('promise');
|
||||||
const ReactPackager = require('../../../packager/react-packager');
|
const ReactPackager = require('../../../packager/react-packager');
|
||||||
|
@ -25,36 +25,7 @@ function bundle(argv, config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _bundle(argv, config, resolve, reject) {
|
function _bundle(argv, config, resolve, reject) {
|
||||||
const args = parseCommandLine([
|
const args = parseBundleCommandLine(argv);
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
// This is used by a bazillion of npm modules we don't control so we don't
|
// 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.
|
// have other choice than defining it as an env variable here.
|
||||||
|
|
|
@ -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) {
|
function run(command, commandArgs) {
|
||||||
if (!command) {
|
if (!command) {
|
||||||
throw new Error(helpMessage());
|
return Promise.reject(helpMessage());
|
||||||
}
|
}
|
||||||
commandArgs = commandArgs || [];
|
commandArgs = commandArgs || [];
|
||||||
|
|
||||||
const commandToExec = documentedCommands[command] || hiddenCommands[command];
|
const commandToExec = documentedCommands[command] || hiddenCommands[command];
|
||||||
if (!commandToExec) {
|
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) {
|
function helpMessage(command) {
|
||||||
|
@ -61,4 +61,7 @@ function help() {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.run = run;
|
module.exports = {
|
||||||
|
run: run,
|
||||||
|
commands: documentedCommands,
|
||||||
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче