-
-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Svelte] Svelte 5 support #2288
base: 2.x
Are you sure you want to change the base?
Conversation
Some reading here: https://svelte-5-preview.vercel.app/docs/breaking-changes (just passing by) |
@@ -37,6 +37,13 @@ class default_1 extends Controller { | |||
}; | |||
this.dispatch(name, { detail, prefix: 'svelte' }); | |||
} | |||
async mountSvelteComponent(Component, options) { | |||
const { mount } = await import('svelte'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not work with AssetMapper right ? In which cas we need to find a solution because this would be a giant BC break :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my first thought but it worked when I tried it in ux.symfony.com !
I also tried to have import { mount } from 'svelte'
at the top of the file but it doesn't work with AssetMapper with Svelte 4, an error was thrown because mount
only exists in v5
I can't explain why but with a dynamic import there is no error, mount is just undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll test this next week, thanks for the explanations :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…hen controller is disconnected
Well that's pretty clear: https://svelte-omnisite.vercel.app/docs/svelte/v5-migration-guide |
I'm starting to investigate what's missing to make Svelte 5 happy here, just personal notes:
|
Small tips: you can get rid of the |
Ok I think I'm on something. I believe that's because the context between In one of the module, I believe this is related to no-build scenarios, like we do with AssetMapper/importmap. I will investigate more and try to find a solution. |
It is, and some people are trying weird stuff with chunks (i'm not sure to even understand what i'm saying here haha) |
To be honest, due to how files are bundled on JSDelivr and how Svelte 5 works, I don't know if we can have Svelte 5 support for AssetMapper... :/ |
I'd be ok if the support was only for webpack :| But no BC break for AssetMapper please :) But i don't get how this work as... in the end... there are only compiled assets in a directory right ? |
Not with AssetMapper / CDN stuff. When you compile this <script>
export let name = "Svelte";
</script>
<div>Hello {name}</div> It become: import * as $ from "svelte/internal/client";
var root = $.template(`<div> </div>`);
export default function _unknown_($$anchor, $$props) {
let name = $.prop($$props, "name", 8, "Svelte");
var div = root();
var text = $.child(div);
$.reset(div);
$.template_effect(() => $.set_text(text, `Hello ${name() ?? ""}`));
$.append($$anchor, div);
} Here, we have a dependency to In the The thing is, that both dependencies One dependency defines IMO, the best we can do is to:
I'm more in favor of a new dedicated |
The potential issue I see with creating a new |
There is not much code in the package, i'm sure we can make something in it to load or or the other file :) |
Yeah, but for the moment Svelte 5 only works with Webpack, not with AssetMapper. Even if we can do something "to load or not the other file", it still won't work :s or am I missing something? |
That's what i reacted on when i said "i'd be ok to no have AssetMapper support" We can announce a compatibility for only Webpack no ? |
Yes we can |
Svelte 5 was just released 🚀