Skip to content

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Aug 12, 2025

The optimization that converts {...props} to props when it's the only attribute was incorrectly applied even when jsx_self or jsx_source plugins are enabled. This caused __self and __source props to not be merged properly,
resulting in incorrect transformation output in development mode.

This fix disables the optimization when these dev plugins are active, ensuring spread props are preserved for proper merging.

@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-bug Category - Bug labels Aug 12, 2025
Copy link
Member Author

Dunqing commented Aug 12, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Dunqing Dunqing marked this pull request as ready for review August 12, 2025 10:05
Copilot AI review requested due to automatic review settings August 12, 2025 10:05
@Dunqing Dunqing requested a review from overlookmotel as a code owner August 12, 2025 10:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where the JSX transformer's spread props optimization was incorrectly applied when development plugins (jsx_self and jsx_source) are enabled. The optimization that converts {...props} to props when it's the only attribute was preventing proper merging of injected __self and __source props in development mode.

Key changes:

  • Added condition to disable spread props optimization when dev plugins are active
  • Added test case to verify correct behavior with classic runtime and development plugins
  • Updated test snapshots to reflect the new passing test

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/oxc_transformer/src/jsx/jsx_impl.rs Added condition to preserve spread syntax when jsx_self or jsx_source plugins are enabled
tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/spread-props-classic/input.jsx Test input with spread props in JSX element
tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/spread-props-classic/options.json Test configuration enabling development transform with classic runtime
tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/spread-props-classic/output.js Expected output showing preserved spread syntax with injected __self and __source props
tasks/transform_conformance/snapshots/oxc.snap.md Updated test count from 182/302 to 183/303 passing tests

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 12, 2025

CodSpeed Instrumentation Performance Report

Merging #13020 will not alter performance

Comparing 08-12-fix_transformer_react_spread_props_optimization_breaks___self_and___source_injection_13009_ (6fe0bb5) with main (c58a699)

Summary

✅ 34 untouched benchmarks

Copy link
Member

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

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

Makes sense!

Pushed a commit to update conformance snapshots (just the usual churn in TS semantic). Hopefully it'll merge now.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Aug 12, 2025
Copy link
Member

overlookmotel commented Aug 12, 2025

Merge activity

…_source injection (#13009) (#13020)

* Fixes #13009

The optimization that converts `{...props}` to `props` when it's the only attribute was incorrectly applied even when `jsx_self` or `jsx_source` plugins are enabled. This caused `__self` and `__source` props to not be merged properly,
resulting in incorrect transformation output in development mode.

This fix disables the optimization when these dev plugins are active, ensuring spread props are preserved for proper merging.
@graphite-app graphite-app bot force-pushed the 08-12-fix_transformer_react_spread_props_optimization_breaks___self_and___source_injection_13009_ branch from 8eb729c to 6fe0bb5 Compare August 12, 2025 11:59
@graphite-app graphite-app bot merged commit 6fe0bb5 into main Aug 12, 2025
30 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 12, 2025
@graphite-app graphite-app bot deleted the 08-12-fix_transformer_react_spread_props_optimization_breaks___self_and___source_injection_13009_ branch August 12, 2025 12:05
taearls pushed a commit to taearls/oxc that referenced this pull request Aug 12, 2025
…_source injection (oxc-project#13009) (oxc-project#13020)

* Fixes oxc-project#13009

The optimization that converts `{...props}` to `props` when it's the only attribute was incorrectly applied even when `jsx_self` or `jsx_source` plugins are enabled. This caused `__self` and `__source` props to not be merged properly,
resulting in incorrect transformation output in development mode.

This fix disables the optimization when these dev plugins are active, ensuring spread props are preserved for proper merging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transformer: classic runtime jsx with a spread prop is transformed incorrectly

3 participants