TanStackT
TanStack2y ago
1 reply
popular-magenta

HELP! V4 to V5 migration Codemod didn't work

So this is what I did
1. installed "@tanstack/react-query": "^5.29.2",
    "@tanstack/react-query-devtools": "^5.29.2",
2. changed the node_modules/@tanstack/react-query/build/codemods/src/v5/remove-overloads/remove-overloads.js to CJS 
3. changed the package json to   "type": "commonjs",
4. changed the require in the cjs file to import like this:
// eslint-disable-next-line @typescript-eslint/no-var-requires
// const createUtilsObject = require('@tanstack/react-query/build/codemods/src/utils')
import createUtilsObject from '@tanstack/react-query/build/codemods/src/utils'
// eslint-disable-next-line @typescript-eslint/no-var-requires
// const transformFilterAwareUsages = require('@tanstack/react-query/build/codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer')
import transformFilterAwareUsages from '@tanstack/react-query/build/codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer'
// eslint-disable-next-line @typescript-eslint/no-var-requires
// const transformQueryFnAwareUsages = require('@tanstack/react-query/build/codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer')
import transformQueryFnAwareUsages from '@tanstack/react-query/build/codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer'
5. run script npx jscodeshift@latest ./src/ \
  --extensions=ts,tsx \
  --parser=tsx \
  --transform=./node_modules/@tanstack/react-query/build/codemods/src/v5/remove-overloads/remove-overloads.cjs

Now I got this error
Error: Package subpath './build/codemods/src/utils' is not defined by "exports" in /Users/annie/Documents/STH/repo/node_modules/@tanstack/react-query/package.json imported from /Users/annie/Documents/STH/repo/node_modules/@tanstack/react-query/build/codemods/src/v5/remove-overloads/remove-overloads.cjs

Where have I gone wrong and what should I do next? Thanks!
Was this page helpful?