Skip to content

RN@0.75.4 codegenNativeComponent build Error #54161

Description

@Yemomo511

Description

I'm trying to upgrade my NativeComponent to Fabric Component. My project is built by the Rollup. When I use codegenNativeComponent and try to build it, I encounter the following Error, which seems that rollup is unable to build the flow syntax

I'm very puzzled as to why I don't have this problem when using TurboModuleRegistry, but a build error occurs when using codegenNativeComponent

  • Terminal Cli:
    rollup -c rollup.config.mjs --bundleConfigAsCjs

rollup.config.mjs

export default defineConfig({
input: 'src/index.ts',
output: [
{
file: 'lib/commonjs/index.js',
format: 'cjs',
plugins: [],
},
{
file: 'lib/module/index.js',
format: 'esm',
},
],
external: ['react-native', 'react', 'react/jsx-runtime'],
plugins: [
//
nodeResolve(),
commonjs(),
typescript({tsconfig: 'tsconfig.build.json'}),
],
});

Steps to reproduce

  1. create XXXNativeComponent.ts and use codegenNativeComponent
  2. use rollup build repo
  3. occur Error

React Native Version

0.75.4

Affected Platforms

Runtime - iOS

Areas

Codegen, Fabric - The New Renderer

Output of npx @react-native-community/cli info

noneSystem:
  OS: macOS 15.6.1
  CPU: (14) arm64 Apple M4 Pro
  Memory: 300.75 MB / 48.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.19.1
    path: /Users/username/.nvm/versions/node/v20.19.1/bin/node
  Yarn: Not Found
  npm:
    version: 10.8.2
    path: /Users/username/.nvm/versions/node/v20.19.1/bin/npm
  Watchman:
    version: 2025.09.08.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.0
      - iOS 26.0
      - macOS 26.0
      - tvOS 26.0
      - visionOS 26.0
      - watchOS 26.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2513.14007798
  Xcode:
    version: 26.0.1/17A400
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.16
    path: /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native:
    installed: 0.74.7
    wanted: ^0.74.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: false
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

info React Native v0.82.0 is now available (your project is running on v0.74.7).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.82.0
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.74.7&to=0.82.0
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".

Stacktrace or Logs

`RollupError: Expected ',', got '{'  in repo/node_modules/.pnpm/react-native@0.74.7_@babel+core@7.28.0_@babel+preset-env@7.28.0_@babel+core@7.28.0__@types+react@18.3.23_react@19.1.0/node_modules/react-native/Libraries/Utilities/codegenNativeComponent.js

../../node_modules/.pnpm/react-native@0.74.7_@babel+core@7.28.0_@babel+preset-env@7.28.0_@babel+core@7.28.0__@types+react@18.3.23_react@19.1.0/node_modules/react-native/Libraries/Utilities/codegenNativeComponent.js (13:12)
11: // TODO: move this file to shims/ReactNative (requires React update and sync)
12: 
13: import type {HostComponent} from '../../Libraries/Renderer/shims/ReactNativeTypes';
                ^
14: 
15: import requireNativeComponent from '../../Libraries/ReactNative/requireNativeComponent';
    at getRollupError ({repo}/node_modules/.pnpm/rollup@4.44.2/node_modules/rollup/dist/shared/parseAst.js:285:41)
    at convertProgram ({repo}/node_modules/.pnpm/rollup@4.44.2/node_modules/rollup/dist/shared/parseAst.js:1152:26)
    at parseAst (repo/node_modules/.pnpm/rollup@4.44.2/node_modules/rollup/dist/shared/parseAst.js:2137:87)
    at tryParse (repo/node_modules/.pnpm/@rollup+plugin-commonjs@26.0.3_rollup@4.44.2/node_modules/@rollup/plugin-commonjs/dist/cjs/index.js:21:12)
    at analyzeTopLevelStatements (repo/node_modules/.pnpm/@rollup+plugin-commonjs@26.0.3_rollup@4.44.2/node_modules/@rollup/plugin-commonjs/dist/cjs/index.js:41:15)
    at Object.transformAndCheckExports (repo/node_modules/.pnpm/@rollup+plugin-commonjs@26.0.3_rollup@4.44.2/node_modules/@rollup/plugin-commonjs/dist/cjs/index.js:2096:68)
    at Object.transform (repo/node_modules/.pnpm/@rollup+plugin-commonjs@26.0.3_rollup@4.44.2/node_modules/@rollup/plugin-commonjs/dist/cjs/index.js:2296:41)
    at repo/node_modules/.pnpm/rollup@4.44.2/node_modules/rollup/dist/shared/rollup.js:3391:40`

MANDATORY Reproducer

none

Screenshots and Videos

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions