T
TanStack2y ago
deep-jade

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
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
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!
1 Reply
deep-jade
deep-jadeOP2y ago
I just read the documentation which says
If the transformation results in an error, you will also see a message on the console. This message will notify you something unexpected happened, please do the migration manually.
I guess maybe this is my case.... But in case someone knows, I'd still be curious to know why it didn't work...

Did you find this page helpful?