GreedyBear icon indicating copy to clipboard operation
GreedyBear copied to clipboard

Migration to TanStack Table v9

Open regulartim opened this issue 2 months ago • 3 comments

In #1602 , dependabot wanted to bump TanStack's react-table library to the next major release. This revealed two problems:

  1. Our code base is nor ready for that bump. Running npm run buildon that branch fails with this error:
error during build:
Build failed with 5 errors:

[MISSING_EXPORT] "useReactTable" is not exported by "node_modules/@tanstack/react-table/dist/index.js".
   ╭─[ src/components/common/gb-ui/components/table/DataTable.jsx:4:10 ]
   │
 4 │ import { useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel } from "@tanstack/react-table";
   │          ──────┬──────  
   │                ╰──────── Missing export
───╯

[MISSING_EXPORT] "getCoreRowModel" is not exported by "node_modules/@tanstack/react-table/dist/index.js".
   ╭─[ src/components/common/gb-ui/components/table/DataTable.jsx:4:25 ]
   │
 4 │ import { useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel } from "@tanstack/react-table";
   │                         ───────┬───────  
   │                                ╰───────── Missing export
───╯

[MISSING_EXPORT] "getFilteredRowModel" is not exported by "node_modules/@tanstack/react-table/dist/index.js".
   ╭─[ src/components/common/gb-ui/components/table/DataTable.jsx:4:42 ]
   │
 4 │ import { useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel } from "@tanstack/react-table";
   │                                          ─────────┬─────────  
   │                                                   ╰─────────── Missing export
───╯

[MISSING_EXPORT] "getSortedRowModel" is not exported by "node_modules/@tanstack/react-table/dist/index.js".
   ╭─[ src/components/common/gb-ui/components/table/DataTable.jsx:4:63 ]
   │
 4 │ import { useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel } from "@tanstack/react-table";
   │                                                               ────────┬────────  
   │                                                                       ╰────────── Missing export
───╯

[MISSING_EXPORT] "getPaginationRowModel" is not exported by "node_modules/@tanstack/react-table/dist/index.js".
   ╭─[ src/components/common/gb-ui/components/table/DataTable.jsx:4:82 ]
   │
 4 │ import { useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel } from "@tanstack/react-table";
   │                                                                                  ──────────┬──────────  
   │                                                                                            ╰──────────── Missing export
───╯

    at aggregateBindingErrorsIntoJsError (file:///home/tim/Repositories/GreedyBear/frontend/node_modules/rolldown/dist/shared/error-HDibX49O.mjs:48:18)
    at unwrapBindingResult (file:///home/tim/Repositories/GreedyBear/frontend/node_modules/rolldown/dist/shared/error-HDibX49O.mjs:18:128)
    at #build (file:///home/tim/Repositories/GreedyBear/frontend/node_modules/rolldown/dist/shared/rolldown-C9Hfg50O.mjs:133:34)
    at async buildEnvironment (file:///home/tim/Repositories/GreedyBear/frontend/node_modules/vite/dist/node/chunks/node.js:33821:66)
    at async Object.build (file:///home/tim/Repositories/GreedyBear/frontend/node_modules/vite/dist/node/chunks/node.js:34242:19)
    at async Object.buildApp (file:///home/tim/Repositories/GreedyBear/frontend/node_modules/vite/dist/node/chunks/node.js:34239:153)
    at async CAC.<anonymous> (file:///home/tim/Repositories/GreedyBear/frontend/node_modules/vite/dist/node/cli.js:776:3) {
  errors: [Getter/Setter]
}
  1. The CI in that PR is green, it does not catch the failing build.

To fix this, we should

  • do a proper migration to v9
  • change tests/components/feeds/Feeds.test.jsx such that it loads the real DataTable
  • make the CI run a vite build to catch these class of bugs in the future

regulartim avatar Sep 29 '26 05:09 regulartim

Hi @regulartim — I'd like to take this.

I reproduced it: on @tanstack/[email protected] the main entry no longer exports useReactTable or the four get*RowModel functions, which is exactly the 5 MISSING_EXPORT errors from #1602. The blast radius is small — DataTable.jsx is the only file importing the library (lines 5–11, plus the useReactTable call at 179 and the four getters at 187–190).

I'll do all three parts: migrate DataTable.jsx to useTable + the v9 feature slots, unmock DataTable in Feeds.test.jsx so it exercises the real component, and add a vite build step to CI so a broken export fails the pipeline instead of the release.

One question: for the CI build check, would you rather I add it to _node.yml as a separate job, or extend the existing lint job? Happy either way.

I also noticed v9 ships @tanstack/react-table/legacy with useLegacyTable and deprecated get*RowModel stubs — I'll use that only as a temporary checkpoint to get the build green before doing the real migration, not as the end state.

ABHIGYA0205 avatar Sep 29 '26 06:09 ABHIGYA0205

Hi @ABHIGYA0205 ! Alright, I'll assign you.

One question: for the CI build check, would you rather I add it to _node.yml as a separate job, or extend the existing lint job? Happy either way.

I think a separate job would be cleaner, no?

regulartim avatar Sep 29 '26 06:09 regulartim

Thanks @regulartim! Agreed — a separate job is cleaner, so that's what I went with: a dedicated build job in _node.yml, gated behind a new use_build input and enabled for the frontend, leaving the lint/vitest job as-is.

Draft PR is up: #1653. It covers all three parts of the issue — the v9 migration, Feeds.test.jsx now loading the real DataTable, and the separate CI build job. npm run build passes and the full test suite is green.

One behavior change flagged in the PR for your review: under v9, filtering to a single page no longer shows the paginator that v8 rendered with a stale page count. Happy to adjust anything once you've had a look.

ABHIGYA0205 avatar Sep 29 '26 17:09 ABHIGYA0205