huntabyte / shadcn-svelte

shadcn/ui, but for Svelte. ✨
https://next.shadcn-svelte.com
MIT License
5.37k stars 335 forks source link

Card component doesn't work on shadcn-svelte@next #1442

Closed dionysuzx closed 5 hours ago

dionysuzx commented 17 hours ago

NOTE: I have seen the below comments. Will repro asap (tomorrow :)), but I think this is a false positive. Thanks!

Describe the bug

I have an error in the Card component for shadcn-svelte@next. It says:

5:56:20 PM [vite] Internal server error: src/lib/components/ui/card/card-header.svelte:14:5 Cannot bind to constant
  Plugin: vite-plugin-svelte
  File: src/lib/components/ui/card/card-header.svelte:14:5
   12 |  </script>
   13 |
   14 |  <div bind:this={ref} class={cn("flex flex-col space-y-1.5 p-6 pb-0", className)} {...restProps}>
                             ^
   15 |    {@render children?.()}
   16 |  </div>
5:56:20 PM [vite] Internal server error: src/lib/components/ui/card/card-footer.svelte:14:5 Cannot bind to constant
  Plugin: vite-plugin-svelte
  File: src/lib/components/ui/card/card-footer.svelte:14:5
   12 |  </script>
   13 |
   14 |  <div bind:this={ref} class={cn("flex items-center p-6 pt-0", className)} {...restProps}>
                             ^
   15 |    {@render children?.()}
   16 |  </div>
5:56:20 PM [vite] Internal server error: src/lib/components/ui/card/card-title.svelte:20:1 Cannot bind to constant
  Plugin: vite-plugin-svelte
...

and svelte: Cannot bind to constant if you open any of the card-*.svelte files.

Reproduction

  1. Create a svelte 5 project
  2. Add a card component with shadcn-svelte@next
  3. Try to use the component
  4. Look at the card-*.svelte files

Logs

No response

System Info

System:
    OS: macOS 15.0.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 1.68 GB / 32.00 GB
    Shell: 3.7.0 - /opt/homebrew/bin/fish
  Binaries:
    Node: 23.1.0 - ~/.local/share/nvm/v23.1.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.9.0 - /opt/homebrew/bin/npm
    pnpm: 9.12.3 - /opt/homebrew/bin/pnpm
    bun: 1.1.34 - ~/.bun/bin/bun
  Browsers:
    Safari: 18.0.1
  npmPackages:
    @sveltejs/kit: ^2.7.4 => 2.7.4
    bits-ui: 1.0.0-next.40 => 1.0.0-next.40
    svelte: ^5.1.9 => 5.1.9

Severity

blocking an upgrade

shyakadavis commented 16 hours ago

Hey, @dionysuzx

I literally was just using it a moment ago, and everything was fine. Mind sharing a repro?

huntabyte commented 7 hours ago

Likely running an outdated version of @sveltejs/vite-plugin-svelte if I had to guess :)

dionysuzx commented 5 hours ago

I'm not sure what it was, I somehow can't reproduce with my own steps. It very well may have been an outdated vite-plugin-svelte. Thanks for checking!