ux icon indicating copy to clipboard operation
ux copied to clipboard

[Svelte] Add support for Svelte 5

Open Kocal opened this issue 2 months ago • 4 comments

Q A
Bug fix? no
New feature? yes
Deprecations? no
Documentation? no
Issues Fix #2540
License MIT

Related to https://github.com/symfony/ux/pull/2288

This is in work-in-progress, I still have an error in the browser while trying to render the Hello component when using the AssetMapper:

stimulus.index-S4zNcea.js:7 Error connecting controller

TypeError: Cannot read properties of undefined (reading 'call')
    at _n (client-BATiWue.js:7:27775)
    at client-BATiWue.js:7:39919
    at Hello (Hello-s876KnU.js:8:12)
    at svelte.index-TK8_2BG.js:7:28981
    at svelte.index-TK8_2BG.js:7:11011
    at Ht (svelte.index-TK8_2BG.js:7:24452)
    at Kt (svelte.index-TK8_2BG.js:7:25511)
    at dt (svelte.index-TK8_2BG.js:7:21898)
    at pt (svelte.index-TK8_2BG.js:7:22380)
    at svelte.index-TK8_2BG.js:7:11003

I didn't check how it deals with Webpack Encore yet (opened https://github.com/symfony/webpack-encore/issues/1384).

Kocal avatar Nov 16 '25 23:11 Kocal

📊 Packages dist files size difference

Thanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR. Please review the changes and make sure they are expected.

FileBefore (Size / Gzip)After (Size / Gzip)
Svelte
render_controller.d.ts 670 B / 359 B 688 B+3% 📈 / 369 B+3% 📈
render_controller.js 1.18 kB / 495 B 1.24 kB+5% 📈 / 513 B+4% 📈

github-actions[bot] avatar Nov 16 '25 23:11 github-actions[bot]

hi there, this is one of a kind.. i had a look recently about svelte 5/asset mapper and i ran into the same, so following what i thought i wrote a rollup.config.js (inspired from this repo) on top of this branch to put all the things together after a while and some distorsions ^^ i managed to render something but it's a big mess at least anyway i feel this is not the right way things should be done with assetmapper as i got to use a module bundler there is already a step to compile .svelte files and it's quite unpleasant tho i could give extra details if it sounds interesting

maxperei avatar Nov 18 '25 14:11 maxperei

Hey @maxperei, sure, any help would be appreciated! :)

Kocal avatar Nov 20 '25 08:11 Kocal

ok well, i generated a patch to give a try of course you'll have to npm i && npm run build again (as well as php bin/console assetmap:install if necessary) then if you go into ./assets/vendor/svelte you see a new file : index-client.js and a bunch of other files like svelte.index.js, internal/client.js which are overridden and the left ones remain unchanged this particular index-client.js is very tricky because sometimes it throws a 404 and you will have to expose this file into public/ folder using php bin/console asset-map:compile or just copy it, and sometimes (maybe it's symfony cache or something i can't explain --') it works without exposing it

maxperei avatar Nov 20 '25 12:11 maxperei