Skip to content

Commit 3cba4c4

Browse files
authored
Remove Paper-only code from Fabric builds of Microsoft.ReactNative (#14289)
## Description Removes most of the Paper-only code from Fabric builds of Microsoft.ReactNative. This is only a first pass - there may be more that needs to be removed (or stuff that needs to be put back in). ### Type of Change - Bug fix (non-breaking change which fixes an issue) - Breaking change (fix or feature that would cause existing functionality to not work as expected) ### Why Besides nearly doubling the size of the binary files, all of the Paper-only code is functionally useless in Fabric builds, which at worse is dead weight, and at best is confusing to developers. Resolves #13405 ### What Updated project files to not load/compile paper-only modules. Updated modules that are used by both to correctly only include the Paper or Fabric code they need. ## Screenshots None, but here are some preliminary binary size numbers for x64 release: | File | Paper | Fabric (Before) | Fabric (After) | |:-|:-:|:-:|:-:| | Microsoft.ReactNative.dll | 4.02 MB | 8.32 MB | 6.47 MB (🔻1.85 MB / 22% ) | | Microsoft.ReactNative.winmd | 64.0 KB | 121.0 KB | 92.0KB (🔻29 KB / 24%) | ## Testing Verified all existing tests still pass and fabric apps work. ## Changelog Should this change be included in the release notes: _yes_ Remove Paper-only code from Fabric builds of Microsoft.ReactNative
1 parent 6620dc0 commit 3cba4c4

31 files changed

+236
-191
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Remove Paper-only code from Fabric builds of Microsoft.ReactNative",
4+
"packageName": "react-native-windows",
5+
"email": "jthysell@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

vnext/Desktop/React.Windows.Desktop.vcxproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@
149149
-->
150150
<PreprocessorDefinitions>CORE_ABI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
151151
</Midl>
152-
<Midl>
153-
<PreprocessorDefinitions Condition="'$(UseFabric)' == 'true'">USE_FABRIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
154-
</Midl>
155152
</ItemDefinitionGroup>
156153
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\ReactCommunity.cpp.props" />
157154
<ItemGroup>

vnext/Microsoft.ReactNative.Cxx/ReactContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct ReactContext {
6565
m_handle.EmitJSEvent(eventEmitterName, eventName, MakeJSValueWriter(std::forward<TArgs>(args)...));
6666
}
6767

68-
#if !defined(CORE_ABI) && !defined(__APPLE__) && !defined(CXXUNITTESTS)
68+
#if !defined(CORE_ABI) && !defined(USE_FABRIC) && !defined(__APPLE__) && !defined(CXXUNITTESTS)
6969
// Dispatch eventName event to the view.
7070
// args are either function arguments or a single lambda with 'IJSValueWriter const&' argument.
7171
template <class... TArgs>

vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <IReactContext.h>
1010
#include <React.h>
1111
#include <Views/DevMenu.h>
12-
#include <Views/ShadowNodeBase.h>
1312
#include <windows.h>
1413
#include <windowsx.h>
1514
#include <winrt/Windows.UI.Core.h>

vnext/Microsoft.ReactNative/IReactContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "pch.h"
55
#include "IReactContext.h"
66
#include "DynamicWriter.h"
7-
#ifndef CORE_ABI
7+
#if !defined(CORE_ABI) && !defined(USE_FABRIC)
88
#include "XamlUIService.h"
99
#endif
1010

@@ -121,7 +121,7 @@ LoadingState ReactContext::LoadingState() noexcept {
121121
};
122122
}
123123

124-
#ifndef CORE_ABI
124+
#if !defined(CORE_ABI) && !defined(USE_FABRIC)
125125
// Deprecated: Use XamlUIService directly.
126126
void ReactContext::DispatchEvent(
127127
xaml::FrameworkElement const &view,

vnext/Microsoft.ReactNative/IReactContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct ReactContext : winrt::implements<ReactContext, IReactContext> {
4646
IInspectable JSRuntime() noexcept;
4747
LoadingState LoadingState() noexcept;
4848

49-
#ifndef CORE_ABI
49+
#if !defined(CORE_ABI) && !defined(USE_FABRIC)
5050
void DispatchEvent(
5151
xaml::FrameworkElement const &view,
5252
hstring const &eventName,

vnext/Microsoft.ReactNative/IReactContext.idl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "IJSValueWriter.idl"; // The import is to be deprecated with IReactContex
55
import "IReactNotificationService.idl";
66
import "IReactPropertyBag.idl";
77

8-
#ifndef CORE_ABI
8+
#if !defined(CORE_ABI) && !defined(USE_FABRIC)
99
#include "NamespaceRedirect.h" // The include is to be deprecated with IReactContext::DispatchEvent
1010
#endif
1111

@@ -185,7 +185,7 @@ namespace Microsoft.ReactNative
185185
"It is an experimental property that may be removed or changed in a future version.")
186186
Object JSRuntime { get; };
187187

188-
#ifndef CORE_ABI
188+
#if !defined(CORE_ABI) && !defined(USE_FABRIC)
189189
[deprecated("Use @XamlUIService.DispatchEvent instead", deprecate, 1)]
190190
DOC_STRING("Deprecated property. Use @XamlUIService.DispatchEvent instead. It will be removed in a future version.")
191191
void DispatchEvent(XAML_NAMESPACE.FrameworkElement view, String eventName, JSValueArgWriter eventDataArgWriter);

vnext/Microsoft.ReactNative/IReactPackageBuilder.idl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import "IReactContext.idl";
55
import "IReactModuleBuilder.idl";
6-
#ifndef CORE_ABI
6+
#if !defined(CORE_ABI) && !defined(USE_FABRIC)
77
import "IViewManager.idl";
88
#endif
99

@@ -14,7 +14,7 @@ namespace Microsoft.ReactNative
1414
DOC_STRING("Provides information about a custom native module. See @IReactModuleBuilder.")
1515
delegate Object ReactModuleProvider(IReactModuleBuilder moduleBuilder);
1616

17-
#ifndef CORE_ABI
17+
#if !defined(CORE_ABI) && !defined(USE_FABRIC)
1818
DOC_STRING("Provides information about a custom view manager. See @IViewManager.")
1919
delegate IViewManager ReactViewManagerProvider();
2020
#endif
@@ -32,7 +32,7 @@ namespace Microsoft.ReactNative
3232
"NOTE: TurboModules using JSI directly will not run correctly while using @ReactInstanceSettings.UseWebDebugger")
3333
void AddTurboModule(String moduleName, ReactModuleProvider moduleProvider);
3434

35-
#ifndef CORE_ABI
35+
#if !defined(CORE_ABI) && !defined(USE_FABRIC)
3636
DOC_STRING("Adds a custom view manager. See @ReactViewManagerProvider.")
3737
void AddViewManager(String viewManagerName, ReactViewManagerProvider viewManagerProvider);
3838
#endif

0 commit comments

Comments
 (0)