Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android template: Allow overriding default "index.js" entry file #26769

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions react.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ import org.apache.tools.ant.taskdefs.condition.Os

def config = project.hasProperty("react") ? project.react : [];

def detectEntryFile(config) {
if (System.getenv('ENTRY_FILE')) {
return System.getenv('ENTRY_FILE')
} else if (config.entryFile) {
return config.entryFile
} else if ((new File("${projectDir}/../../index.android.js")).exists()) {
return "index.android.js"
}

return "index.js";
}

def cliPath = config.cliPath ?: "node_modules/react-native/cli.js"
def composeSourceMapsPath = config.composeSourceMapsPath ?: "node_modules/react-native/scripts/compose-source-maps.js"
def bundleAssetName = config.bundleAssetName ?: "index.android.bundle"
def entryFile = config.entryFile ?: "index.android.js"
def entryFile = detectEntryFile(config)
def bundleCommand = config.bundleCommand ?: "bundle"
def reactRoot = file(config.root ?: "../../")
def inputExcludes = config.inputExcludes ?: ["android/**", "ios/**"]
Expand Down Expand Up @@ -149,7 +161,7 @@ afterEvaluate {
hermesFlags = config.hermesFlagsDebug
if (hermesFlags == null) hermesFlags = []
}

if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine("cmd", "/c", getHermesCommand(), "-emit-binary", "-out", hbcTempFile, jsBundleFile, *hermesFlags)
} else {
Expand Down
5 changes: 3 additions & 2 deletions template/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import com.android.build.OutputFile
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* // the entry file for bundle generation. If none specified and
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
* // default. Can be overridden with ENTRY_FILE environment variable.
* entryFile: "index.android.js",
*
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
Expand Down Expand Up @@ -76,7 +78,6 @@ import com.android.build.OutputFile
*/

project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]

Expand Down