TanStack / table

🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
https://tanstack.com/table
MIT License
24.84k stars 3.07k forks source link

CommonJS support with ESM import #4496

Closed konsalex closed 1 year ago

konsalex commented 1 year ago

Describe the bug

Not sure if this is expected, but trying to implement react-table v8 inside Storybook and I have a problem.

By default it tries to import UMD, which is not supported, and when I try to import manually the CommonJS build:

import {  useReactTable } from '@tanstack/react-table/build/cjs/react-table/src/index';

I get an error:

ERROR in ....../node_modules/@tanstack/react-table/build/cjs/table-core/build/esm/index.js 109:33

And I can see from the build files: https://cdn.jsdelivr.net/npm/@tanstack/react-table@8.5.22/build/cjs/react-table/src/index.js

That there is an ESM import from the table-core package. Is this the expected behaviour?

Your minimal, reproducible example

https://codesandbox.io/s/kind-mopsa-0egd7p?file=/src/components/Button.stories.tsx

Steps to reproduce

  1. Let packages get installed and then check the errors inside the terminal

Expected behavior

No errors in importing the package

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

All of them

react-table version

v8.5.22

TypeScript version

No response

Additional context

No response

Terms & Code of Conduct

KevinVandy commented 1 year ago

@konsalex Try out the newest TanStack Table v8.7.0 and let us know if you are still running into problems here

We think PR https://github.com/TanStack/table/pull/4552 should have fixed this issue.

konsalex commented 1 year ago

@KevinVandy probably it's fixed as I can see the diff:

  1. https://cdn.jsdelivr.net/npm/@tanstack/react-table@8.7.0/build/lib/index.js

  2. https://cdn.jsdelivr.net/npm/@tanstack/react-table@8.5.22/build/cjs/react-table/src/index.js

Thank for the ping