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

fix: Bundle assets in monorepo #26940

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
10 changes: 9 additions & 1 deletion RNTester/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ plugins {
*/

project.ext.react = [
cliPath: "$rootDir/cli.js",
bundleAssetName: "RNTesterApp.android.bundle",
entryFile: file("../../js/RNTesterApp.android.js"),
root: "$rootDir",
Expand Down Expand Up @@ -109,6 +108,15 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @dulmandakh, ideas why @Esemesek needed that for the build to happen? Is this his local env issue, or something reproducible?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kudo will have more details here. We have discussed this and it's known issue in RNTester (I had to set it myself a few times too). It has something to do with the way packages are bundled and distributed, but I don't have enough context into that side of the build system.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pickFirst concern is coming from 3rd party libraries built by different NDK and may depend on different libc++_shared.so. pickFirst cannot be a reliable way to choose which libc++_shared.so will be used.
Some context at: facebook/hermes#74
I was proposing to remove pickFirst especially from RN template.
For RNTester it is somehow acceptable but it would be great if we could not depend on it.

Both JSC and Hermes excluded libc++_shared.so right now.
The libc++_shared.so should come from Flipper.
@willholen did have a PR for that and it seems be fixed from Flipper side.
Maybe upgrade Flipper will fix the conflict issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Kudo an explanation. I will remove this section.

pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
}

flavorDimensions "vm"
productFlavors {
hermes {
Expand Down
25 changes: 16 additions & 9 deletions react.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ afterEvaluate {
def nodeExecutableAndArgs = config.nodeExecutableAndArgs ?: ["node"]
def extraPackagerArgs = config.extraPackagerArgs ?: []

def execCommand = []

if (config.cliPath || config.nodeExecutableAndArgs) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
execCommand.addAll(["cmd", "/c", *nodeExecutableAndArgs, cliPath])
} else {
execCommand.addAll([*nodeExecutableAndArgs, cliPath])
}
} else {
execCommand.addAll(["npx", "react-native"])
Esemesek marked this conversation as resolved.
Show resolved Hide resolved
}

def enableHermes = enableHermesForVariant(variant)

def currentBundleTask = tasks.create(
Expand Down Expand Up @@ -140,15 +152,10 @@ afterEvaluate {
extraArgs.add(bundleConfig);
}

if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine("cmd", "/c", *nodeExecutableAndArgs, cliPath, bundleCommand, "--platform", "android", "--dev", "${devEnabled}",
"--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir,
"--sourcemap-output", enableHermes ? jsPackagerSourceMapFile : jsOutputSourceMapFile, *extraArgs)
} else {
commandLine(*nodeExecutableAndArgs, cliPath, bundleCommand, "--platform", "android", "--dev", "${devEnabled}",
"--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir,
"--sourcemap-output", enableHermes ? jsPackagerSourceMapFile : jsOutputSourceMapFile, *extraArgs)
}
commandLine(*execCommand, bundleCommand, "--platform", "android", "--dev", "${devEnabled}",
"--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir,
"--sourcemap-output", enableHermes ? jsPackagerSourceMapFile : jsOutputSourceMapFile, *extraArgs)


if (enableHermes) {
doLast {
Expand Down