Skip to content

[compiler] Preserve JSX pragmas before generated imports#36465

Open
yudin-s wants to merge 1 commit into
facebook:mainfrom
yudin-s:fix-compiler-jsx-pragma-order
Open

[compiler] Preserve JSX pragmas before generated imports#36465
yudin-s wants to merge 1 commit into
facebook:mainfrom
yudin-s:fix-compiler-jsx-pragma-order

Conversation

@yudin-s
Copy link
Copy Markdown

@yudin-s yudin-s commented May 13, 2026

Summary

Fixes #36460.

React Compiler adds a runtime import for compiled functions. When a source file starts with a JSX pragma such as @jsxImportSource, inserting that runtime import at the very start of the program moves the pragma after a code statement in the generated output. Downstream JSX transforms such as Oxc, SWC, and TypeScript only honor these pragmas before code statements.

This preserves leading JSX pragma comments by moving them onto the first generated compiler import before inserting it. Non-JSX leading comments are left on the original first statement, which avoids changing existing compiler fixture output for test-only config comments.

How did you test this change?

  • corepack yarn prettier --check packages/babel-plugin-react-compiler/src/Entrypoint/Imports.ts packages/babel-plugin-react-compiler/src/__tests__/Imports-test.ts
  • corepack yarn jest src/__tests__/Imports-test.ts --runInBand
  • git diff --check

@meta-cla meta-cla Bot added the CLA Signed label May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compiler Bug]: Compiler breaks JSX pragma handling for Oxc/SWC/TS

1 participant