diff --git a/playgrounds/demo/src/entry-client.ts b/playgrounds/demo/demo-client.ts similarity index 88% rename from playgrounds/demo/src/entry-client.ts rename to playgrounds/demo/demo-client.ts index 2bde776586..acf96e6490 100644 --- a/playgrounds/demo/src/entry-client.ts +++ b/playgrounds/demo/demo-client.ts @@ -1,5 +1,5 @@ import { mount, hydrate, unmount } from 'svelte'; -import App from './App.svelte'; +import App from './src/main.svelte'; const root = document.getElementById('root')!; const render = root.firstChild?.nextSibling ? hydrate : mount; @@ -7,6 +7,6 @@ const render = root.firstChild?.nextSibling ? hydrate : mount; const component = render(App, { target: document.getElementById('root')! }); + // @ts-ignore window.unmount = () => unmount(component); - diff --git a/playgrounds/demo/server.js b/playgrounds/demo/demo-server.js similarity index 83% rename from playgrounds/demo/server.js rename to playgrounds/demo/demo-server.js index 82a75e70e7..47702629b7 100644 --- a/playgrounds/demo/server.js +++ b/playgrounds/demo/demo-server.js @@ -32,11 +32,13 @@ async function createServer() { const template = fs.readFileSync(path.resolve(__dirname, 'index.html'), 'utf-8'); const transformed_template = await vite.transformIndexHtml(req.originalUrl, template); - const { body: appHtml, head: headHtml } = await vite.ssrLoadModule('./src/entry-server.ts'); + const { render } = await vite.ssrLoadModule('svelte/server'); + const { default: App } = await vite.ssrLoadModule('./src/main.svelte'); + const { head, body } = render(App); const html = transformed_template - .replace(``, appHtml) - .replace(``, headHtml); + .replace(``, head) + .replace(``, body); res.writeHead(200, { 'Content-Type': 'text/html' }).end(html); }); diff --git a/playgrounds/demo/index.html b/playgrounds/demo/index.html index d6ea134264..ddaccadff3 100644 --- a/playgrounds/demo/index.html +++ b/playgrounds/demo/index.html @@ -7,7 +7,7 @@
- - + +