From 47ceed02ce0bba0cdda84fbcaf47d4ca0ba94fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Fri, 22 Aug 2025 17:09:19 +0200 Subject: [PATCH] fix svelte skeleton --- .../static-assets/skel-svelte/client/main.js | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/tools/static-assets/skel-svelte/client/main.js b/tools/static-assets/skel-svelte/client/main.js index 376cf55474..11a9eeb2f2 100644 --- a/tools/static-assets/skel-svelte/client/main.js +++ b/tools/static-assets/skel-svelte/client/main.js @@ -1,9 +1,26 @@ import { Meteor } from 'meteor/meteor'; import App from '../imports/ui/App.svelte'; +import { mount, unmount } from 'svelte'; +let app; // will hold the mounted instance Meteor.startup(() => { - new App({ - target: document.getElementById('app') - }); -}); \ No newline at end of file + const target = document.getElementById('app'); + + // (Re)mount + app = mount(App, { target }); + + // Clean up on HMR so we don't double-mount + if (import.meta.webpackHot) { + import.meta.webpackHot.accept(); + import.meta.webpackHot.dispose(() => { + if (app) { + // pass the instance you got from mount() + unmount(app, { outro: false }); // set outro:true if you want transitions + app = null; + } + // optional: clear target to be extra safe + target.innerHTML = ''; + }); + } +});