From 683c8ddad899efa86946fe51df0b9a4a987caf1b Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Thu, 25 May 2017 10:11:17 -0700 Subject: [PATCH] Allow RAM bundle output Summary: Hooks up indexed RAM bundle output for the build. Reviewed By: jeanlauliac Differential Revision: D5121515 fbshipit-source-id: 47a540d8ec016a36e21e1daa2876f582dbdb8504 --- packages/metro-bundler/src/ModuleGraph/ModuleGraph.js | 8 ++++++-- packages/metro-bundler/src/ModuleGraph/types.flow.js | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/metro-bundler/src/ModuleGraph/ModuleGraph.js b/packages/metro-bundler/src/ModuleGraph/ModuleGraph.js index 9b29505d..3c00b69c 100644 --- a/packages/metro-bundler/src/ModuleGraph/ModuleGraph.js +++ b/packages/metro-bundler/src/ModuleGraph/ModuleGraph.js @@ -17,6 +17,7 @@ const seq = require('async/seq'); const virtualModule = require('./module').virtual; import type { + BuildResult, Callback, GraphFn, GraphResult, @@ -27,7 +28,7 @@ import type { type BuildFn = ( entryPoints: Iterable, options: BuildOptions, - callback: Callback, + callback: Callback, ) => void; type BuildOptions = {| @@ -86,9 +87,12 @@ exports.createBuildSetup = ( polyfills, } = nullthrows(result); + const preludeScript = prelude(optimize); + const prependedScripts = [preludeScript, ...moduleSystem, ...polyfills]; callback(null, { entryModules, - modules: concat([prelude(optimize)], moduleSystem, polyfills, modules), + modules: concat(prependedScripts, modules), + prependedScripts, }); }); }; diff --git a/packages/metro-bundler/src/ModuleGraph/types.flow.js b/packages/metro-bundler/src/ModuleGraph/types.flow.js index 4f66d303..b75b6655 100644 --- a/packages/metro-bundler/src/ModuleGraph/types.flow.js +++ b/packages/metro-bundler/src/ModuleGraph/types.flow.js @@ -15,6 +15,11 @@ import type {Ast} from 'babel-core'; import type {Console} from 'console'; export type {Transformer} from '../JSTransformer/worker/worker.js'; +export type BuildResult = {| + ...GraphResult, + prependedScripts: $ReadOnlyArray, +|}; + export type Callback = (Error => void) & ((null | void, A, B) => void);