Skip to content

Conversation

@poteto
Copy link
Member

@poteto poteto commented Mar 6, 2025

In #32416, @michaelfaith discovered that

if (process.env.NODE_ENV === 'production') {
would fail on the merged compiler eslint rule.

Upon further investigation I discovered that our CompilerError implementation doesn't play nicely with Reflect, so Reflect.construct would fail as .toString would error:

TypeError: Cannot read properties of undefined (reading 'map')
          at _CompilerError.toString (/Users/.../code/react/node_modules/babel-plugin-react-compiler/src/CompilerError.ts:200:25)
          at _CompilerError.get message [as message] (/Users/.../code/react/node_modules/babel-plugin-react-compiler/src/CompilerError.ts:194:17)
          at Object.construct (/Users/.../code/react/scripts/jest/setupTests.js:153:52)

I tested this fix using my local copy of the built babel-plugin-react-compiler to verify that this fixes those tests.

In #32416, @michaelfaith discovered that https://github.com/facebook/react/blob/029e8bd618af23fbdd9efdac565ad81f7d4640d8/scripts/jest/setupTests.js#L82 would fail on the merged compiler eslint rule.

Upon further investigation I discovered that our CompilerError implementation doesn't play nicely with Reflect, so `Reflect.construct` would fail as `.toString` would error:

```
TypeError: Cannot read properties of undefined (reading 'map')
          at _CompilerError.toString (/Users/.../code/react/node_modules/babel-plugin-react-compiler/src/CompilerError.ts:200:25)
          at _CompilerError.get message [as message] (/Users/.../code/react/node_modules/babel-plugin-react-compiler/src/CompilerError.ts:194:17)
          at Object.construct (/Users/.../code/react/scripts/jest/setupTests.js:153:52)
```

I tested this fix using my local copy of the built babel-plugin-react-compiler to verify that this fixes those tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants