mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fix: Bundle assets in monorepo (#26940)
Summary: In monorepo environment, `metro` isn't able to resolve `react-native` because the path to it is hardcoded. I've also added `packagingOptions` to RNTester to make Android builds work for me. Let me know if this is something that is only specific to my setup, and shouldn't be added. ## Changelog [Android] [Fixed] - Fix `bundleReleaseJsAndAssets` in monorepo env Pull Request resolved: https://github.com/facebook/react-native/pull/26940 Test Plan: - [x] - Works in monorepo setup on MacOS - [x] - Works with RNTester app Differential Revision: D18323703 Pulled By: cpojer fbshipit-source-id: b8eb15dfd8a32ae11fd862fc725af9cffea2cf96
This commit is contained in:
@@ -64,7 +64,6 @@ plugins {
|
||||
*/
|
||||
|
||||
project.ext.react = [
|
||||
cliPath: "$rootDir/cli.js",
|
||||
bundleAssetName: "RNTesterApp.android.bundle",
|
||||
entryFile: file("../../js/RNTesterApp.android.js"),
|
||||
root: "$rootDir",
|
||||
|
||||
+17
-9
@@ -85,6 +85,19 @@ 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 = []
|
||||
|
||||
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)
|
||||
|
||||
@@ -126,15 +139,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 {
|
||||
|
||||
Reference in New Issue
Block a user