From 3f34f8467fccda644abed0eeb67d9d3a74d4c5e2 Mon Sep 17 00:00:00 2001 From: D N <4661784+retyui@users.noreply.github.com> Date: Tue, 11 Mar 2025 10:33:12 +0100 Subject: [PATCH] feat: Allow to customize reanimated library import name --- .../src/HIR/Environment.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts index b61243f042..b0be943af0 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts @@ -571,6 +571,14 @@ const EnvironmentConfigSchema = z.object({ */ enableCustomTypeDefinitionForReanimated: z.boolean().default(false), + + /** + * The import name of React Native Reanimated library, by default, it's `react-native-reanimated`. + * In case if you use a custom wrapper around the library, you can specify it here, so + * React Compiler will work with Reanimated Babel plugin + */ + reanimatedImportNames: z.array(z.string()).optional(), + /** * If specified, this value is used as a pattern for determing which global values should be * treated as hooks. The pattern should have a single capture group, which will be used as @@ -917,7 +925,11 @@ export class Environment { if (config.enableCustomTypeDefinitionForReanimated) { const reanimatedModuleType = getReanimatedModuleType(this.#shapes); - this.#moduleTypes.set(REANIMATED_MODULE_NAME, reanimatedModuleType); + const reanimatedImportNames: Array = config.reanimatedImportNames ?? [REANIMATED_MODULE_NAME]; + + reanimatedImportNames.forEach((importName) => { + this.#moduleTypes.set(importName, reanimatedModuleType); + }); } this.#contextIdentifiers = contextIdentifiers;