Skip to content

Commit 8d836a0

Browse files
tjzelm-bert
andcommitted
fix: initializer file not loaded in Expo52 (#6980)
Turns out that `sideEffects` field was ignored and `isWeb()` check evaluated to static false, removing `initializers.ts` from the bundle. Fixes - #6740 - #6839 Tested it on RNGH web example app using Expo52 Co-authored-by: Michał Bert <[email protected]>
1 parent 24d66bc commit 8d836a0

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

packages/react-native-reanimated/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,13 @@
175175
}
176176
},
177177
"sideEffects": [
178+
"./src/layoutReanimation/animationsManager.ts",
178179
"./lib/module/layoutReanimation/animationsManager.js",
180+
"./src/core.ts",
179181
"./lib/module/core.js",
182+
"./src/initializers.ts",
180183
"./lib/module/initializers.js",
184+
"./src/index.ts",
181185
"./lib/module/index.js"
182186
]
183187
}

packages/react-native-reanimated/src/core.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
import { ReanimatedModule } from './ReanimatedModule';
3-
import { isWeb, shouldBeUseWeb, isFabric } from './PlatformChecker';
3+
import { shouldBeUseWeb, isFabric } from './PlatformChecker';
44
import type {
55
AnimatedKeyboardOptions,
66
LayoutAnimationBatchItem,
@@ -11,10 +11,10 @@ import type {
1111
ValueRotation,
1212
WorkletFunction,
1313
} from './commonTypes';
14-
import { makeShareableCloneRecursive } from './shareables';
14+
import { ReanimatedError } from './errors';
1515
import { initializeUIRuntime } from './initializers';
1616
import { SensorContainer } from './SensorContainer';
17-
import { ReanimatedError } from './errors';
17+
import { makeShareableCloneRecursive } from './shareables';
1818

1919
export { startMapper, stopMapper } from './mappers';
2020
export { runOnJS, runOnUI, executeOnUIRuntimeSync } from './threads';
@@ -154,9 +154,7 @@ export function unregisterSensor(sensorId: number): void {
154154
return sensorContainer.unregisterSensor(sensorId);
155155
}
156156

157-
if (!isWeb()) {
158-
initializeUIRuntime(ReanimatedModule);
159-
}
157+
initializeUIRuntime(ReanimatedModule);
160158

161159
type FeaturesConfig = {
162160
enableLayoutAnimations: boolean;

packages/react-native-reanimated/src/initializers.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
'use strict';
22
import { registerReanimatedError, reportFatalErrorOnJS } from './errors';
3-
import { isChromeDebugger, isJest, shouldBeUseWeb } from './PlatformChecker';
3+
import {
4+
isChromeDebugger,
5+
isJest,
6+
isWeb,
7+
shouldBeUseWeb,
8+
} from './PlatformChecker';
49
import {
510
runOnJS,
611
setupMicrotasks,
@@ -180,6 +185,9 @@ function setupRequestAnimationFrame() {
180185
}
181186

182187
export function initializeUIRuntime(ReanimatedModule: IReanimatedModule) {
188+
if (isWeb()) {
189+
return;
190+
}
183191
if (!ReanimatedModule) {
184192
// eslint-disable-next-line reanimated/use-reanimated-error
185193
throw new Error(

0 commit comments

Comments
 (0)