diff --git a/packages/metro-bundler/src/Config.js b/packages/metro-bundler/src/Config.js index ca98aeaa..f892da9a 100644 --- a/packages/metro-bundler/src/Config.js +++ b/packages/metro-bundler/src/Config.js @@ -27,6 +27,8 @@ import type {TransformVariants} from './ModuleGraph/types.flow'; import type {HasteImpl} from './node-haste/Module'; export type ConfigT = { + assetRegistryPath: string, + extraNodeModules: {[id: string]: string}, /** * Specify any additional asset file extensions to be used by the packager. @@ -140,6 +142,7 @@ export type ConfigT = { }; const DEFAULT = ({ + assetRegistryPath: 'missing-asset-registry-path', extraNodeModules: {}, assetTransforms: false, getAssetExts: () => [], diff --git a/packages/metro-bundler/src/index.js b/packages/metro-bundler/src/index.js index 4d6bc54e..0e1e99d1 100644 --- a/packages/metro-bundler/src/index.js +++ b/packages/metro-bundler/src/index.js @@ -74,7 +74,7 @@ async function asyncRealpath(path): Promise { async function runMetro({ config, maxWorkers = 1, - projectRoots, + projectRoots = [], watch = false, }: PrivateMetroOptions) { const normalizedConfig = config ? normalizeConfig(config) : DEFAULT_CONFIG; @@ -97,7 +97,7 @@ async function runMetro({ const serverOptions: ServerOptions = { assetExts: defaultAssetExts.concat(assetExts), - assetRegistryPath: `invalid`, + assetRegistryPath: normalizedConfig.assetRegistryPath, blacklistRE: normalizedConfig.getBlacklistRE(), extraNodeModules: normalizedConfig.extraNodeModules, getPolyfills: normalizedConfig.getPolyfills, @@ -237,12 +237,13 @@ exports.runBuild = async (options: RunBuildOptions) => { const metroBundle = await MetroBundler.build(metroServer, requestOptions); const outputOptions: OutputOptions = { - bundleOutput: options.out, + bundleOutput: options.out.replace(/(\.js)?$/, '.js'), dev: options.dev, platform: options.platform || `web`, }; await MetroBundler.save(metroBundle, outputOptions, console.log); + await metroServer.end(); return {metroServer, metroBundle}; };