Permalink
Browse files

Make the runBeforeMainModule config param to RN repo and make it abso…

…lute

Reviewed By: davidaurelio

Differential Revision: D5880700

fbshipit-source-id: 5df6781026030395900388c561283abadefa6511
  • Loading branch information...
rafeca authored and facebook-github-bot committed Sep 26, 2017
1 parent 292b19d commit 34487c059192129db07608af4eb27cfad22b2d06
Showing with 16 additions and 9 deletions.
  1. +1 −0 local-cli/bundle/buildBundle.js
  2. +1 −0 local-cli/server/runServer.js
  3. +11 −9 local-cli/util/Config.js
  4. +3 −0 rn-cli.config.js
@@ -125,6 +125,7 @@ function buildBundle(
providesModuleNodeModules: providesModuleNodeModules,
resetCache: args.resetCache,
reporter: new TerminalReporter(terminal),
runBeforeMainModule: config.runBeforeMainModule,
sourceExts: defaultSourceExts.concat(sourceExts),
transformCache: TransformCaching.useTempDir(),
transformModulePath: transformModulePath,
@@ -194,6 +194,7 @@ function getPackagerServer(args, config, reporter) {
postProcessModules: config.postProcessModules,
projectRoots: args.projectRoots,
providesModuleNodeModules: providesModuleNodeModules,
runBeforeMainModule: config.runBeforeMainModule,
reporter,
resetCache: args.resetCache,
sourceExts: defaultSourceExts.concat(args.sourceExts),
View
@@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
* @flow
*/
'use strict';
@@ -28,7 +29,9 @@ import type {ConfigT as MetroConfigT} from 'metro-bundler';
export type ConfigT = MetroConfigT;
function getProjectPath() {
if (__dirname.match(/node_modules[\/\\]react-native[\/\\]local-cli[\/\\]util$/)) {
if (
__dirname.match(/node_modules[\/\\]react-native[\/\\]local-cli[\/\\]util$/)
) {
// Packager is running from node_modules.
// This is the default case for all projects created using 'react-native init'.
return path.resolve(__dirname, '../../../..');
@@ -41,10 +44,8 @@ function getProjectPath() {
const resolveSymlinksForRoots = roots =>
roots.reduce(
(arr, rootPath) => arr.concat(
findSymlinkedModules(rootPath, roots)
),
[...roots]
(arr, rootPath) => arr.concat(findSymlinkedModules(rootPath, roots)),
[...roots],
);
const getProjectRoots = () => {
@@ -68,6 +69,9 @@ const Config = {
...MetroConfig.DEFAULT,
getProjectRoots,
getPolyfills,
runBeforeMainModule: [
require.resolve('../../Libraries/Core/InitializeCore'),
],
}: ConfigT),
find(startDir: string): ConfigT {
@@ -86,9 +90,7 @@ const Config = {
findOptional(startDir: string): ConfigT {
const configPath = findConfigPath(startDir);
return configPath
? this.load(configPath, startDir)
: {...Config.DEFAULT};
return configPath ? this.load(configPath, startDir) : {...Config.DEFAULT};
},
load(configFile: string): ConfigT {
@@ -105,7 +107,7 @@ function findConfigPath(cwd: string): ?string {
// a file named `filename`
function findParentDirectory(currentFullPath, filename) {
const root = path.parse(currentFullPath).root;
const testDir = (parts) => {
const testDir = parts => {
if (parts.length === 0) {
return null;
}
View
@@ -5,6 +5,9 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @format
*/
'use strict';

0 comments on commit 34487c0

Please sign in to comment.