Commit 619c8ae
Detect formatted React.createClass calls (#58256)
Summary:
The source-optimized preset enables React's display-name transform only when the exact bytes `React.createClass` are present. Valid comments or whitespace around the member access, such as `React /* comment */ . createClass(...)`, bypass the transform and omit the inferred component `displayName`, unlike the full preset path.
Use the stable `createClass` identifier token as the cheap source probe while retaining the separate `createReactClass` probe. Formatting no longer changes output; unrelated token matches only enable an otherwise no-op Babel visitor.
## Changelog:
[GENERAL] [FIXED] - Detect trivia-separated React.createClass calls in optimized preset configuration.
Pull Request resolved: #58256
Test Plan:
- Added an optimized-source regression with comment/whitespace-separated member access.
- Exact baseline omits `displayName`; the fixed transform emits `displayName: "Component"`.
- Full preset Jest passes: 4/4 suites, 111/111 tests, 16 snapshots.
- Fresh Flow check reports 0 errors.
- Targeted no-ignore ESLint, Prettier, and `git diff --check` pass.
No public API or breaking behavior change; optimized and full preset paths now agree for valid formatting.
Reviewed By: GijsWeterings
Differential Revision: D118266439
Pulled By: javache
fbshipit-source-id: 802fe1c8cadda18931384cd5a7f6e88a63e87bad1 parent 1b40443 commit 619c8ae
2 files changed
Lines changed: 26 additions & 1 deletion
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
174 | 189 | | |
175 | 190 | | |
176 | 191 | | |
| |||
267 | 282 | | |
268 | 283 | | |
269 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
270 | 295 | | |
271 | 296 | | |
272 | 297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
0 commit comments