Remove unused `packagerInstance` option and rename it to `server`
Reviewed By: rafeca Differential Revision: D6435505 fbshipit-source-id: e1912f20be517be49648b0eeb52c53f66e3fae55
This commit is contained in:
parent
af6450c660
commit
bbbc18c4ee
|
@ -57,7 +57,6 @@ async function buildBundle(
|
||||||
},
|
},
|
||||||
config: ConfigT,
|
config: ConfigT,
|
||||||
output = outputBundle,
|
output = outputBundle,
|
||||||
packagerInstance,
|
|
||||||
) {
|
) {
|
||||||
// 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.
|
||||||
|
@ -76,60 +75,53 @@ async function buildBundle(
|
||||||
platform: args.platform,
|
platform: args.platform,
|
||||||
};
|
};
|
||||||
|
|
||||||
// If a packager instance was not provided, then just create one for this
|
const assetExts = (config.getAssetExts && config.getAssetExts()) || [];
|
||||||
// bundle command and close it down afterwards.
|
const sourceExts = (config.getSourceExts && config.getSourceExts()) || [];
|
||||||
var shouldClosePackager = false;
|
const platforms = (config.getPlatforms && config.getPlatforms()) || [];
|
||||||
if (!packagerInstance) {
|
|
||||||
const assetExts = (config.getAssetExts && config.getAssetExts()) || [];
|
|
||||||
const sourceExts = (config.getSourceExts && config.getSourceExts()) || [];
|
|
||||||
const platforms = (config.getPlatforms && config.getPlatforms()) || [];
|
|
||||||
|
|
||||||
const transformModulePath = args.transformer
|
const transformModulePath = args.transformer
|
||||||
? path.resolve(args.transformer)
|
? path.resolve(args.transformer)
|
||||||
: config.getTransformModulePath();
|
: config.getTransformModulePath();
|
||||||
|
|
||||||
const providesModuleNodeModules =
|
const providesModuleNodeModules =
|
||||||
typeof config.getProvidesModuleNodeModules === 'function'
|
typeof config.getProvidesModuleNodeModules === 'function'
|
||||||
? config.getProvidesModuleNodeModules()
|
? config.getProvidesModuleNodeModules()
|
||||||
: defaultProvidesModuleNodeModules;
|
: defaultProvidesModuleNodeModules;
|
||||||
|
|
||||||
const terminal = new Terminal(process.stdout);
|
const terminal = new Terminal(process.stdout);
|
||||||
const options = {
|
|
||||||
assetExts: defaultAssetExts.concat(assetExts),
|
|
||||||
assetRegistryPath: ASSET_REGISTRY_PATH,
|
|
||||||
blacklistRE: config.getBlacklistRE(),
|
|
||||||
extraNodeModules: config.extraNodeModules,
|
|
||||||
getModulesRunBeforeMainModule: config.getModulesRunBeforeMainModule,
|
|
||||||
getPolyfills: config.getPolyfills,
|
|
||||||
getTransformOptions: config.getTransformOptions,
|
|
||||||
globalTransformCache: null,
|
|
||||||
hasteImpl: config.hasteImpl,
|
|
||||||
maxWorkers: args.maxWorkers,
|
|
||||||
platforms: defaultPlatforms.concat(platforms),
|
|
||||||
postMinifyProcess: config.postMinifyProcess,
|
|
||||||
postProcessModules: config.postProcessModules,
|
|
||||||
postProcessBundleSourcemap: config.postProcessBundleSourcemap,
|
|
||||||
projectRoots: config.getProjectRoots(),
|
|
||||||
providesModuleNodeModules: providesModuleNodeModules,
|
|
||||||
resetCache: args.resetCache,
|
|
||||||
reporter: new TerminalReporter(terminal),
|
|
||||||
sourceExts: defaultSourceExts.concat(sourceExts),
|
|
||||||
transformCache: TransformCaching.useTempDir(),
|
|
||||||
transformModulePath: transformModulePath,
|
|
||||||
watch: false,
|
|
||||||
workerPath: config.getWorkerPath && config.getWorkerPath(),
|
|
||||||
};
|
|
||||||
|
|
||||||
packagerInstance = new Server(options);
|
const server = new Server({
|
||||||
shouldClosePackager = true;
|
assetExts: defaultAssetExts.concat(assetExts),
|
||||||
}
|
assetRegistryPath: ASSET_REGISTRY_PATH,
|
||||||
|
blacklistRE: config.getBlacklistRE(),
|
||||||
|
extraNodeModules: config.extraNodeModules,
|
||||||
|
getModulesRunBeforeMainModule: config.getModulesRunBeforeMainModule,
|
||||||
|
getPolyfills: config.getPolyfills,
|
||||||
|
getTransformOptions: config.getTransformOptions,
|
||||||
|
globalTransformCache: null,
|
||||||
|
hasteImpl: config.hasteImpl,
|
||||||
|
maxWorkers: args.maxWorkers,
|
||||||
|
platforms: defaultPlatforms.concat(platforms),
|
||||||
|
postMinifyProcess: config.postMinifyProcess,
|
||||||
|
postProcessModules: config.postProcessModules,
|
||||||
|
postProcessBundleSourcemap: config.postProcessBundleSourcemap,
|
||||||
|
projectRoots: config.getProjectRoots(),
|
||||||
|
providesModuleNodeModules: providesModuleNodeModules,
|
||||||
|
resetCache: args.resetCache,
|
||||||
|
reporter: new TerminalReporter(terminal),
|
||||||
|
sourceExts: defaultSourceExts.concat(sourceExts),
|
||||||
|
transformCache: TransformCaching.useTempDir(),
|
||||||
|
transformModulePath: transformModulePath,
|
||||||
|
watch: false,
|
||||||
|
workerPath: config.getWorkerPath && config.getWorkerPath(),
|
||||||
|
});
|
||||||
|
|
||||||
const bundle = await output.build(packagerInstance, requestOpts);
|
const bundle = await output.build(server, requestOpts);
|
||||||
|
|
||||||
await output.save(bundle, args, log);
|
await output.save(bundle, args, log);
|
||||||
|
|
||||||
// Save the assets of the bundle
|
// Save the assets of the bundle
|
||||||
const outputAssets = await packagerInstance.getAssets({
|
const outputAssets = await server.getAssets({
|
||||||
...Server.DEFAULT_BUNDLE_OPTIONS,
|
...Server.DEFAULT_BUNDLE_OPTIONS,
|
||||||
...requestOpts,
|
...requestOpts,
|
||||||
bundleType: 'todo',
|
bundleType: 'todo',
|
||||||
|
@ -142,9 +134,7 @@ async function buildBundle(
|
||||||
args.assetsDest,
|
args.assetsDest,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (shouldClosePackager) {
|
server.end();
|
||||||
packagerInstance.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
return assets;
|
return assets;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,21 +15,17 @@ const outputBundle = require('metro/src/shared/output/bundle');
|
||||||
/**
|
/**
|
||||||
* Builds the bundle starting to look for dependencies at the given entry path.
|
* Builds the bundle starting to look for dependencies at the given entry path.
|
||||||
*/
|
*/
|
||||||
function bundleWithOutput(argv, config, args, output, packagerInstance) {
|
function bundleWithOutput(argv, config, args, output) {
|
||||||
if (!output) {
|
if (!output) {
|
||||||
output = outputBundle;
|
output = outputBundle;
|
||||||
}
|
}
|
||||||
return buildBundle(args, config, output, packagerInstance);
|
return buildBundle(args, config, output);
|
||||||
}
|
|
||||||
|
|
||||||
function bundle(argv, config, args, packagerInstance) {
|
|
||||||
return bundleWithOutput(argv, config, args, undefined, packagerInstance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'bundle',
|
name: 'bundle',
|
||||||
description: 'builds the javascript bundle for offline use',
|
description: 'builds the javascript bundle for offline use',
|
||||||
func: bundle,
|
func: bundleWithOutput,
|
||||||
options: bundleCommandLineArgs,
|
options: bundleCommandLineArgs,
|
||||||
|
|
||||||
// not used by the CLI itself
|
// not used by the CLI itself
|
||||||
|
|
|
@ -15,8 +15,8 @@ const outputUnbundle = require('metro/src/shared/output/unbundle');
|
||||||
/**
|
/**
|
||||||
* Builds the bundle starting to look for dependencies at the given entry path.
|
* Builds the bundle starting to look for dependencies at the given entry path.
|
||||||
*/
|
*/
|
||||||
function unbundle(argv, config, args, packagerInstance) {
|
function unbundle(argv, config, args) {
|
||||||
return bundleWithOutput(argv, config, args, outputUnbundle, packagerInstance);
|
return bundleWithOutput(argv, config, args, outputUnbundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
Loading…
Reference in New Issue