sveltejs / sapper

The next small thing in web development, powered by Svelte
https://sapper.svelte.dev
MIT License
6.99k stars 432 forks source link

Add worker-dom option #367

Open Rich-Harris opened 6 years ago

Rich-Harris commented 6 years ago

This project is very interesting:

It's a little tricky to set up, because it expects the markup inside the root element to match what gets generated inside the worker. But Sapper could make it very easy.

Possible API:

import sirv from 'sirv';
import polka from 'polka';
import sapper from 'sapper';
import compression from 'compression';
import { manifest } from './manifest/server.js';

polka() // You can also use Express
    .use(
        compression({ threshold: 0 }),
        sirv('assets'),
-       sapper({ manifest })
+       sapper({
+           manifest,
+           workerdom: true
+       })
    )
    .listen(process.env.PORT)
    .catch(err => {
        console.log('error', err);
    })
Rich-Harris commented 6 years ago

One significant hurdle: you can't prevent event defaults. The client-side router depends on being able to intercept clicks on <a> elements, and prevent the default if it's to a URL belonging to the app.