svelte: Svelte 5: List of libraries not working out of the box

Describe the bug

Some libraries don’t work with Svelte 5 out of the box. It will probably be impossible to make every library compatible given that some use stuff svelte/internal (which they really shouldn’t) and everything in there changed, but those who don’t should be closely investigated. Feel free to post libraries you found that don’t work in here, ideally along with a small reproduction (repro or “install and use component X”).

Won’t / can’t fix

Fixed

  • svelte-confetti
  • svelte-range-slider-pips (through #10543)

Reproduction

Use the libraries and observe errors

Logs

No response

System Info

-

Severity

annoyance

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 36
  • Comments: 78 (27 by maintainers)

Commits related to this issue

Most upvoted comments

I just ran LayerChart’s docs using the latest Svelte 5 (5.0.0-next.144 as of writing this) and it was experiencing quite a few problems (all dialogs open by default, non reactive toggles, 100% CPU on some pages, etc). Some of these are likely coming from Svelte UX components as well (which has been pretty good to tease out regressions).

I’ll be investigating these as I get time and hopefully create minimal REPL reproductions when possible, but wanted to give a heads up in case someone else has time to take a look.

I did just log an SVG namespace issue (https://github.com/sveltejs/svelte/issues/11847) that was uncovered.

svelteflow.dev - the following error occurs as soon as the dep is installed

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import ‘/home/qw/projects/qwerty/node_modules/.pnpm/@xyflow+svelte@0.0.37_svelte@5.0.0-next.69/node_modules/@xyflow/svelte/dist/lib/container/SvelteFlow’ is not supported resolving ES modules imported from /home/sol/projects/qwerty/node_modules/.pnpm/@xyflow+svelte@0.0.37_svelte@5.0.0-next.69/node_modules/@xyflow/svelte/dist/lib/index.js

Shadcn-svelte Combobox works in Svelte 4, but doesn’t in Svelte 5. Tried with both, the code is same in both, the only different is svelte version.

I’ve created a repo for the same. The svelte 4 works well, svelte 5 fails - keeps adding new items when trying to filter lists

https://github.com/memestageceo/combobox-4v5.git

image

PS: Posting it here as I think that Svelte 5 is meant to be backward compatible, but in this case, it isn’t. I don’t know how to figure this out more than this, so kindly clone the repo and test it out. I’ve set up everything for both svelte 4 and svelte 5.

Hey @dummdidumm, we’ve had a few reports on a couple of components with Bits/Melt (Range Calendar being one), as well as a few about https://github.com/huntabyte/cmdk-sv. I’ll confirm and try to put some minimal repros together.

That’s #11429 which was fixed by #11438, release soon

svelte-sonner no work -> #10359 (comment)

@dummdidumm most of the issues I’m seeing in a few different components consist of the ERR_SVELTE_TOO_MANY_UPDATES. The functionality appears to work as expected, but the error is displayed in the browser’s console.

Reproduction

  1. Launch minimal repro Stackblitz
  2. Click “Show Toast” button
  3. Observe errors in the browser console

i’m using shadcn-svelte and trying to get the combo box example working with the current version of svelte 5. I’ve installed all the below dependancies for it to work:

  1. npx shadcn-svelte@latest add popover
  2. npx shadcn-svelte@latest add command
  3. npm install cmdk-sv

When installing these i need to use --force as otherwise i can’t install any of the shadcn-svelte components. I’ve been told that its because it uses svelte/internal. You can see the error i get when trying without force in the second code example below. However more importantly I get the below error when I try to open a page with the combo box element on it

Error with combo installed using --force

✘ [ERROR] Invalid assignment target

    node_modules/cmdk-sv/dist/cmdk/components/Command.svelte:82:30:
      82 │       $.mutate_store(stateStore, $.untrack($stateStore).value() = value2, $.untrack($stateStore));
         ╵                                  ^

9:10:29 AM [vite] error while updating dependencies:
Error: Build failed with 1 error:
node_modules/cmdk-sv/dist/cmdk/components/Command.svelte:82:30: ERROR: Invalid assignment target
    at failureErrorWithLog (/Users/me/Sites/my-project-v4/node_modules/esbuild/lib/main.js:1651:15)
    at /Users/me/Sites/my-project-v4/node_modules/esbuild/lib/main.js:1059:25
    at /Users/me/Sites/my-project-v4/node_modules/esbuild/lib/main.js:1527:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Error when trying to install any shadcn-svelte component without --force

ERROR: Command failed with exit code 1: npm install paneforge
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: my-project-v4@0.0.1
npm ERR! Found: svelte@5.0.0-next.68
npm ERR! node_modules/svelte
npm ERR!   svelte@"^5.0.0-next.55" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer svelte@"^4.0.0" from paneforge@0.0.2
npm ERR! node_modules/paneforge
npm ERR!   paneforge@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /Users/me/.npm/_logs/2024-02-27T22_20_26_351Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /Users/me/.npm/_logs/2024-02-27T22_20_26_351Z-debug-0.log

It seems like a ton of libraries are using svelte/internal is there no way to mimic the functionality of the most common things they are doing to greatly reduce the ecosystem fragmentation?

Yeah, I did that, but I decided to come at it from the other angle and, following the advice from here, turned rune mode on for the entire app and turned it off for the individual incompatible library.

svelte.config.js

  vitePlugin: {
    dynamicCompileOptions({filename}) {
      if (filename.includes('node_modules/sveltekit-superforms')) {
        return {runes: false}
      }
    },
  },

I think it would be helpful to have this info in the documentation.

@vexkiddy seems to be working on the latest version. REPL. Version next.55 is really ancient.

From the linked issue it sounds like you’re setting runes: true in the compiler options. You shouldn’t be doing this when using any component libraries that are still using Svelte 4 syntax. Instead it’s best to implicitly opt into runes mode on a per file basis by using runes inside your components.

Created #11389 to track the devtools integration story

svelte-confetti has been fixed as of version 1.3.2 https://github.com/Mitcheljager/svelte-confetti/pull/10

There is no reactivity for Remult entities :

<script lang="ts">
  import { Entreprise } from "../../shared/Entreprise";
  import { remult } from "remult";

  let entreprise = $state<Entreprise>();

  const entrepriseRepo = remult.repo(Entreprise);

  entrepriseRepo.findId(1).then((e) => (entreprise = e));

  $inspect(entreprise);  // only log the init state, no updates
</script>

<button onclick={() => console.log($state.snapshot(entreprise))}>Log</button>

{#if entreprise}
  <input type="text" bind:value={entreprise.name} />
{/if}

It works only if we save the new state as a new object: entrepriseRepo.findId(1).then((e) => (entreprise = { ...e }));

@jycouet found that the issue was that class instances are not reactive, already discussed here : https://github.com/sveltejs/svelte/issues/11590.

The workaround is to use the toJson repository method : https://remult.dev/docs/ref_repository#tojson

The underlying problem is that the dependency sswr is using beforeUpdate: https://github.com/ConsoleTVs/sswr/blob/master/src/sswr.ts#L29 Let’s use https://github.com/vercel/ai/issues/3107 to track this

This sounds like https://github.com/huntabyte/cmdk-sv/issues/92, which isn’t solveable on our end, and needs adjustment in the library.

svelte-turnstile breaks as a result of #8301. If that issue is fixed, svelte-turnstile will function properly.

This isn’t a bug, but the svelte-json-tree library should be updated to include Svelte 5 as a peer dependency.

https://github.com/sveltejs/svelte-json-tree/blob/main/package.json#L58

@attilabuturla I’ve encountered this with LayerChart (maybe why you are reporting 😁) and looks like quite a few libraries are affected (especially those set as peerDependency)

This isn’t a bug, but the svelte-json-tree library should be updated to include Svelte 5 as a peer dependency.

https://github.com/sveltejs/svelte-json-tree/blob/main/package.json#L58

I don’t know if it helps, but I created a PR to take care of it: https://github.com/sveltejs/svelte-json-tree/pull/6

@benmccann They forced compilerOptions: { runes: true }, which affects installed libraries as well (#9632). It works fine when the library is allowed to operate in legacy mode.

Please open a separate issue with a proper reproduction

vercel/ai with the @ai-sdk/svelte is not working due they’re using svelte/stores, do not work on Runes mode.

Svelte 5: Runes mode

image

image

Svelte 5: Compatibility mode

image

I guess svelte-5 is close to its release. There are only 8 issues left. I have started working towards upgrading svelte-commerce to svelte5

Please open a separate issue with a reproduction for this

next.174 broke svelte material ui (SMUI) by @hperrin https://github.com/hperrin/svelte-material-ui/issues/662

As a temporary workaround I found wrapping the chart in an {#if} block using a flag that is set to false via beforeNavigate works to at least keep the app running, even though the error still logs to the console (without it the app is dead and I have to do a hard page refresh):

import { beforeNavigate } from '$app/navigation'

let show = $state(true)
beforeNavigate(() => show = false)
{#if show}
  <Chart> ... </Chart>
{/if}

Possibly related to what @techniq is seeing, LayerCake is having an issue on 5.0.0-next.148 where listeners2 is not defined. Seems to be related to observing the width of an element. I’m only getting the error intermittently, though, and I haven’t been able to track it down more than that.

I see the same thing, but it only happens in dev - when I build and run the app it works fine.

Using this repl the listeners2 issue happens both when using npm run dev and using npm run build npm run preview https://github.com/sveltejs/svelte/issues/11934#issuecomment-2153020997

@dummdidumm Kitbook copies the Svelte DevTools chrome extension use of SvelteRegisterBlock, SvelteRegisterComponent and the create_fragment m, p, and d functions to build up the active component tree w/ associated dom elements. I’ve looked around a bit (particularly in ownership.js at mark_module_start and mark_module_end) for the equivalents in Svelte 5 but it’s not apparent to me what a good path forward would be. See this comment for a little more context. Do you guys have a plan yet for how the Svelte DevTools is going to track with mounted components and elements? Is this going to need to wait for the final 5.0 release? Thanks!

https://github.com/vkurko/calendar

Error when evaluating SSR module /node_modules/svelte/src/internal/index.js:
|- Error: Your application, or one of its dependencies, 
imported from 'svelte/internal', which was a private module used by Svelte 4 components that no longer exists in Svelte 5

The library is using a lot of svelte/internal

import { run_all, is_function, noop, identity, tick, SvelteComponent, init, safe_not_equal, ensure_array_like, empty, insert, detach, destroy_each, component_subscribe, set_store_value, element, text, attr, append, listen, set_data, action_destroyer, transition_in, group_outros, check_outros, transition_out, space, create_component, mount_component, destroy_component, construct_svelte_component, set_style, get_current_component } from 'svelte/internal';

https://github.com/TanStack/table/issues/5213. The svelte wrapper for TanStack Table is using svelte/internal and thus is broken.

svelte-sonner repro: https://stackblitz.com/edit/sveltejs-kit-template-default-y7ihkq?file=src%2Froutes%2FCounter.svelte

or just install “svelte-sonner” and use component with latest svelte 5 (alpha 68 at this moment)

In the browser console it says: ERR_SVELTE_TOO_MANY_UPDATES

@mquandalle can you provide a reproduction? I tried the code snippet in the related svelte-range-slider-pips issue and it’s working for me.

@Leftium the bug with the artifact should be fixed through #10555