From 543e275d22baac1d6ff50ed3f38787f9b131bdf6 Mon Sep 17 00:00:00 2001 From: Kacper Wiszczuk Date: Mon, 21 Oct 2019 11:58:42 +0200 Subject: [PATCH 1/5] fix: Bundle in monorepo --- react.gradle | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/react.gradle b/react.gradle index 20c183218405ff..2ad3a13c4f611f 100644 --- a/react.gradle +++ b/react.gradle @@ -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"]) + } + def enableHermes = enableHermesForVariant(variant) def currentBundleTask = tasks.create( @@ -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 { From fe81c94814f6f19a6fc210ef81ebd70f3831321d Mon Sep 17 00:00:00 2001 From: Kacper Wiszczuk Date: Mon, 21 Oct 2019 12:40:39 +0200 Subject: [PATCH 2/5] Remove path from RNTester --- RNTester/android/app/build.gradle | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle index db4a066d383fba..8d9b2a25c34016 100644 --- a/RNTester/android/app/build.gradle +++ b/RNTester/android/app/build.gradle @@ -65,7 +65,6 @@ plugins { */ project.ext.react = [ - cliPath: "$rootDir/cli.js", bundleAssetName: "RNTesterApp.android.bundle", entryFile: file("../../js/RNTesterApp.android.js"), root: "$rootDir", @@ -109,6 +108,16 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } + + packagingOptions { + pickFirst 'lib/x86/libc++_shared.so' + 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 { From b7321d72d5e4d422c682fcd58328750989c07ddb Mon Sep 17 00:00:00 2001 From: Kacper Wiszczuk Date: Mon, 21 Oct 2019 12:43:51 +0200 Subject: [PATCH 3/5] Remove whitespace --- RNTester/android/app/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle index 8d9b2a25c34016..1f47a2791f90e9 100644 --- a/RNTester/android/app/build.gradle +++ b/RNTester/android/app/build.gradle @@ -108,7 +108,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - packagingOptions { pickFirst 'lib/x86/libc++_shared.so' pickFirst 'lib/arm64-v8a/libc++_shared.so' From c591b0855719169bb4849a3a2e32726faa66b578 Mon Sep 17 00:00:00 2001 From: Kacper Wiszczuk Date: Mon, 21 Oct 2019 13:05:24 +0200 Subject: [PATCH 4/5] Add Windows compat --- react.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/react.gradle b/react.gradle index 2ad3a13c4f611f..aee91f930a74c0 100644 --- a/react.gradle +++ b/react.gradle @@ -99,6 +99,7 @@ afterEvaluate { // Additional node and packager commandline arguments def nodeExecutableAndArgs = config.nodeExecutableAndArgs ?: ["node"] def extraPackagerArgs = config.extraPackagerArgs ?: [] + def npx = Os.isFamily(Os.FAMILY_WINDOWS) ? "npx.cmd" : "npx" def execCommand = [] @@ -109,7 +110,7 @@ afterEvaluate { execCommand.addAll([*nodeExecutableAndArgs, cliPath]) } } else { - execCommand.addAll(["npx", "react-native"]) + execCommand.addAll([npx, "react-native"]) } def enableHermes = enableHermesForVariant(variant) From 89bed13f85060210a439181a9d4874801c26ea3a Mon Sep 17 00:00:00 2001 From: Kacper Wiszczuk Date: Thu, 31 Oct 2019 19:58:22 +0100 Subject: [PATCH 5/5] Remove pickFirst from packaging options --- RNTester/android/app/build.gradle | 9 --------- 1 file changed, 9 deletions(-) diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle index 1f47a2791f90e9..edac8893b3c390 100644 --- a/RNTester/android/app/build.gradle +++ b/RNTester/android/app/build.gradle @@ -108,15 +108,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - packagingOptions { - pickFirst 'lib/x86/libc++_shared.so' - 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 {