-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Migrating Remotely Bundled Component setup from Svelte 4 to 5 #14293
Comments
Please provide a reproduction repository |
of the system that worked or the one that doesnt? |
This the version that doesnt work. I am pretty sure the problem is somewhere on the client with how the component is instantiated and mounted. only once the component tries to attach to the dom, some problem arrises. also the bundling is successfull, and from what i can tell, looks exactly like before. |
The problem is that your setup does not deduplicate the Svelte runtime, it exists multiple times: once for your main app, once for your each of your bundles. If you can externalize them somehow that would be the ideal outcome, since it means you also save on bundle size. If that's not possible for some reason, you have to make sure to call the I quickly tried that like this <script module>
import Test from './Test.svelte'
import { mount as _mount } from "svelte";
export function mount(target, props) {
return _mount(Test, { target, props})
}
</script>
<script>
let { ...data } = $props();
console.log("Hello World from Test.svelte");
console.log("Check these amazing props", data);
</script>
<h1 class="text-palette-white">My Test Heading</h1> (and adjusting the place where the component is instantiated to use the exported mount method) ...but it still produces two versions of the Svelte runtime inside the Converting this to a discussion because this is not a bug in Svelte. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Describe the bug
I have a server on port 8000 that bundles and hosts svelte components, which are imported into a sveltekit app running on port 5173. This setup used to work fine on svelte 4, but the migration isnt as straight forward as i'd hoped.
Let me show first how the old setup used to work server and client side, and then what ive tried so far.
The server had a esbuild bundler, which had its outputFiles hosted on a http get request.
This was consumed by the client in two steps.
The Widget functioned as the Sveltekits Universal interface/ loader.
The referenced Component:
The component thats gettings built by the server is currently an empty demo.
this setup worked like a CHARM! given, its a bit much, but once i had figured it out, it never had any hickups.
but as you can see, it relied on instantiating the components as
new component
classes.now ive updated the build svelte dependency to 5.1.9 which is the same my main sveltekit app uses.
on the client ive tried a few different approaches like:
replace
new component
withcmp = createClassComponent({component:Component, target });
andcmp = mount(Component, { target, props: payload,});
but nothing works.
I get various error messages like:
any help would be welcome. i am very stuck and have no clue what levers to try next.
Reproduction
above
Logs
No response
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: