From 58fb91e62bbab1db648725367f5b1af3350a1954 Mon Sep 17 00:00:00 2001 From: Philipp von Weitershausen Date: Sat, 4 Jun 2016 15:57:01 -0700 Subject: [PATCH] Android: allow app/build.gradle to specify how node gets invoked for the packager Summary: **Test plan:** With the given patch applied to `react.gradle`, I specified the following in my `android/app/build.gradle`: ``` project.ext.react = [ nodeExecutableAndArgs: ["node", "--max_old_space_size=4096"] ] ``` and ensured in a `./gradlew installDebug --debug` run that the packager gets indeed invoked with these parameters. Closes https://github.com/facebook/react-native/pull/7903 Differential Revision: D3390543 fbshipit-source-id: cf440b36633420b8f67070f47dfabf4c84cb28a7 --- local-cli/generator-android/templates/src/app/build.gradle | 3 +++ react.gradle | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/local-cli/generator-android/templates/src/app/build.gradle b/local-cli/generator-android/templates/src/app/build.gradle index 11380b0062f60f..63ab2dcbf9c37f 100644 --- a/local-cli/generator-android/templates/src/app/build.gradle +++ b/local-cli/generator-android/templates/src/app/build.gradle @@ -57,6 +57,9 @@ import com.android.build.OutputFile * // for example, you might want to remove it from here. * inputExcludes: ["android/**", "ios/**"], * + * // override which node gets called and with what additional arguments + * nodeExecutableAndArgs: ["node"] + * * // supply additional arguments to the packager * extraPackagerArgs: [] * ] diff --git a/react.gradle b/react.gradle index f52b30c3b284d2..ffa9e48c6d37ed 100644 --- a/react.gradle +++ b/react.gradle @@ -49,7 +49,8 @@ gradle.projectsEvaluated { // Bundle task name for variant def bundleJsAndAssetsTaskName = "bundle${targetName}JsAndAssets" - // Additional packager commandline arguments + // Additional node and packager commandline arguments + def nodeExecutableAndArgs = config.nodeExecutableAndArgs ?: ["node"] def extraPackagerArgs = config.extraPackagerArgs ?: [] def currentBundleTask = tasks.create( @@ -75,10 +76,10 @@ gradle.projectsEvaluated { // Set up dev mode def devEnabled = !targetName.toLowerCase().contains("release") if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine("cmd", "/c", "node", "node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "android", "--dev", "${devEnabled}", + commandLine("cmd", "/c", *nodeExecutableAndArgs, "node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "android", "--dev", "${devEnabled}", "--reset-cache", "true", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, *extraPackagerArgs) } else { - commandLine("node", "node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "android", "--dev", "${devEnabled}", + commandLine(*nodeExecutableAndArgs, "node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "android", "--dev", "${devEnabled}", "--reset-cache", "true", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, *extraPackagerArgs) }