Skip to content

Separating RN Bundle Generation from Android Gradle Build #887

Open
@FilDevTronic

Description

@FilDevTronic

Introduction

I'm facing a challenge with optimizing our build pipelines and was hoping you might have some insight. Specifically, I'm trying to separate the React Native bundle generation from the main Android Gradle build process so that:

  1. The bundle generation can run as a separate CI job
  2. The resulting bundle, sourcemap, and assets can be cached
  3. These artifacts can then be passed to the Android build jobs

Details

I've tried several approaches:

  • Using react-native bundle directly and moving the generated files to the expected output paths
  • Running just the createBundle Gradle task in a separate CI job
  • Configuring the build.gradle to disable the task when files are present

However, I'm encountering issues with all approaches:

  • Gradle still runs the bundling task instead of marking it UP-TO-DATE
  • R8 fails when the task is disabled, seemingly unable to find main.jar
  • The CI runner-specific metadata seems to prevent Gradle from recognizing pre-existing bundle files

Do you have any recommendations for cleanly separating these concerns in the build process? Is there a better approach I'm overlooking?

I appreciate any guidance you might be able to provide.

Discussion points

  • Splitting the React Native Bundle generation out from the main app building tasks (primarily Android, Gradle; but would also want to do the same for iOS via Xcode)

  • Optimising React Native app
    Building in CI

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions