Skip to content

Commit

Permalink
Android: allow app/build.gradle to specify how node gets invoked for …
Browse files Browse the repository at this point in the history
…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 #7903

Differential Revision: D3390543

fbshipit-source-id: cf440b36633420b8f67070f47dfabf4c84cb28a7
  • Loading branch information
philikon authored and Facebook Github Bot 8 committed Jun 4, 2016
1 parent 28b16dd commit 58fb91e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions local-cli/generator-android/templates/src/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
* ]
Expand Down
7 changes: 4 additions & 3 deletions react.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
}

Expand Down

0 comments on commit 58fb91e

Please sign in to comment.