Skip to content

Commit 32615b9

Browse files
javachemeta-codesync[bot]
authored andcommitted
Restructure core dependencies to avoid cxxreact and fabric (#54446)
Summary: Pull Request resolved: #54446 Changelog: [Internal] Differential Revision: D86515326
1 parent a9b11c6 commit 32615b9

28 files changed

Lines changed: 319 additions & 234 deletions

File tree

packages/react-native/Package.swift

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ let reactDebug = RNTarget(
9696
path: "ReactCommon/react/debug",
9797
dependencies: [.reactNativeDependencies]
9898
)
99+
99100
/// React-jsi.podspec
100101
let jsi = RNTarget(
101102
name: .jsi,
@@ -192,13 +193,29 @@ let reactJsInspector = RNTarget(
192193
]
193194
)
194195

196+
/// React-Bridging.podspec
197+
let reactTurboModuleBridging = RNTarget(
198+
name: .reactTurboModuleBridging,
199+
path: "ReactCommon/react/bridging",
200+
excludedPaths: ["tests"],
201+
dependencies: [.reactNativeDependencies, .reactPerfLogger, .jsi]
202+
)
203+
204+
/// React-jserrorhandler.podspec
205+
let reactJsErrorHandler = RNTarget(
206+
name: .reactJsErrorHandler,
207+
path: "ReactCommon/jserrorhandler",
208+
excludedPaths: ["tests"],
209+
dependencies: [.reactNativeDependencies, .jsi, .reactFeatureFlags, .reactDebug, .reactTurboModuleBridging]
210+
)
211+
195212
/// React-cxxreact.podspec
196213
let reactCxxReact = RNTarget(
197214
name: .reactCxxReact,
198215
path: "ReactCommon/cxxreact",
199216
searchPaths: [CallInvokerPath],
200217
excludedPaths: ["tests"],
201-
dependencies: [.reactNativeDependencies, .jsi, .reactPerfLogger, .logger, .reactDebug, .reactJsInspector]
218+
dependencies: [.reactNativeDependencies, .jsi, .reactJsErrorHandler, .reactPerfLogger, .logger, .reactDebug, .reactJsInspector]
202219
)
203220

204221
/// React-jsitooling.podspec
@@ -243,40 +260,23 @@ let reactPerformanceCdpMetrics = RNTarget(
243260
name: .reactPerformanceCdpMetrics,
244261
path: "ReactCommon/react/performance/cdpmetrics",
245262
excludedPaths: ["tests"],
246-
dependencies: [.reactNativeDependencies, .reactCxxReact, .jsi, .reactPerformanceTimeline, .reactRuntimeExecutor]
263+
dependencies: [.reactNativeDependencies, .jsi, .reactPerformanceTimeline, .reactRuntimeExecutor]
247264
)
248265

249266
/// React-performancetimeline.podspec
250267
let reactPerformanceTimeline = RNTarget(
251268
name: .reactPerformanceTimeline,
252269
path: "ReactCommon/react/performance/timeline",
253270
excludedPaths: ["tests"],
254-
dependencies: [.reactNativeDependencies, .reactFeatureFlags, .reactJsInspectorTracing, .reactCxxReact, .reactPerfLogger]
271+
dependencies: [.reactNativeDependencies, .reactFeatureFlags, .reactJsInspectorTracing, .reactPerfLogger]
255272
)
256273

257274
/// React-runtimescheduler.podspec
258275
let reactRuntimeScheduler = RNTarget(
259276
name: .reactRuntimeScheduler,
260277
path: "ReactCommon/react/renderer/runtimescheduler",
261278
excludedPaths: ["tests"],
262-
dependencies: [.reactNativeDependencies, .reactFeatureFlags, .reactCxxReact, .reactPerfLogger, .reactPerformanceTimeline, .reactRendererConsistency, .reactUtils, .reactRuntimeExecutor]
263-
)
264-
265-
/// ReactCommon.podspec
266-
/// This target represent the ReactCommon/turbomodule/bridging subspec
267-
let reactTurboModuleBridging = RNTarget(
268-
name: .reactTurboModuleBridging,
269-
path: "ReactCommon/react/bridging",
270-
excludedPaths: ["tests"],
271-
dependencies: [.reactNativeDependencies, .reactPerfLogger, .reactCxxReact, .jsi, .logger]
272-
)
273-
274-
/// React-jserrorhandler.podspec
275-
let reactJsErrorHandler = RNTarget(
276-
name: .reactJsErrorHandler,
277-
path: "ReactCommon/jserrorhandler",
278-
excludedPaths: ["tests"],
279-
dependencies: [.reactNativeDependencies, .jsi, .reactCxxReact, .reactFeatureFlags, .reactDebug, .reactTurboModuleBridging]
279+
dependencies: [.reactNativeDependencies, .reactJsErrorHandler, .reactFeatureFlags, .reactCxxReact, .reactPerfLogger, .reactPerformanceTimeline, .reactRendererConsistency, .reactUtils, .reactRuntimeExecutor]
280280
)
281281

282282
/// React-graphicsApple
@@ -871,7 +871,7 @@ extension String {
871871
static let reactRCTActionSheet = "React-RCTActionSheet" // Empty target
872872
static let reactRCTLinking = "React-RCTLinking"
873873
static let reactCoreModules = "React-CoreModules"
874-
static let reactTurboModuleBridging = "ReactCommon/turbomodule/bridging"
874+
static let reactTurboModuleBridging = "React-Bridging"
875875
static let reactTurboModuleCore = "ReactCommon/turbomodule/core"
876876
static let reactTurboModuleCoreDefaults = "ReactCommon/turbomodule/core/defaults"
877877
static let reactTurboModuleCoreMicrotasks = "ReactCommon/turbomodule/core/microtasks"

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TransformHelper.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ package com.facebook.react.uimanager
99

1010
import com.facebook.common.logging.FLog
1111
import com.facebook.react.bridge.NativeArray
12+
import com.facebook.react.bridge.ReactNativeJNISoLoader
1213
import com.facebook.react.bridge.ReadableArray
1314
import com.facebook.react.bridge.ReadableMap
1415
import com.facebook.react.bridge.ReadableType
1516
import com.facebook.react.common.ReactConstants
1617
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
1718

1819
public object TransformHelper {
20+
init {
21+
ReactNativeJNISoLoader.staticInit()
22+
}
1923

2024
private val helperMatrix: ThreadLocal<DoubleArray> =
2125
object : ThreadLocal<DoubleArray>() {

packages/react-native/ReactAndroid/src/main/jni/react/jni/OnLoad-common.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "JReactMarker.h"
1212
#include "NativeArray.h"
1313
#include "NativeMap.h"
14-
#include "TransformHelper.h"
1514
#include "WritableNativeArray.h"
1615
#include "WritableNativeMap.h"
1716

@@ -28,7 +27,6 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
2827
ReadableNativeMap::registerNatives();
2928
WritableNativeArray::registerNatives();
3029
WritableNativeMap::registerNatives();
31-
TransformHelper::registerNatives();
3230
});
3331
}
3432

packages/react-native/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "InspectorNetworkRequestListener.h"
1515
#include "JavaScriptExecutorHolder.h"
1616
#include "ReactInstanceManagerInspectorTarget.h"
17+
#include "TransformHelper.h"
1718

1819
#ifndef WITH_GLOGINIT
1920
#define WITH_GLOGINIT 1
@@ -43,6 +44,7 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
4344
#endif
4445
ReactInstanceManagerInspectorTarget::registerNatives();
4546
InspectorNetworkRequestListener::registerNatives();
47+
TransformHelper::registerNatives();
4648
});
4749
}
4850

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
require "json"
7+
8+
package = JSON.parse(File.read(File.join(__dir__, "..", "package.json")))
9+
version = package['version']
10+
11+
source = { :git => 'https://github.com/facebook/react-native.git' }
12+
if version == '1000.0.0'
13+
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
14+
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
15+
else
16+
source[:tag] = "v#{version}"
17+
end
18+
19+
Pod::Spec.new do |s|
20+
s.name = "React-Bridging"
21+
s.module_name = "React-Bridging"
22+
s.version = version
23+
s.summary = "-" # TODO
24+
s.homepage = "https://reactnative.dev/"
25+
s.license = package["license"]
26+
s.author = "Meta Platforms, Inc. and its affiliates"
27+
s.platforms = min_supported_versions
28+
s.source = source
29+
s.header_dir = "ReactCommon" # Use global header_dir for all subspecs for use_frameworks! compatibility
30+
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/React-Core\"",
31+
"USE_HEADERMAP" => "YES",
32+
"DEFINES_MODULE" => "YES",
33+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
34+
"GCC_WARN_PEDANTIC" => "YES" }
35+
36+
resolve_use_frameworks(s, header_mappings_dir: './')
37+
38+
add_rn_third_party_dependencies(s)
39+
40+
s.source_files = podspec_sources("react/bridging/**/*.{cpp,h}", "react/bridging/**/*.h")
41+
s.exclude_files = "react/bridging/tests"
42+
s.header_dir = "react/bridging"
43+
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\"" }
44+
45+
s.dependency "React-jsi", version
46+
s.dependency "React-callinvoker", version
47+
s.dependency "React-perflogger", version
48+
if use_hermes()
49+
s.dependency "hermes-engine"
50+
end
51+
end

packages/react-native/ReactCommon/ReactCommon.podspec renamed to packages/react-native/ReactCommon/React-TurboModule.podspec

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,24 @@ Pod::Spec.new do |s|
4141
# TODO (T48588859): Restructure this target to align with dir structure: "react/nativemodule/..."
4242
# Note: Update this only when ready to minimize breaking changes.
4343
s.subspec "turbomodule" do |ss|
44-
ss.dependency "React-callinvoker", version
45-
ss.dependency "React-perflogger", version
46-
ss.dependency "React-cxxreact", version
47-
ss.dependency "React-jsi", version
48-
ss.dependency "React-logger", version
49-
if use_hermes()
50-
ss.dependency "hermes-engine"
51-
end
52-
53-
ss.subspec "bridging" do |sss|
54-
sss.dependency "React-jsi", version
55-
sss.source_files = podspec_sources("react/bridging/**/*.{cpp,h}", "react/bridging/**/*.h")
56-
sss.exclude_files = "react/bridging/tests"
57-
sss.header_dir = "react/bridging"
58-
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\"" }
59-
if use_hermes()
60-
sss.dependency "hermes-engine"
61-
end
62-
end
63-
6444
ss.subspec "core" do |sss|
6545
sss.source_files = podspec_sources("react/nativemodule/core/ReactCommon/**/*.{cpp,h}", "react/nativemodule/core/ReactCommon/**/*.h")
6646
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_debug.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_featureflags.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers\"" }
47+
48+
sss.dependency "React-cxxreact", version
6749
sss.dependency "React-debug", version
6850
sss.dependency "React-featureflags", version
51+
sss.dependency "React-logger", version
52+
sss.dependency "React-jsi", version
6953
sss.dependency "React-utils", version
54+
if use_hermes()
55+
sss.dependency "hermes-engine"
56+
end
57+
end
58+
59+
# Provided for backwards compat, use React-Bridging instead
60+
ss.subspec "bridging" do |sss|
61+
sss.dependency "React-Bridging", version
7062
end
7163
end
7264
end

packages/react-native/ReactCommon/cxxreact/ErrorUtils.h

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,6 @@
77

88
#pragma once
99

10-
#include <jsi/jsi.h>
10+
#warning Deprecated: use <jserrorhandler/ErrorUtils.h> instead.
1111

12-
namespace facebook::react {
13-
14-
inline static void handleJSError(jsi::Runtime &runtime, const jsi::JSError &error, bool isFatal)
15-
{
16-
auto errorUtils = runtime.global().getProperty(runtime, "ErrorUtils");
17-
if (errorUtils.isUndefined() || !errorUtils.isObject() ||
18-
!errorUtils.getObject(runtime).hasProperty(runtime, "reportFatalError") ||
19-
!errorUtils.getObject(runtime).hasProperty(runtime, "reportError")) {
20-
// ErrorUtils was not set up. This probably means the bundle didn't
21-
// load properly.
22-
throw jsi::JSError(
23-
runtime,
24-
"ErrorUtils is not set up properly. Something probably went wrong trying to load the JS bundle. Trying to report error " +
25-
error.getMessage(),
26-
error.getStack());
27-
}
28-
29-
// TODO(janzer): Rewrite this function to return the processed error
30-
// instead of just reporting it through the native module
31-
if (isFatal) {
32-
auto func = errorUtils.asObject(runtime).getPropertyAsFunction(runtime, "reportFatalError");
33-
34-
func.call(runtime, error.value());
35-
} else {
36-
auto func = errorUtils.asObject(runtime).getPropertyAsFunction(runtime, "reportError");
37-
38-
func.call(runtime, error.value());
39-
}
40-
}
41-
42-
} // namespace facebook::react
12+
#include <jserrorhandler/ErrorUtils.h>

packages/react-native/ReactCommon/cxxreact/Instance.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@
99

1010
#ifndef RCT_REMOVE_LEGACY_ARCH
1111

12-
#include "ErrorUtils.h"
12+
#include <jserrorhandler/ErrorUtils.h>
1313
#include "JSBigString.h"
14-
#include "JSBundleType.h"
1514
#include "JSExecutor.h"
1615
#include "MessageQueueThread.h"
17-
#include "MethodCall.h"
1816
#include "NativeToJsBridge.h"
1917
#include "RAMBundleRegistry.h"
20-
#include "RecoverableError.h"
2118
#include "TraceSection.h"
2219

2320
#include <cxxreact/JSIndexedRAMBundle.h>
@@ -27,7 +24,6 @@
2724
#include <glog/logging.h>
2825

2926
#include <condition_variable>
30-
#include <exception>
3127
#include <memory>
3228
#include <mutex>
3329
#include <string>

0 commit comments

Comments
 (0)