2015-10-05 16:15:09 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-11-14 19:12:24 +00:00
|
|
|
'use strict';
|
2015-10-05 16:15:09 +00:00
|
|
|
|
2015-10-20 20:47:41 +00:00
|
|
|
const buildBundle = require('./buildBundle');
|
2016-07-30 15:59:16 +00:00
|
|
|
const bundleCommandLineArgs = require('./bundleCommandLineArgs');
|
2017-06-25 00:04:27 +00:00
|
|
|
const outputBundle = require('metro-bundler/src/shared/output/bundle');
|
2015-10-05 16:15:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds the bundle starting to look for dependencies at the given entry path.
|
|
|
|
*/
|
2016-07-30 15:59:16 +00:00
|
|
|
function bundleWithOutput(argv, config, args, output, packagerInstance) {
|
2015-12-01 15:42:44 +00:00
|
|
|
if (!output) {
|
2016-11-07 11:36:51 +00:00
|
|
|
output = outputBundle;
|
2015-12-01 15:42:44 +00:00
|
|
|
}
|
2016-03-18 19:44:01 +00:00
|
|
|
return buildBundle(args, config, output, packagerInstance);
|
2015-12-01 15:42:44 +00:00
|
|
|
}
|
|
|
|
|
2016-07-30 15:59:16 +00:00
|
|
|
function bundle(argv, config, args, packagerInstance) {
|
|
|
|
return bundleWithOutput(argv, config, args, undefined, packagerInstance);
|
2015-10-05 16:15:09 +00:00
|
|
|
}
|
|
|
|
|
2016-07-30 15:59:16 +00:00
|
|
|
module.exports = {
|
|
|
|
name: 'bundle',
|
|
|
|
description: 'builds the javascript bundle for offline use',
|
|
|
|
func: bundle,
|
|
|
|
options: bundleCommandLineArgs,
|
|
|
|
|
|
|
|
// not used by the CLI itself
|
|
|
|
withOutput: bundleWithOutput,
|
|
|
|
};
|