diff --git a/packages/react-native-reanimated/plugin/build/plugin.js b/packages/react-native-reanimated/plugin/build/plugin.js index 72f5134a6fc..7401a8c40e2 100644 --- a/packages/react-native-reanimated/plugin/build/plugin.js +++ b/packages/react-native-reanimated/plugin/build/plugin.js @@ -1351,9 +1351,9 @@ var require_class = __commonJS({ (0, assert_1.strict)(classPath.node.id); const className = classPath.node.id.name; const polyfilledClassAst = getPolyfilledAst(classPath.node, state); + sortPolyfills(polyfilledClassAst); appendWorkletDirectiveToPolyfills(polyfilledClassAst.program.body); replaceClassDeclarationWithFactoryAndCall(polyfilledClassAst.program.body, className); - sortPolyfills(polyfilledClassAst); polyfilledClassAst.program.body.push((0, types_12.returnStatement)((0, types_12.identifier)(className))); const factoryFactory = (0, types_12.functionExpression)(null, [], (0, types_12.blockStatement)([...polyfilledClassAst.program.body])); const factoryCall = (0, types_12.callExpression)(factoryFactory, []); diff --git a/packages/react-native-reanimated/plugin/src/class.ts b/packages/react-native-reanimated/plugin/src/class.ts index ad7a552c1c9..88e5dd1c8ab 100644 --- a/packages/react-native-reanimated/plugin/src/class.ts +++ b/packages/react-native-reanimated/plugin/src/class.ts @@ -68,6 +68,8 @@ function processClass( const polyfilledClassAst = getPolyfilledAst(classPath.node, state); + sortPolyfills(polyfilledClassAst); + appendWorkletDirectiveToPolyfills(polyfilledClassAst.program.body); replaceClassDeclarationWithFactoryAndCall( @@ -75,8 +77,6 @@ function processClass( className ); - sortPolyfills(polyfilledClassAst); - polyfilledClassAst.program.body.push(returnStatement(identifier(className))); const factoryFactory = functionExpression(