From db47372f06fe945543ce6dc5b7e08ca2dda49032 Mon Sep 17 00:00:00 2001 From: Rafael Oleza Date: Wed, 13 Dec 2017 08:17:36 -0800 Subject: [PATCH] Pass runBeforeMainModule option correctly when building prod bundles Summary: On D6248242, runBeforeMainModule was changed to `getModulesRunBeforeMainModule`, but the entry point used by opensource to build prod bundles was not updated. We couldn't catch this since we don't use this codepath internally Fixes https://github.com/facebook/metro/issues/73 Reviewed By: mjesun Differential Revision: D6556097 fbshipit-source-id: 889eaf825c7c3cdebe1ca4fc9831020a4a7d56dc --- packages/metro/src/Server/__tests__/Server-test.js | 2 +- packages/metro/src/Server/index.js | 3 +++ .../metro/src/integration_tests/__tests__/basic_bundle-test.js | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/metro/src/Server/__tests__/Server-test.js b/packages/metro/src/Server/__tests__/Server-test.js index ef40d1dd..5a3d8a33 100644 --- a/packages/metro/src/Server/__tests__/Server-test.js +++ b/packages/metro/src/Server/__tests__/Server-test.js @@ -439,7 +439,7 @@ describe('processRequest', () => { onProgress: null, platform: undefined, resolutionResponse: null, - runBeforeMainModule: [], + runBeforeMainModule: ['InitializeCore'], runModule: true, sourceMapUrl: null, unbundle: false, diff --git a/packages/metro/src/Server/index.js b/packages/metro/src/Server/index.js index 09be445c..723e4836 100644 --- a/packages/metro/src/Server/index.js +++ b/packages/metro/src/Server/index.js @@ -213,6 +213,9 @@ class Server { options = { ...options, deltaBundleId: null, + runBeforeMainModule: this._opts.getModulesRunBeforeMainModule( + options.entryFile, + ), }; const fullBundle = await Serializers.fullBundle( diff --git a/packages/metro/src/integration_tests/__tests__/basic_bundle-test.js b/packages/metro/src/integration_tests/__tests__/basic_bundle-test.js index 4436fef9..0526492d 100644 --- a/packages/metro/src/integration_tests/__tests__/basic_bundle-test.js +++ b/packages/metro/src/integration_tests/__tests__/basic_bundle-test.js @@ -93,6 +93,7 @@ describe('basic_bundle', () => { const bundleWithPolyfills = await Metro.build( { assetRegistryPath: ASSET_REGISTRY_PATH, + getModulesRunBeforeMainModule: () => ['InitializeCore'], getPolyfills: () => [polyfill1, polyfill2], projectRoots: [INPUT_PATH, POLYFILLS_PATH], transformCache: Metro.TransformCaching.none(), @@ -112,6 +113,7 @@ describe('basic_bundle', () => { const bundleWithoutPolyfills = await Metro.build( { assetRegistryPath: ASSET_REGISTRY_PATH, + getModulesRunBeforeMainModule: () => ['InitializeCore'], getPolyfills: () => [], projectRoots: [INPUT_PATH, POLYFILLS_PATH], transformCache: Metro.TransformCaching.none(),