Enabling React Compiler breaks JSX pragma handling

未关闭
#1,224 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
react, typescript
领域
frontend, tooling

调研方向

先运行链接的 StackBlitz 复现,然后检查 plugin-react 的 React Compiler 集成及其对 JSX pragma 的处理。当启用 React Compiler 后仍能保留 JSX pragma 的行为(包括使用自定义 JSX 或 Emotion css prop),且复现不再失败时,该问题即得到解决。

由索引模型根据 Issue 内容生成。

描述

bug: upstream plugin: react
Related plugins
Describe the bug

React Compiler integration, as documented by the plugin, is not compatible with JSX pragma usage (e.g Emotion css prop).

React Compiler adds an import statement at the top of the file (playground).

This causes Oxc to skip the pragma (playground).

Interestingly, Babel handles this case fine (playground), while TypeScript matches Oxc's behavior (playground).

Reproduction

https://stackblitz.com/edit/vitejs-vite-9eantx6h

Steps to reproduce

No response

System Info
System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 22.22.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @vitejs/plugin-react: ^6.0.1 => 6.0.1 
    vite: ^8.0.12 => 8.0.12
Used Package Manager

npm

Logs

No response

Validations
主要语言
TypeScript
星标
1.2k
派生
287
平均合并
1 天 17 小时
30 天内合并 PR
19

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

vitejs/vite-plugin-react 的其他 Issue

查看 vitejs/vite-plugin-react 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。