Make the runBeforeMainModule config param to RN repo and make it absolute
Reviewed By: davidaurelio Differential Revision: D5880700 fbshipit-source-id: 5df6781026030395900388c561283abadefa6511
This commit is contained in:
parent
292b19d339
commit
34487c0591
|
@ -125,6 +125,7 @@ function buildBundle(
|
||||||
providesModuleNodeModules: providesModuleNodeModules,
|
providesModuleNodeModules: providesModuleNodeModules,
|
||||||
resetCache: args.resetCache,
|
resetCache: args.resetCache,
|
||||||
reporter: new TerminalReporter(terminal),
|
reporter: new TerminalReporter(terminal),
|
||||||
|
runBeforeMainModule: config.runBeforeMainModule,
|
||||||
sourceExts: defaultSourceExts.concat(sourceExts),
|
sourceExts: defaultSourceExts.concat(sourceExts),
|
||||||
transformCache: TransformCaching.useTempDir(),
|
transformCache: TransformCaching.useTempDir(),
|
||||||
transformModulePath: transformModulePath,
|
transformModulePath: transformModulePath,
|
||||||
|
|
|
@ -194,6 +194,7 @@ function getPackagerServer(args, config, reporter) {
|
||||||
postProcessModules: config.postProcessModules,
|
postProcessModules: config.postProcessModules,
|
||||||
projectRoots: args.projectRoots,
|
projectRoots: args.projectRoots,
|
||||||
providesModuleNodeModules: providesModuleNodeModules,
|
providesModuleNodeModules: providesModuleNodeModules,
|
||||||
|
runBeforeMainModule: config.runBeforeMainModule,
|
||||||
reporter,
|
reporter,
|
||||||
resetCache: args.resetCache,
|
resetCache: args.resetCache,
|
||||||
sourceExts: defaultSourceExts.concat(args.sourceExts),
|
sourceExts: defaultSourceExts.concat(args.sourceExts),
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
|
* @format
|
||||||
* @flow
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -28,7 +29,9 @@ import type {ConfigT as MetroConfigT} from 'metro-bundler';
|
||||||
export type ConfigT = MetroConfigT;
|
export type ConfigT = MetroConfigT;
|
||||||
|
|
||||||
function getProjectPath() {
|
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.
|
// Packager is running from node_modules.
|
||||||
// This is the default case for all projects created using 'react-native init'.
|
// This is the default case for all projects created using 'react-native init'.
|
||||||
return path.resolve(__dirname, '../../../..');
|
return path.resolve(__dirname, '../../../..');
|
||||||
|
@ -41,10 +44,8 @@ function getProjectPath() {
|
||||||
|
|
||||||
const resolveSymlinksForRoots = roots =>
|
const resolveSymlinksForRoots = roots =>
|
||||||
roots.reduce(
|
roots.reduce(
|
||||||
(arr, rootPath) => arr.concat(
|
(arr, rootPath) => arr.concat(findSymlinkedModules(rootPath, roots)),
|
||||||
findSymlinkedModules(rootPath, roots)
|
[...roots],
|
||||||
),
|
|
||||||
[...roots]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const getProjectRoots = () => {
|
const getProjectRoots = () => {
|
||||||
|
@ -68,6 +69,9 @@ const Config = {
|
||||||
...MetroConfig.DEFAULT,
|
...MetroConfig.DEFAULT,
|
||||||
getProjectRoots,
|
getProjectRoots,
|
||||||
getPolyfills,
|
getPolyfills,
|
||||||
|
runBeforeMainModule: [
|
||||||
|
require.resolve('../../Libraries/Core/InitializeCore'),
|
||||||
|
],
|
||||||
}: ConfigT),
|
}: ConfigT),
|
||||||
|
|
||||||
find(startDir: string): ConfigT {
|
find(startDir: string): ConfigT {
|
||||||
|
@ -86,9 +90,7 @@ const Config = {
|
||||||
|
|
||||||
findOptional(startDir: string): ConfigT {
|
findOptional(startDir: string): ConfigT {
|
||||||
const configPath = findConfigPath(startDir);
|
const configPath = findConfigPath(startDir);
|
||||||
return configPath
|
return configPath ? this.load(configPath, startDir) : {...Config.DEFAULT};
|
||||||
? this.load(configPath, startDir)
|
|
||||||
: {...Config.DEFAULT};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
load(configFile: string): ConfigT {
|
load(configFile: string): ConfigT {
|
||||||
|
@ -105,7 +107,7 @@ function findConfigPath(cwd: string): ?string {
|
||||||
// a file named `filename`
|
// a file named `filename`
|
||||||
function findParentDirectory(currentFullPath, filename) {
|
function findParentDirectory(currentFullPath, filename) {
|
||||||
const root = path.parse(currentFullPath).root;
|
const root = path.parse(currentFullPath).root;
|
||||||
const testDir = (parts) => {
|
const testDir = parts => {
|
||||||
if (parts.length === 0) {
|
if (parts.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* 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
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*
|
||||||
|
* @flow
|
||||||
|
* @format
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue