Skip to content

Commit c1c0809

Browse files
committed
Upgrade to React Native 0.70.5
1 parent 1bd4864 commit c1c0809

20 files changed

+122
-72
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-template-cljs-krell-storybook",
3-
"version": "0.1.3",
3+
"version": "0.2.0",
44
"description": "Template providing a working React Native setup for ClojureScript with Krell and Storybook",
55
"scripts": {
66
"test": "exit 0"

template/_flowconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ nonstrict-import=warn
5252
deprecated-type=warn
5353
unsafe-getters-setters=warn
5454
unnecessary-invariant=warn
55-
signature-verification-failure=warn
5655

5756
[strict]
5857
deprecated-type
@@ -64,4 +63,4 @@ untyped-import
6463
untyped-type-import
6564

6665
[version]
67-
^0.170.0
66+
^0.182.0

template/_node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

template/_ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.5

template/android/app/build.gradle

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
7979
*/
8080

8181
project.ext.react = [
82-
enableHermes: false, // clean and rebuild if changing
82+
enableHermes: true, // clean and rebuild if changing
8383
]
8484

8585
apply from: "../../node_modules/react-native/react.gradle"
@@ -143,25 +143,14 @@ android {
143143
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
144144

145145
if (isNewArchitectureEnabled()) {
146-
// We configure the NDK build only if you decide to opt-in for the New Architecture.
146+
// We configure the CMake build only if you decide to opt-in for the New Architecture.
147147
externalNativeBuild {
148-
ndkBuild {
149-
arguments "APP_PLATFORM=android-21",
150-
"APP_STL=c++_shared",
151-
"NDK_TOOLCHAIN_VERSION=clang",
152-
"GENERATED_SRC_DIR=$buildDir/generated/source",
153-
"PROJECT_BUILD_DIR=$buildDir",
154-
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
155-
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build"
156-
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
157-
cppFlags "-std=c++17"
158-
// Make sure this target name is the same you specify inside the
159-
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
160-
targets "projectname_appmodules"
161-
// Fix for windows limit on number of character in file paths and in command lines
162-
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
163-
arguments "NDK_APP_SHORT_COMMANDS=true"
164-
}
148+
cmake {
149+
arguments "-DPROJECT_BUILD_DIR=$buildDir",
150+
"-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
151+
"-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
152+
"-DNODE_MODULES_DIR=$rootDir/../node_modules",
153+
"-DANDROID_STL=c++_shared"
165154
}
166155
}
167156
if (!enableSeparateBuildPerCPUArchitecture) {
@@ -175,8 +164,8 @@ android {
175164
if (isNewArchitectureEnabled()) {
176165
// We configure the NDK build only if you decide to opt-in for the New Architecture.
177166
externalNativeBuild {
178-
ndkBuild {
179-
path "$projectDir/src/main/jni/Android.mk"
167+
cmake {
168+
path "$projectDir/src/main/jni/CMakeLists.txt"
180169
}
181170
}
182171
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
@@ -198,15 +187,15 @@ android {
198187
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
199188

200189
// Due to a bug inside AGP, we have to explicitly set a dependency
201-
// between configureNdkBuild* tasks and the preBuild tasks.
190+
// between configureCMakeDebug* tasks and the preBuild tasks.
202191
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
203-
configureNdkBuildRelease.dependsOn(preReleaseBuild)
204-
configureNdkBuildDebug.dependsOn(preDebugBuild)
192+
configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild)
193+
configureCMakeDebug.dependsOn(preDebugBuild)
205194
reactNativeArchitectures().each { architecture ->
206-
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
195+
tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
207196
dependsOn("preDebugBuild")
208197
}
209-
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
198+
tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
210199
dependsOn("preReleaseBuild")
211200
}
212201
}
@@ -281,9 +270,10 @@ dependencies {
281270
}
282271

283272
if (enableHermes) {
284-
def hermesPath = "../../node_modules/hermes-engine/android/";
285-
debugImplementation files(hermesPath + "hermes-debug.aar")
286-
releaseImplementation files(hermesPath + "hermes-release.aar")
273+
//noinspection GradleDynamicVersion
274+
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
275+
exclude group:'com.facebook.fbjni'
276+
}
287277
} else {
288278
implementation jscFlavor
289279
}
@@ -296,7 +286,11 @@ if (isNewArchitectureEnabled()) {
296286
configurations.all {
297287
resolutionStrategy.dependencySubstitution {
298288
substitute(module("com.facebook.react:react-native"))
299-
.using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source")
289+
.using(project(":ReactAndroid"))
290+
.because("On New Architecture we're building React Native from source")
291+
substitute(module("com.facebook.react:hermes-engine"))
292+
.using(project(":ReactAndroid:hermes-engine"))
293+
.because("On New Architecture we're building Hermes from source")
300294
}
301295
}
302296
}

template/android/app/src/main/java/com/projectname/MainActivity.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ protected String getMainComponentName() {
1717

1818
/**
1919
* Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
20-
* you can specify the rendered you wish to use (Fabric or the older renderer).
20+
* you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer
21+
* (Paper).
2122
*/
2223
@Override
2324
protected ReactActivityDelegate createReactActivityDelegate() {
@@ -36,5 +37,12 @@ protected ReactRootView createRootView() {
3637
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
3738
return reactRootView;
3839
}
40+
41+
@Override
42+
protected boolean isConcurrentRootEnabled() {
43+
// If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18).
44+
// More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
45+
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
46+
}
3947
}
4048
}

template/android/app/src/main/java/com/projectname/newarchitecture/MainApplicationReactNativeHost.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
import com.facebook.react.bridge.UIManager;
1717
import com.facebook.react.fabric.ComponentFactory;
1818
import com.facebook.react.fabric.CoreComponentsRegistry;
19-
import com.facebook.react.fabric.EmptyReactNativeConfig;
2019
import com.facebook.react.fabric.FabricJSIModuleProvider;
20+
import com.facebook.react.fabric.ReactNativeConfig;
2121
import com.facebook.react.uimanager.ViewManagerRegistry;
2222
import com.projectname.BuildConfig;
2323
import com.projectname.newarchitecture.components.MainComponentsRegistry;
@@ -105,7 +105,7 @@ public JSIModuleProvider<UIManager> getJSIModuleProvider() {
105105
return new FabricJSIModuleProvider(
106106
reactApplicationContext,
107107
componentFactory,
108-
new EmptyReactNativeConfig(),
108+
ReactNativeConfig.DEFAULT_CONFIG,
109109
viewManagerRegistry);
110110
}
111111
});

template/android/app/src/main/jni/MainApplicationModuleProvider.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#include "MainApplicationModuleProvider.h"
22

3+
#include <rncli.h>
34
#include <rncore.h>
45

56
namespace facebook {
67
namespace react {
78

89
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
9-
const std::string moduleName,
10+
const std::string &moduleName,
1011
const JavaTurboModule::InitParams &params) {
1112
// Here you can provide your own module provider for TurboModules coming from
1213
// either your application or from external libraries. The approach to follow
@@ -17,6 +18,13 @@ std::shared_ptr<TurboModule> MainApplicationModuleProvider(
1718
// return module;
1819
// }
1920
// return rncore_ModuleProvider(moduleName, params);
21+
22+
// Module providers autolinked by RN CLI
23+
auto rncli_module = rncli_ModuleProvider(moduleName, params);
24+
if (rncli_module != nullptr) {
25+
return rncli_module;
26+
}
27+
2028
return rncore_ModuleProvider(moduleName, params);
2129
}
2230

template/android/app/src/main/jni/MainApplicationModuleProvider.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace facebook {
99
namespace react {
1010

1111
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
12-
const std::string moduleName,
12+
const std::string &moduleName,
1313
const JavaTurboModule::InitParams &params);
1414

1515
} // namespace react

template/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ void MainApplicationTurboModuleManagerDelegate::registerNatives() {
2222

2323
std::shared_ptr<TurboModule>
2424
MainApplicationTurboModuleManagerDelegate::getTurboModule(
25-
const std::string name,
26-
const std::shared_ptr<CallInvoker> jsInvoker) {
25+
const std::string &name,
26+
const std::shared_ptr<CallInvoker> &jsInvoker) {
2727
// Not implemented yet: provide pure-C++ NativeModules here.
2828
return nullptr;
2929
}
3030

3131
std::shared_ptr<TurboModule>
3232
MainApplicationTurboModuleManagerDelegate::getTurboModule(
33-
const std::string name,
33+
const std::string &name,
3434
const JavaTurboModule::InitParams &params) {
3535
return MainApplicationModuleProvider(name, params);
3636
}
3737

3838
bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule(
39-
std::string name) {
39+
const std::string &name) {
4040
return getTurboModule(name, nullptr) != nullptr ||
4141
getTurboModule(name, {.moduleName = name}) != nullptr;
4242
}

0 commit comments

Comments
 (0)