From 64a5b1d9d40397899ca7eab69da62ee504ef4e54 Mon Sep 17 00:00:00 2001 From: Rafael Oleza Date: Fri, 13 Jul 2018 06:12:04 -0700 Subject: [PATCH] Use correct getModulesRunBeforeMainModule config param when building production bundles Summary: This fixes https://github.com/facebook/metro/issues/197 Differential Revision: D8818833 fbshipit-source-id: d80a824bb4fd90ef32104c651aa3c1ecc79ebad9 --- packages/metro/src/Server.js | 18 ++++++++++++------ packages/metro/src/shared/types.flow.js | 1 - 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/metro/src/Server.js b/packages/metro/src/Server.js index 93a7f354f3..8b7a81cbb0 100644 --- a/packages/metro/src/Server.js +++ b/packages/metro/src/Server.js @@ -236,7 +236,9 @@ class Server { createModuleId: this._opts.createModuleId, getRunModuleStatement: this._opts.getRunModuleStatement, dev: options.dev, - runBeforeMainModule: options.runBeforeMainModule, + runBeforeMainModule: this._opts.getModulesRunBeforeMainModule( + path.relative(this._opts.projectRoot, entryPoint), + ), runModule: options.runModule, sourceMapUrl: options.sourceMapUrl, }), @@ -285,7 +287,9 @@ class Server { getRunModuleStatement: this._opts.getRunModuleStatement, getTransformOptions: this._opts.getTransformOptions, platform: options.platform, - runBeforeMainModule: options.runBeforeMainModule, + runBeforeMainModule: this._opts.getModulesRunBeforeMainModule( + path.relative(this._opts.projectRoot, entryPoint), + ), runModule: options.runModule, sourceMapUrl: options.sourceMapUrl, }, @@ -672,7 +676,9 @@ class Server { createModuleId: this._opts.createModuleId, dev: options.dev, getRunModuleStatement: this._opts.getRunModuleStatement, - runBeforeMainModule: options.runBeforeMainModule, + runBeforeMainModule: this._opts.getModulesRunBeforeMainModule( + path.relative(this._opts.projectRoot, options.entryFile), + ), runModule: options.runModule, sourceMapUrl: options.sourceMapUrl, }, @@ -736,7 +742,9 @@ class Server { createModuleId: this._opts.createModuleId, getRunModuleStatement: this._opts.getRunModuleStatement, dev: options.dev, - runBeforeMainModule: options.runBeforeMainModule, + runBeforeMainModule: this._opts.getModulesRunBeforeMainModule( + path.relative(this._opts.projectRoot, options.entryFile), + ), runModule: options.runModule, sourceMapUrl: options.sourceMapUrl, }), @@ -1047,7 +1055,6 @@ class Server { minify, excludeSource, hot: true, - runBeforeMainModule: this._opts.getModulesRunBeforeMainModule(entryFile), runModule: this._getBoolOptionFromQuery(urlObj.query, 'runModule', true), inlineSourceMap: includeSource, platform, @@ -1109,7 +1116,6 @@ class Server { entryModuleOnly: false, excludeSource: false, inlineSourceMap: false, - runBeforeMainModule: [], runModule: true, sourceMapUrl: null, }; diff --git a/packages/metro/src/shared/types.flow.js b/packages/metro/src/shared/types.flow.js index 6259ac76f0..f6e675b6f7 100644 --- a/packages/metro/src/shared/types.flow.js +++ b/packages/metro/src/shared/types.flow.js @@ -51,7 +51,6 @@ export type BundleOptions = { minify: boolean, onProgress: ?(doneCont: number, totalCount: number) => mixed, +platform: ?string, - +runBeforeMainModule: Array, +runModule: boolean, sourceMapUrl: ?string, createModuleIdFactory?: () => (path: string) => number,