It's very unlikely we'd be able to upgrade the Svelte REPL into something that could run SvelteKit apps (and therefore be suitable for a SvelteKit tutorial a la https://svelte.dev/tutorial). I had a conversation today with Eric Simons from StackBlitz about what a WebContainer-powered REPL might look like, and whether it's something the Svelte team would want to pursue.
We talked through all the bullet points below, and Eric addressed various concerns:
- Expecting browser support issues to be more or less resolved by end of Q1 2022, which is probably around the timeframe we'd be looking at
- Most of the startup time is downloading stuff from npm (and in a SvelteKit app, most of that is Vite; it's possible there's some stuff we could do to slim down that package). The WebContainer itself is around 2MB IIRC. In a non-Kit REPL we could potentially take a simpler approach that bypassed npm altogether; it should be possible to have things start up in around a second in a typical setup
- The interface would be fairly low-level — basically we get access to a filesystem, a terminal, and a way to detect servers listening. We have full control over the UI (in other words we could implement the existing tutorial experience with near 100% fidelity, including using a local copy of Svelte for testing in-development stuff)
- StackBlitz will be around for the forseeable :)
- Projects that need to download npm packages (i.e. the Kit REPL) would need to do so via StackBlitz's npm proxy, so there is a dependency. It might involve an API key; as yet unclear
I think this makes a lot of sense for us; I'm pretty sure this is the future of interactive tutorials.
- Full SvelteKit support, including e.g. HMR
- Corollary: we could build a SvelteKit tutorial. People fucking love the Svelte tutorial but it's unclear how we could make something similar for Kit without something like WebContainers
- Much smarter editor, including e.g. TypeScript support
- More stuff works (npm packages that are tricky to work with in the REPL, plus the REPL doesn't let you try out e.g. preprocessors)
- Less for us to maintain
- I often use the REPL to create mini apps for things I need in the moment, like this one — imagine being able to build and deploy prod-ready versions right from the REPL
- Currently Chrome-only, which feels like something of a dealbreaker
- It's pretty fast to start up, but the Svelte REPL is massively faster, partly because it has to download way less stuff (though on the flip side, the REPL has to rebundle your entire app, which is much slower. 1 point for the REPL, n points for WebContainers)
- Integration takes work
- Unclear how much control we would have over the UI etc
- StackBlitz could disappear in a puff of smoke
- Is this a product or a service? Would the REPL be tied to their servers? Would we need API/license keys or whatever?
- Would it be possible for people to run the REPL locally with a local copy of the Svelte compiler?
I'd like to hear more about this npm proxy. What is this doing, exactly? Will its behavior be documented and will it be open source?