Webpack issue upgrading React Query from v4 to v5
After upgrading
@tanstack/react-query
and @tanstack/react-query-devtools
, Webpack (v4) fails to build my application.
It looks like Webpack is attempting to bundle the wrong build files, or else I need to configure babel to compile the newer Ecmascript syntax?16 Replies
eager-peach•11mo ago
https://tanstack.com/query/latest/docs/framework/react/guides/migrating-to-v5#private-class-fields-and-methods
You likely need to make sure you bundle with at least ECMAScript 2022
TanStack | High Quality Open-Source Software for Web Developers
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.

rare-sapphireOP•11mo ago
Thanks for the reply @troywoy . I have
@babel/preset-env@7.16.11
setup. Because I haven't declared a browserslist
anywhere it should be defaulting to the oldest browsers and transpiling anything newer than ES2015, right? Or am I getting this backwards?eager-peach•11mo ago
Not sure, Vite ruined everything I remember about Webpack
I know in my setup I had to add
target: 'es2022'
in my vite configs in order for top level await to workrare-sapphireOP•11mo ago
I wish I could be in that position, haha. This application is too big, I'll need to convince leadership to invest at least a couple quarters to a migration 😿
eager-peach•11mo ago
target: ["web", "es2022"]
rare-sapphireOP•11mo ago
Unfortunately, still on webpack 4, and I'd rather put energy into Vite than upgrading Webpack.
Here's another error raised during the build
React Query is certainly not our only dependency making use of nullish coalescing, so I'm wondering why it's the only one that is causing an issue for us?
In fact, here's an example of its usage in v4 of React Query which is working fine for us right now.
https://github.com/TanStack/query/blob/92e5672f58dec44d87f899e41d78d3582866d3f8/packages/query-core/src/queriesObserver.ts#L168
eager-peach•11mo ago
GitHub
feat: Drop legacy webpack v4 support by lachlancollins · Pull Reque...
This removes the legacy .esm.js output, which was used by bundlers that didn't recognise the modern .mjs extension such as Webpack v4. If you are still using Webpack v4, you can continue to...
rare-sapphireOP•11mo ago
Ahh, painful but direct lol
There's also this follow up PR linked that implies they walked that back? I wish there was a more public discussion or at least statement of intent...
rare-sapphireOP•11mo ago
GitHub
feat: Add legacy rollup builds by lachlancollins · Pull Request #55...
Kind of reverts #5507. The packages that use buildConfigs (i.e. not the svelte, solid or eslint packages) will also generate a legacy output (.legacy.js and .legacy.cjs). I've checked to ma...
eager-peach•11mo ago
That PR is to an alpha branch so I don't think it ever made it into v4/v5
rare-sapphireOP•11mo ago
Ahh good spot
eager-peach•11mo ago
Maybe this can be good fuel to ignite the dependency updates/migration that your leadership needs to hear lol
rare-sapphireOP•11mo ago
True... Thank you for your help at least!
eager-peach•11mo ago
I kept looking through the Github Issues and came across this comment: https://github.com/TanStack/query/issues/4155#issuecomment-1244222558
GitHub
Webpack build issue v4.3.4 · Issue #4155 · TanStack/query
Describe the bug When running webpack webpack --config webpack.config.js I'm getting this error on v4.3.4: ERROR in ./node_modules/@tanstack/react-query/build/lib/reactBatchedUpdates.mjs 3:32-6...
eager-peach•11mo ago
This is still referring to RQ v4 though. Not sure I'd have high hopes for webpack v4