sveltejs / sapper

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

Updates to Sapper for a smoother transition to SvelteKit #1791

Open btakita opened 2 years ago

btakita commented 2 years ago

Sapper development has ended but SvelteKit & Vite are not yet stable & currently not ready for some projects, particularly re: SSR issues (https://github.com/vitejs/vite/discussions/4230).

As anybody who has gone through a migration with a large project can attest to, unforeseen edge cases often occur. There is also hidden downstream technical risk to the SvelteKit migration being successful at this time. This often occurs where it's difficult to justify prioritizing the migration when balancing with client project needs.

In the meantime, some projects on Sapper are waiting for SvelteKit to mature to a point to where the risk of a migration is minimized. I went through the steps of transition to SvelteKit due to needing SPA support which will not occur with Sapper (https://github.com/sveltejs/sapper/issues/383), including converting all dependent libraries to "type": "module" among other changes suggested in https://kit.svelte.dev/migrating.

Now having to go back to supporting Sapper due to running into SSR issues including https://github.com/sveltejs/kit/issues/1947, I realize that Sapper does not support ES modules & has a different api from SvelteKit. It would be great if Sapper could be retrofitted to support some of the SvelteKit configurations & api so a future transition is made easier & the migration process can be de-risked by allowing failed migrations to be transitioned back to Sapper.

The changes should be minor, such as allowing rollup.config.mjs to support ES modules (https://github.com/sveltejs/sapper/issues/1204). Another nice to have would be support for the load (an alternative to preload) function with the same api as SvelteKit. Any other compatible SvelteKit updates can also be backported.

Deprecation of Sapper's unique api & compatible with SvelteKit behavior may also be useful to encourage existing Sapper projects to consider & move over to SvelteKit.

btakita commented 2 years ago

I have a PR cooking to add ESM support & a global fetch via server.mjs. There's a dependency PR for cheap-watch https://github.com/Conduitry/cheap-watch/pull/10. Since using a pnpm vendor multirepo to test this on my project, will need to have the cheap-watch PR merged before posting a PR for sapper.