Bug: React.Profiler
no longer works in production builds after upgrading to React 19
#32992
Labels
Status: Unconfirmed
A potential issue that we haven't yet confirmed as a bug
React version: 19.0.0
Steps To Reproduce
react-profiler-test
yarn install
yarn build
yarn prod
Uncaught TypeError: Cannot read properties of undefined (reading 'd')
I've forked the repo webpack-5-react-boilerplate, which is a perfectly working React 19 + Webpack repository, adding the code the React.Profiler documentation points out to to enable
React.Profiler
in production, you can see that code in this PR - with this you can reproduce the error that I'm seeing in another larger application.The current behavior
I have a larger application using
React.Profiler
in production, I followed the steps to enable it and everything was working as expected, I was usingreact@18.3.1
andreact-dom@18.3.1
After upgrading to
react@19.0.0
(and even 19.1.0) I started seeing thatReact.Profiler
no longer worked in the production build (it does work in development tho) having a very similar runtime error to the one above when I opened any page:Uncaught TypeError: Cannot read properties of undefined (reading 'd')
, since it's the production build everything is minified and I haven't had luck finding more details about the error.Research made
I compared the code inside
node_modules
forreact-dom@18.3.1
andreact-dom@19.0.0
to see if I was able to find any ways to fix it, but had no luck. The main difference between those 2 versions are:The exported configuration in
package.json
We have this for
react-dom@18.3.1
in package.jsonwhereas in
react-dom@19.0.0
in package.json theexports
values are quite different usingdefault
:I thought this meant I needed to change the way I create the
alias
in my webpack config, but I tried several different ways and nothing worked while buildingContents of
profiling.js
Looking again at the differences in versions in
node_modules
I found that the file that ends up being export byreact-dom/profiler.js
changed from versions, the one inreact-dom@18.3.1
was minified whereas the one inreact-dom@19.0.0
is not precisely minified.I had no further findings in this area but I've updated the node modules to a repo for easier comparision:
react-dom@19.0.0 - profiling.js
react-dom@19.0.0 - cjs/react-dom-profiling.profiling.js
VS
react-dom@18.3.1 - profiling.js
react-dom@18.3.1 - cjs/react-dom.profiling.min.js
The expected behavior
I'd appreciate your help to find out why this is not working and how to fix it.
The text was updated successfully, but these errors were encountered: