Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(plugin-react): honor explicit all-mode compilation - #1624

Open
Cynnamoroll wants to merge 1 commit into
vitejs:mainfrom
Cynnamoroll:fix/react-compiler-all-mode
Open

Cynnamoroll wants to merge 1 commit into
vitejs:mainfrom
Cynnamoroll:fix/react-compiler-all-mode

Conversation

@Cynnamoroll

Copy link
Copy Markdown

With compilationMode: 'all', a top-level anonymous default component such as export default ({ name }) => <div>{name}</div> was skipped by both the native plugin and the Babel preset. Its source doesn't match the heuristic used to find component and hook names. The compiler itself does optimize this component when given the same options.

Skip the source-code prefilter only for explicit all mode. File and environment filters still apply. Infer and annotation modes keep their existing filters.

I tested both compiler paths with production Vite builds and React DOM. Rendering the same component with labels one, one, two called a stable render prop three times before this change and twice after it. Both paths still skipped the same unannotated component in infer and annotation modes, when the file was excluded, and in SSR builds. All ten cases rendered the expected text.

All 59 plugin-react unit tests, the workspace build, package typecheck, repo lint and formatting passed. Developed and tested with AI assistance (Factory Droid).

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>

@ArnaudBarre ArnaudBarre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that it doesn't change the behaviour for the default usage I'm ok with this change

This branch has not been deployed

No deployments
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.

2 participants