Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite #409

Merged
merged 18 commits into from
Mar 2, 2021
Merged

Vite #409

merged 18 commits into from
Mar 2, 2021

Conversation

Rich-Harris
Copy link
Member

This PR switches the build system underlying SvelteKit, from Snowpack to Vite. This isn't a decision we're taking lightly, but after careful analysis we feel that it's the right one — while we had misgivings about Vite 1 (which gave Vue apps preferential treatment, and didn't really support SSR), Vite 2 does a really great job of solving some tricky problems that were previously in SvelteKit's domain, like CSS code-splitting or fixing stack traces during SSR. Since it's Rollup-based, it also means that SvelteKit apps can benefit from the very large ecosystem of Rollup plugins.

I did some spot checking on how this would affect things like build time and bundle sizes. I wasn't scientific about it and didn't take extensive notes, but the upshot was that Vite was slightly ahead on both fronts, but not to the extent that it was a significant factor in the decision.

Since Reddit code historians and others will no doubt find this PR once the repo goes public, I'll take this opportunity to make clear that we still think Snowpack is an excellent tool with a bright future. The only thing that has changed here is that Vite 2 came out and is uncannily well-designed for the details of the problems we're trying to solve, and we have a responsibility to pick the most appropriate tool for the job. (At present! We can expect more evolution in the unbundled dev server arena.)

One notable thing about this PR: it includes a @sveltejs/vite-plugin-svelte package, which is a fork of @dominikg's plugin that I added temporarily to work around a caching bug we found. In all likelihood we'll want to have some form of Vite plugin in this repo on a permanent basis, but it's not yet totally clear what that looks like — Dominik justifiably wants to keep the Svite plugin in an open repo, and this repo isn't open just yet. There's also rollup-plugin-svelte-hot; @rixo makes the point that we could potentially merge the Rollup and Vite plugins to the benefit of all (e.g. the Rollup plugin doesn't currently read svelte.config.js files). (It's a Vite plugin rather than a plain Rollup plugin because we need extra Vite-specific logic to take advantage of the HMR capabilities.) The good news is that this is a minor implementation detail from the perspective of SvelteKit users, and can be swapped around easily.

benmccann and others added 16 commits February 1, 2021 12:31
* WIP vite prod builds

* prettier

* HN example working, at least

* fix some stuff

* update config files

* various

* simplify

* simplify

* oops

* fix find_layout

* remove logging

* fix vite base path

* make vite a peer dependency

* let vite serve static assets

* get SSR CSS working

* remove unused code

* rename CLI

* simplify configs

* tweak relationship between different packages

* simplify app-utils

* update tests to remove app startup crashes in prod

* fix lockfile

* tweak some file locations etc, get some more tests passing

* get tests passing

* update lockfile

* update lockfile

* get all tests passing, locally at least

* remove snowpack-related stuff

* add vite-plugin-svelte to monorepo

* lint

* dont remove styles, it breaks stuff. TODO investigate

* Upgrade vite

* fix some sourcemap stuff

* remove vite-plugin-svelte from workspace until things settle down more

* fix lockfile

* gloss over import.meta transform bug for now

* hack around vite bugs until 2.0.4

* only lint src files

* remove source-map-support, it was causing weird stuff to happen

* ensure renderer waits for layout/error styles

* i really dont understand this lockfile bollocks

* Upgrade to vite 2.0.4

* add fork of @svitejs/vite-plugin-svelte back to monorepo

* lint

* make run in node 12

* ffffuuuuuuu

* Fix file path

* specify vite 2.0.4 everywhere

* add some logging to try and diagnose CI test failures

* fix output directories

* remove logging

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
examples/sandbox/src/routes/index.svelte Outdated Show resolved Hide resolved
@mrienstra
Copy link

For future historians: this PR dropped meriyah as well, presumably as a side-effect of dropping snowpack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants