Open thisjt opened 1 month ago
the package in question does not have "type": "module"
in its package.json so .js files in it are considered to be commonjs. But /dist/js/tabulator_esm.js
is esm. It should either have a .mjs
extension or the package needs to change to "type":"module"
and commonjs exports need a .cjs extension.
see https://publint.dev/tabulator-tables@6.2.1 and also https://antfu.me/posts/publish-esm-and-cjs
opening your reproduction in stackblitz shows a different error https://stackblitz.com/github/thisjt/tabulator-import-issue?file=README.md (looks like building an error stacktrace broke)
This is very unlikely to be caused by sveltekit. On the offchance it is, please provide a reproduction that shows tabulator-tables 6.0 working in sveltekit@1, not working in sveltekit@2 and also working in a generic vite 5 js project.
sveltekit is an esm first framework, and personally i would recommend using dependencies that also share this spirit.
I have inform the author with your suggestions. I'm currently waiting for his reply. As of now, I have replicated the package working fine as is in sveltekit@1.5. I'm not sure if I'm doing the barebones vite@5 right but the importing is also working fine there. For sveltekit@2 I'm getting the same error as what you saw when trying to import the package so not sure what's up with that.
Sveltekit@1.5 barebones repro https://stackblitz.com/edit/vitejs-vite-pqilhv Sveltekit@2 barebones repro https://stackblitz.com/edit/vitejs-vite-dp8aka (broken with unrelated error) Vite@5 barebones repro https://stackblitz.com/edit/vitejs-vite-cdmwht
Describe the bug
Importing the package "tabulator-tables" throws an error saying that it's a CJS module and it should be imported in a specific way. On SvelteKit 1 this importation is working fine as is but the issue started to happen when I upgraded to SvelteKit 2. This could also potentially be an issue with Vite but so far this issue is only happening for SvelteKit 2 and not on other frontend frameworks.
Here's the import code
This is currently my workaround for this issue
Here's the bug report that was opened on tabulator-tables. The author stated that it should work properly as is and it's weird that this is happening specifically only on SvelteKit. https://github.com/olifolkerd/tabulator/issues/4378
Here's the output of the issue
Reproduction
Here's a repo with the minimum reproducible issue: https://github.com/thisjt/tabulator-import-issue
Logs
No response
System Info
Severity
annoyance