Skip to content

Commit

Permalink
Make the runBeforeMainModule config param to RN repo and make it abso…
Browse files Browse the repository at this point in the history
…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 34487c0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions local-cli/bundle/buildBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions local-cli/server/runServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
20 changes: 11 additions & 9 deletions local-cli/util/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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, '../../../..');
Expand All @@ -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 = () => {
Expand All @@ -68,6 +69,9 @@ const Config = {
...MetroConfig.DEFAULT,
getProjectRoots,
getPolyfills,
runBeforeMainModule: [
require.resolve('../../Libraries/Core/InitializeCore'),
],
}: ConfigT),

find(startDir: string): ConfigT {
Expand All @@ -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 {
Expand All @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions rn-cli.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit 34487c0

Please sign in to comment.