Repository: sveltejs/kit
Pull request #6398 (2022-08-29 21:50:26)

[breaking] require Vite 3.1.0-beta.1
Normally we'd wait to do this, but given the severity of the issue, the fact that we're in pre-release, and the fact that the final release won't be until Friday we've decided to go ahead and do it now

Closes https://github.com/sveltejs/kit/issues/5952
Closes https://github.com/sveltejs/kit/issues/5843
Closes https://github.com/sveltejs/kit/issues/6239

changeset-bot[bot]: ###  🦋  Changeset detected

Latest commit: 30edb13c3e6697b39470b12536b0adebffff3ac2

**The changes in this PR will be included in the next version bump.**

<details><summary>This PR includes changesets to release 1 package</summary>

  | Name          | Type  |
| ------------- | ----- |
| @sveltejs/kit | Patch |

</details>

Not sure what this means? [Click here  to learn what changesets are](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/benmccann/kit/new/vite-3.1.0-beta.1?filename=.changeset/beige-oranges-love.md&value=---%0A%22%40sveltejs%2Fadapter-netlify%22%3A%20patch%0A%22%40sveltejs%2Fadapter-node%22%3A%20patch%0A%22%40sveltejs%2Fadapter-static%22%3A%20patch%0A%22create-svelte%22%3A%20patch%0A%22%40sveltejs%2Fkit%22%3A%20patch%0A%22kit.svelte.dev%22%3A%20patch%0A%22~TODO~%22%3A%20patch%0A%22~TODO~%22%3A%20patch%0A%22test-amp%22%3A%20patch%0A%22test-basics%22%3A%20patch%0A%22test-basics%22%3A%20patch%0A%22test-options-2%22%3A%20patch%0A%22test-options%22%3A%20patch%0A%22test-writes%22%3A%20patch%0A%22prerendering-test-basics%22%3A%20patch%0A%22prerendering-test-disabled%22%3A%20patch%0A%22prerendering-test-options%22%3A%20patch%0A%22prerendering-test-paths-base%22%3A%20patch%0A%22prerendering-test-trailing-slash%22%3A%20patch%0A%22default-template%22%3A%20patch%0A---%0A%0A%5Bbreaking%5D%20require%20Vite%203.1.0-beta.1%0A)



Patch:
diff --git a/.changeset/big-trainers-love.md b/.changeset/big-trainers-love.md
new file mode 100644
index 000000000..166f2fc7f
--- /dev/null
+++ b/.changeset/big-trainers-love.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/adapter-node': patch
+---
+
+Bundle non-production dependencies with esbuild
diff --git a/.changeset/brown-doors-bathe.md b/.changeset/brown-doors-bathe.md
new file mode 100644
index 000000000..ded0424db
--- /dev/null
+++ b/.changeset/brown-doors-bathe.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+[breaking] require Vite 3.1.0-beta.1
diff --git a/.changeset/pre.json b/.changeset/pre.json
index 43d0bd717..bfba1c7ea 100644
--- a/.changeset/pre.json
+++ b/.changeset/pre.json
@@ -59,6 +59,7 @@
     "big-cups-exist",
     "big-garlics-complain",
     "big-houses-bow",
+    "big-trainers-love",
     "blue-apes-type",
     "blue-bees-jump",
     "blue-bulldogs-visit",
diff --git a/package.json b/package.json
index 24546d50b..e4f3a76d9 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,7 @@
 		"@svitejs/changesets-changelog-github-compact": "^0.1.1",
 		"playwright": "^1.25.0",
 		"prettier": "^2.6.2",
-		"rollup": "^2.75.7",
+		"rollup": "^2.78.1",
 		"svelte": "^3.48.0",
 		"tiny-glob": "^0.2.9",
 		"turbo": "^1.3.4",
diff --git a/packages/adapter-netlify/package.json b/packages/adapter-netlify/package.json
index 350642abb..143eecb53 100644
--- a/packages/adapter-netlify/package.json
+++ b/packages/adapter-netlify/package.json
@@ -46,7 +46,7 @@
 		"@types/node": "^16.11.36",
 		"@types/set-cookie-parser": "^2.4.2",
 		"rimraf": "^3.0.2",
-		"rollup": "^2.75.7",
+		"rollup": "^2.78.1",
 		"typescript": "^4.7.4",
 		"uvu": "^0.5.3"
 	}
diff --git a/packages/adapter-node/CHANGELOG.md b/packages/adapter-node/CHANGELOG.md
index 0696f850c..3672aabb2 100644
--- a/packages/adapter-node/CHANGELOG.md
+++ b/packages/adapter-node/CHANGELOG.md
@@ -1,5 +1,11 @@
 # @sveltejs/adapter-node
 
+## 1.0.0-next.88
+
+### Patch Changes
+
+- Bundle non-production dependencies with esbuild ([#6372](https://github.com/sveltejs/kit/pull/6372))
+
 ## 1.0.0-next.87
 
 ### Patch Changes
diff --git a/packages/adapter-node/README.md b/packages/adapter-node/README.md
index a7e7ed52b..80dc3d2a9 100644
--- a/packages/adapter-node/README.md
+++ b/packages/adapter-node/README.md
@@ -140,12 +140,14 @@ app.listen(3000, () => {
 
 ## Deploying
 
-You will need the output directory (`build` by default), the project's `package.json`, and the production dependencies in `node_modules` to run the application. Production dependencies can be generated with `npm ci --prod`, you can also skip this step if your app doesn't have any dependencies. You can then start your app with
+You will need the output directory (`build` by default), the project's `package.json`, and the production dependencies in `node_modules` to run the application. Production dependencies can be generated with `npm ci --prod` (you can skip this step if your app doesn't have any dependencies). You can then start your app with
 
 ```bash
 node build
 ```
 
+Development dependencies will be bundled into your app using `esbuild`. To control whether a given package is bundled or externalised, place it in `devDependencies` or `dependencies` respectively in your `package.json`.
+
 ## Changelog
 
 [The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/master/packages/adapter-node/CHANGELOG.md).
diff --git a/packages/adapter-node/ambient.d.ts b/packages/adapter-node/ambient.d.ts
index 537f7cc04..15d554182 100644
--- a/packages/adapter-node/ambient.d.ts
+++ b/packages/adapter-node/ambient.d.ts
@@ -1,8 +1,16 @@
-declare module 'SERVER' {
-	export { Server } from '@sveltejs/kit';
+declare module 'ENV' {
+	export function env(key: string, fallback?: any): string;
+}
+
+declare module 'HANDLER' {
+	export const handler: import('polka').Middleware;
 }
 
 declare module 'MANIFEST' {
 	import { SSRManifest } from '@sveltejs/kit';
 	export const manifest: SSRManifest;
 }
+
+declare module 'SERVER' {
+	export { Server } from '@sveltejs/kit';
+}
diff --git a/packages/adapter-node/index.js b/packages/adapter-node/index.js
index ef6e8adab..48a0ac5c3 100644
--- a/packages/adapter-node/index.js
+++ b/packages/adapter-node/index.js
@@ -1,5 +1,6 @@
-import { writeFileSync } from 'fs';
+import { readFileSync, writeFileSync } from 'fs';
 import { fileURLToPath } from 'url';
+import * as esbuild from 'esbuild';
 
 const files = fileURLToPath(new URL('./files', import.meta.url).href);
 
@@ -19,33 +20,54 @@ export default function (opts = {}) {
 		name: '@sveltejs/adapter-node',
 
 		async adapt(builder) {
+			const tmp = builder.getBuildDirectory('adapter-node');
+
 			builder.rimraf(out);
+			builder.rimraf(tmp);
+			builder.mkdirp(tmp);
 
 			builder.log.minor('Copying assets');
 			builder.writeClient(`${out}/client`);
-			builder.writeServer(`${out}/server`);
 			builder.writePrerendered(`${out}/prerendered`);
 
+			if (precompress) {
+				builder.log.minor('Compressing assets');
+				await builder.compress(`${out}/client`);
+				await builder.compress(`${out}/prerendered`);
+			}
+
+			builder.log.minor('Building server');
+
+			builder.writeServer(tmp);
+
 			writeFileSync(
-				`${out}/manifest.js`,
-				`export const manifest = ${builder.generateManifest({
-					relativePath: './server'
-				})};\n`
+				`${tmp}/manifest.js`,
+				`export const manifest = ${builder.generateManifest({ relativePath: './' })};`
 			);
 
+			const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
+
+			await esbuild.build({
+				platform: 'node',
+				sourcemap: 'linked',
+				target: 'es2022',
+				entryPoints: [`${tmp}/index.js`, `${tmp}/manifest.js`],
+				outdir: `${out}/server`,
+				splitting: true,
+				format: 'esm',
+				bundle: true,
+				external: [...Object.keys(pkg.dependencies || {})]
+			});
+
 			builder.copy(files, out, {
 				replace: {
-					SERVER: './server/index.js',
-					MANIFEST: './manifest.js',
+					ENV: './env.js',
+					HANDLER: './handler.js',
+					MANIFEST: './server/manifest.js',
+					SERVER: `./server/index.js`,
 					ENV_PREFIX: JSON.stringify(envPrefix)
 				}
 			});
-
-			if (precompress) {
-				builder.log.minor('Compressing assets');
-				await builder.compress(`${out}/client`);
-				await builder.compress(`${out}/prerendered`);
-			}
 		}
 	};
 }
diff --git a/packages/adapter-node/package.json b/packages/adapter-node/package.json
index 9e5639075..97189d21d 100644
--- a/packages/adapter-node/package.json
+++ b/packages/adapter-node/package.json
@@ -1,6 +1,6 @@
 {
 	"name": "@sveltejs/adapter-node",
-	"version": "1.0.0-next.87",
+	"version": "1.0.0-next.88",
 	"repository": {
 		"type": "git",
 		"url": "https://github.com/sveltejs/kit",
@@ -39,9 +39,12 @@
 		"node-fetch": "^3.2.4",
 		"polka": "^1.0.0-next.22",
 		"rimraf": "^3.0.2",
-		"rollup": "^2.75.7",
+		"rollup": "^2.78.1",
 		"sirv": "^2.0.2",
 		"typescript": "^4.7.4",
 		"uvu": "^0.5.3"
+	},
+	"dependencies": {
+		"esbuild": "^0.14.48"
 	}
 }
diff --git a/packages/adapter-node/rollup.config.js b/packages/adapter-node/rollup.config.js
index 9bd5c9970..6384234b2 100644
--- a/packages/adapter-node/rollup.config.js
+++ b/packages/adapter-node/rollup.config.js
@@ -1,19 +1,35 @@
 import { nodeResolve } from '@rollup/plugin-node-resolve';
 import commonjs from '@rollup/plugin-commonjs';
 import json from '@rollup/plugin-json';
+import { builtinModules } from 'module';
 
 export default [
 	{
-		input: {
-			index: 'src/index.js',
-			handler: 'src/handler.js',
-			shims: 'src/shims.js'
+		input: 'src/index.js',
+		output: {
+			file: 'files/index.js',
+			format: 'esm'
 		},
+		plugins: [nodeResolve(), commonjs(), json()],
+		external: ['ENV', 'HANDLER', ...builtinModules]
+	},
+	{
+		input: 'src/env.js',
 		output: {
-			dir: 'files',
+			file: 'files/env.js',
 			format: 'esm'
 		},
 		plugins: [nodeResolve(), commonjs(), json()],
-		external: ['SERVER', 'MANIFEST', ...require('module').builtinModules]
+		external: ['HANDLER', ...builtinModules]
+	},
+	{
+		input: 'src/handler.js',
+		output: {
+			file: 'files/handler.js',
+			format: 'esm',
+			inlineDynamicImports: true
+		},
+		plugins: [nodeResolve(), commonjs(), json()],
+		external: ['ENV', 'MANIFEST', 'SERVER', ...builtinModules]
 	}
 ];
diff --git a/packages/adapter-node/src/handler.js b/packages/adapter-node/src/handler.js
index d90bce52d..b0951fccd 100644
--- a/packages/adapter-node/src/handler.js
+++ b/packages/adapter-node/src/handler.js
@@ -6,7 +6,7 @@ import { fileURLToPath } from 'url';
 import { getRequest, setResponse } from '@sveltejs/kit/node';
 import { Server } from 'SERVER';
 import { manifest } from 'MANIFEST';
-import { env } from './env.js';
+import { env } from 'ENV';
 
 /* global ENV_PREFIX */
 
@@ -19,7 +19,7 @@ const address_header = env('ADDRESS_HEADER', '').toLowerCase();
 const protocol_header = env('PROTOCOL_HEADER', '').toLowerCase();
 const host_header = env('HOST_HEADER', 'host').toLowerCase();
 
-const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const dir = path.dirname(fileURLToPath(import.meta.url));
 
 /**
  * @param {string} path
@@ -132,9 +132,9 @@ function get_origin(headers) {
 
 export const handler = sequence(
 	[
-		serve(path.join(__dirname, '/client'), true),
-		serve(path.join(__dirname, '/static')),
-		serve(path.join(__dirname, '/prerendered')),
+		serve(path.join(dir, 'client'), true),
+		serve(path.join(dir, 'static')),
+		serve(path.join(dir, 'prerendered')),
 		ssr
 	].filter(Boolean)
 );
diff --git a/packages/adapter-node/src/index.js b/packages/adapter-node/src/index.js
index 5832b244a..ea3feee05 100644
--- a/packages/adapter-node/src/index.js
+++ b/packages/adapter-node/src/index.js
@@ -1,5 +1,5 @@
-import { handler } from './handler.js';
-import { env } from './env.js';
+import { handler } from 'HANDLER';
+import { env } from 'ENV';
 import polka from 'polka';
 
 export const path = env('SOCKET_PATH', false);
diff --git a/packages/adapter-static/package.json b/packages/adapter-static/package.json
index 28fa9863b..74f0bb4c6 100644
--- a/packages/adapter-static/package.json
+++ b/packages/adapter-static/package.json
@@ -32,6 +32,6 @@
 		"svelte": "^3.48.0",
 		"typescript": "^4.7.4",
 		"uvu": "^0.5.3",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	}
 }
diff --git a/packages/create-svelte/templates/default/package.json b/packages/create-svelte/templates/default/package.json
index 5766fd226..534581b40 100644
--- a/packages/create-svelte/templates/default/package.json
+++ b/packages/create-svelte/templates/default/package.json
@@ -13,7 +13,7 @@
 		"svelte": "^3.48.0",
 		"svelte-preprocess": "^4.10.6",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module",
 	"dependencies": {
diff --git a/packages/create-svelte/templates/default/package.template.json b/packages/create-svelte/templates/default/package.template.json
index 945fa4f25..a8dddd263 100644
--- a/packages/create-svelte/templates/default/package.template.json
+++ b/packages/create-svelte/templates/default/package.template.json
@@ -10,7 +10,7 @@
 		"@sveltejs/adapter-auto": "next",
 		"@sveltejs/kit": "next",
 		"svelte": "^3.46.0",
-		"vite": "^3.0.8"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module",
 	"dependencies": {
diff --git a/packages/create-svelte/templates/libskeleton/package.template.json b/packages/create-svelte/templates/libskeleton/package.template.json
index e154bd154..43a052472 100644
--- a/packages/create-svelte/templates/libskeleton/package.template.json
+++ b/packages/create-svelte/templates/libskeleton/package.template.json
@@ -12,7 +12,7 @@
 		"svelte": "^3.44.0",
 		"tslib": "^2.3.1",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.0"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/create-svelte/templates/skeleton/package.template.json b/packages/create-svelte/templates/skeleton/package.template.json
index 0d2623c4e..956d2c910 100644
--- a/packages/create-svelte/templates/skeleton/package.template.json
+++ b/packages/create-svelte/templates/skeleton/package.template.json
@@ -11,7 +11,7 @@
 		"@sveltejs/adapter-auto": "workspace:*",
 		"@sveltejs/kit": "workspace:*",
 		"svelte": "^3.44.0",
-		"vite": "^3.0.4"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/package.json b/packages/kit/package.json
index 61a378d30..8ba661b3d 100644
--- a/packages/kit/package.json
+++ b/packages/kit/package.json
@@ -33,16 +33,16 @@
 		"@types/sade": "^1.7.4",
 		"@types/set-cookie-parser": "^2.4.2",
 		"marked": "^4.0.16",
-		"rollup": "^2.75.7",
+		"rollup": "^2.78.1",
 		"svelte": "^3.48.0",
 		"svelte-preprocess": "^4.10.6",
 		"typescript": "^4.7.4",
 		"uvu": "^0.5.3",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"peerDependencies": {
 		"svelte": "^3.44.0",
-		"vite": "^3.0.0"
+		"vite": "^3.1.0-beta.1"
 	},
 	"bin": {
 		"svelte-kit": "svelte-kit.js"
diff --git a/packages/kit/src/exports/vite/index.js b/packages/kit/src/exports/vite/index.js
index ecdcc7d3e..7f56d9e46 100644
--- a/packages/kit/src/exports/vite/index.js
+++ b/packages/kit/src/exports/vite/index.js
@@ -333,152 +333,162 @@ function kit() {
 		 * The user's package.json scripts will invoke the Vite CLI to execute the client build. We
 		 * then use this hook to kick off builds for the server and service worker.
 		 */
-		async writeBundle(_options, bundle) {
-			if (vite_config.build.ssr) {
-				return;
-			}
+		writeBundle: {
+			sequential: true,
+			async handler(_options, bundle) {
+				if (vite_config.build.ssr) {
+					return;
+				}
+
+				manifest_data.nodes.forEach((_node, i) => {
+					const id = vite.normalizePath(
+						path.resolve(svelte_config.kit.outDir, `generated/nodes/${i}.js`)
+					);
+
+					const module_node = this.getModuleInfo(id);
+
+					if (module_node) {
+						prevent_illegal_rollup_imports(
+							this.getModuleInfo.bind(this),
+							module_node,
+							illegal_imports
+						);
+					}
+				});
 
-			manifest_data.nodes.forEach((_node, i) => {
-				const id = vite.normalizePath(
-					path.resolve(svelte_config.kit.outDir, `generated/nodes/${i}.js`)
+				const verbose = vite_config.logLevel === 'info';
+				log = logger({
+					verbose
+				});
+
+				fs.writeFileSync(
+					`${paths.client_out_dir}/${svelte_config.kit.appDir}/version.json`,
+					JSON.stringify({ version: svelte_config.kit.version.name })
+				);
+
+				const { assets, chunks } = collect_output(bundle);
+				log.info(
+					`Client build completed. Wrote ${chunks.length} chunks and ${assets.length} assets`
+				);
+
+				log.info('Building server');
+				const options = {
+					cwd,
+					config: svelte_config,
+					vite_config,
+					vite_config_env,
+					build_dir: paths.build_dir, // TODO just pass `paths`
+					manifest_data,
+					output_dir: paths.output_dir,
+					service_worker_entry_file: resolve_entry(svelte_config.kit.files.serviceWorker)
+				};
+				const client = client_build_info(assets, chunks);
+				const server = await build_server(options, client);
+
+				/** @type {import('types').BuildData} */
+				build_data = {
+					app_dir: svelte_config.kit.appDir,
+					manifest_data,
+					service_worker: options.service_worker_entry_file ? 'service-worker.js' : null, // TODO make file configurable?
+					client,
+					server
+				};
+
+				const manifest_path = `${paths.output_dir}/server/manifest.js`;
+				fs.writeFileSync(
+					manifest_path,
+					`export const manifest = ${generate_manifest({
+						build_data,
+						relative_path: '.',
+						routes: manifest_data.routes
+					})};\n`
 				);
 
-				const module_node = this.getModuleInfo(id);
+				log.info('Prerendering');
+				await new Promise((fulfil, reject) => {
+					const results_path = `${svelte_config.kit.outDir}/generated/prerendered.json`;
 
-				if (module_node) {
-					prevent_illegal_rollup_imports(
-						this.getModuleInfo.bind(this),
-						module_node,
-						illegal_imports
+					// do prerendering in a subprocess so any dangling stuff gets killed upon completion
+					const script = fileURLToPath(
+						new URL('../../core/prerender/prerender.js', import.meta.url)
 					);
-				}
-			});
-
-			const verbose = vite_config.logLevel === 'info';
-			log = logger({
-				verbose
-			});
-
-			fs.writeFileSync(
-				`${paths.client_out_dir}/${svelte_config.kit.appDir}/version.json`,
-				JSON.stringify({ version: svelte_config.kit.version.name })
-			);
-
-			const { assets, chunks } = collect_output(bundle);
-			log.info(`Client build completed. Wrote ${chunks.length} chunks and ${assets.length} assets`);
-
-			log.info('Building server');
-			const options = {
-				cwd,
-				config: svelte_config,
-				vite_config,
-				vite_config_env,
-				build_dir: paths.build_dir, // TODO just pass `paths`
-				manifest_data,
-				output_dir: paths.output_dir,
-				service_worker_entry_file: resolve_entry(svelte_config.kit.files.serviceWorker)
-			};
-			const client = client_build_info(assets, chunks);
-			const server = await build_server(options, client);
-
-			/** @type {import('types').BuildData} */
-			build_data = {
-				app_dir: svelte_config.kit.appDir,
-				manifest_data,
-				service_worker: options.service_worker_entry_file ? 'service-worker.js' : null, // TODO make file configurable?
-				client,
-				server
-			};
 
-			const manifest_path = `${paths.output_dir}/server/manifest.js`;
-			fs.writeFileSync(
-				manifest_path,
-				`export const manifest = ${generate_manifest({
-					build_data,
-					relative_path: '.',
-					routes: manifest_data.routes
-				})};\n`
-			);
-
-			log.info('Prerendering');
-			await new Promise((fulfil, reject) => {
-				const results_path = `${svelte_config.kit.outDir}/generated/prerendered.json`;
-
-				// do prerendering in a subprocess so any dangling stuff gets killed upon completion
-				const script = fileURLToPath(new URL('../../core/prerender/prerender.js', import.meta.url));
-
-				const child = fork(
-					script,
-					[
-						vite_config.build.outDir,
-						results_path,
-						manifest_path,
-						'' + verbose,
-						JSON.stringify({ ...env.private, ...env.public })
-					],
-					{
-						stdio: 'inherit'
-					}
-				);
+					const child = fork(
+						script,
+						[
+							vite_config.build.outDir,
+							results_path,
+							manifest_path,
+							'' + verbose,
+							JSON.stringify({ ...env.private, ...env.public })
+						],
+						{
+							stdio: 'inherit'
+						}
+					);
 
-				child.on('exit', (code) => {
-					if (code) {
-						reject(new Error(`Prerendering failed with code ${code}`));
-					} else {
-						prerendered = JSON.parse(fs.readFileSync(results_path, 'utf8'), (key, value) => {
-							if (key === 'pages' || key === 'assets' || key === 'redirects') {
-								return new Map(value);
-							}
-							return value;
-						});
-						fulfil(undefined);
-					}
+					child.on('exit', (code) => {
+						if (code) {
+							reject(new Error(`Prerendering failed with code ${code}`));
+						} else {
+							prerendered = JSON.parse(fs.readFileSync(results_path, 'utf8'), (key, value) => {
+								if (key === 'pages' || key === 'assets' || key === 'redirects') {
+									return new Map(value);
+								}
+								return value;
+							});
+							fulfil(undefined);
+						}
+					});
 				});
-			});
 
-			if (options.service_worker_entry_file) {
-				if (svelte_config.kit.paths.assets) {
-					throw new Error('Cannot use service worker alongside config.kit.paths.assets');
-				}
+				if (options.service_worker_entry_file) {
+					if (svelte_config.kit.paths.assets) {
+						throw new Error('Cannot use service worker alongside config.kit.paths.assets');
+					}
 
-				log.info('Building service worker');
+					log.info('Building service worker');
 
-				await build_service_worker(options, prerendered, client.vite_manifest);
-			}
+					await build_service_worker(options, prerendered, client.vite_manifest);
+				}
 
-			console.log(
-				`\nRun ${colors.bold().cyan('npm run preview')} to preview your production build locally.`
-			);
+				console.log(
+					`\nRun ${colors.bold().cyan('npm run preview')} to preview your production build locally.`
+				);
 
-			completed_build = true;
+				completed_build = true;
+			}
 		},
 
 		/**
 		 * Runs the adapter.
 		 */
-		async closeBundle() {
-			// vite calls closeBundle when dev-server restarts, ignore that,
-			// and only adapt when build successfully completes.
-			const is_restart = !completed_build;
-			if (vite_config.build.ssr || is_restart) {
-				return;
-			}
+		closeBundle: {
+			sequential: true,
+			async handler() {
+				// vite calls closeBundle when dev-server restarts, ignore that,
+				// and only adapt when build successfully completes.
+				const is_restart = !completed_build;
+				if (vite_config.build.ssr || is_restart) {
+					return;
+				}
 
-			if (svelte_config.kit.adapter) {
-				const { adapt } = await import('../../core/adapt/index.js');
-				await adapt(svelte_config, build_data, prerendered, { log });
-			} else {
-				console.log(colors.bold().yellow('\nNo adapter specified'));
+				if (svelte_config.kit.adapter) {
+					const { adapt } = await import('../../core/adapt/index.js');
+					await adapt(svelte_config, build_data, prerendered, { log });
+				} else {
+					console.log(colors.bold().yellow('\nNo adapter specified'));
 
-				const link = colors.bold().cyan('https://kit.svelte.dev/docs/adapters');
-				console.log(
-					`See ${link} to learn how to configure your app to run on the platform of your choosing`
-				);
-			}
+					const link = colors.bold().cyan('https://kit.svelte.dev/docs/adapters');
+					console.log(
+						`See ${link} to learn how to configure your app to run on the platform of your choosing`
+					);
+				}
 
-			// avoid making the manifest available to users
-			fs.unlinkSync(`${paths.output_dir}/client/${vite_config.build.manifest}`);
-			fs.unlinkSync(`${paths.output_dir}/server/${vite_config.build.manifest}`);
+				// avoid making the manifest available to users
+				fs.unlinkSync(`${paths.output_dir}/client/${vite_config.build.manifest}`);
+				fs.unlinkSync(`${paths.output_dir}/server/${vite_config.build.manifest}`);
+			}
 		},
 
 		/**
diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts
index f5033d642..a4b9cb024 100644
--- a/packages/kit/types/index.d.ts
+++ b/packages/kit/types/index.d.ts
@@ -99,7 +99,7 @@ export interface Builder {
 	/**
 	 * @param {string} directory Path to the directory containing the files to be compressed
 	 */
-	compress(directory: string): void;
+	compress(directory: string): Promise<void>;
 }
 
 export interface Config {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 45616a3e9..35a127b6a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -11,20 +11,20 @@ importers:
       '@svitejs/changesets-changelog-github-compact': ^0.1.1
       playwright: ^1.25.0
       prettier: ^2.6.2
-      rollup: ^2.75.7
+      rollup: ^2.78.1
       svelte: ^3.48.0
       tiny-glob: ^0.2.9
       turbo: ^1.3.4
       typescript: ^4.7.4
     devDependencies:
       '@changesets/cli': 2.23.0
-      '@rollup/plugin-commonjs': 22.0.1_rollup@2.75.7
-      '@rollup/plugin-json': 4.1.0_rollup@2.75.7
-      '@rollup/plugin-node-resolve': 13.3.0_rollup@2.75.7
+      '@rollup/plugin-commonjs': 22.0.1_rollup@2.78.1
+      '@rollup/plugin-json': 4.1.0_rollup@2.78.1
+      '@rollup/plugin-node-resolve': 13.3.0_rollup@2.78.1
       '@svitejs/changesets-changelog-github-compact': 0.1.1
       playwright: 1.25.0
       prettier: 2.7.1
-      rollup: 2.75.7
+      rollup: 2.78.1
       svelte: 3.48.0
       tiny-glob: 0.2.9
       turbo: 1.3.4
@@ -91,7 +91,7 @@ importers:
       '@types/set-cookie-parser': ^2.4.2
       esbuild: ^0.14.48
       rimraf: ^3.0.2
-      rollup: ^2.75.7
+      rollup: ^2.78.1
       set-cookie-parser: ^2.4.8
       tiny-glob: ^0.2.9
       typescript: ^4.7.4
@@ -103,14 +103,14 @@ importers:
       tiny-glob: 0.2.9
     devDependencies:
       '@netlify/functions': 1.0.0
-      '@rollup/plugin-commonjs': 22.0.1_rollup@2.75.7
-      '@rollup/plugin-json': 4.1.0_rollup@2.75.7
-      '@rollup/plugin-node-resolve': 13.3.0_rollup@2.75.7
+      '@rollup/plugin-commonjs': 22.0.1_rollup@2.78.1
+      '@rollup/plugin-json': 4.1.0_rollup@2.78.1
+      '@rollup/plugin-node-resolve': 13.3.0_rollup@2.78.1
       '@sveltejs/kit': link:../kit
       '@types/node': 16.11.42
       '@types/set-cookie-parser': 2.4.2
       rimraf: 3.0.2
-      rollup: 2.75.7
+      rollup: 2.78.1
       typescript: 4.7.4
       uvu: 0.5.4
 
@@ -120,22 +120,25 @@ importers:
       '@sveltejs/kit': workspace:*
       '@types/node': ^16.11.36
       c8: ^7.11.3
+      esbuild: ^0.14.48
       node-fetch: ^3.2.4
       polka: ^1.0.0-next.22
       rimraf: ^3.0.2
-      rollup: ^2.75.7
+      rollup: ^2.78.1
       sirv: ^2.0.2
       typescript: ^4.7.4
       uvu: ^0.5.3
+    dependencies:
+      esbuild: 0.14.54
     devDependencies:
-      '@rollup/plugin-json': 4.1.0_rollup@2.75.7
+      '@rollup/plugin-json': 4.1.0_rollup@2.78.1
       '@sveltejs/kit': link:../kit
       '@types/node': 16.11.42
       c8: 7.11.3
       node-fetch: 3.2.6
       polka: 1.0.0-next.22
       rimraf: 3.0.2
-      rollup: 2.75.7
+      rollup: 2.78.1
       sirv: 2.0.2
       typescript: 4.7.4
       uvu: 0.5.4
@@ -149,7 +152,7 @@ importers:
       svelte: ^3.48.0
       typescript: ^4.7.4
       uvu: ^0.5.3
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/kit': link:../kit
       '@types/node': 16.11.42
@@ -158,17 +161,17 @@ importers:
       svelte: 3.48.0
       typescript: 4.7.4
       uvu: 0.5.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/adapter-static/test/apps/prerendered:
     specifiers:
       '@sveltejs/kit': workspace:*
       svelte: ^3.48.0
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/kit': link:../../../../kit
       svelte: 3.48.0
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/adapter-static/test/apps/spa:
     specifiers:
@@ -176,13 +179,13 @@ importers:
       '@sveltejs/kit': workspace:*
       sirv-cli: ^2.0.2
       svelte: ^3.48.0
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/adapter-node': link:../../../../adapter-node
       '@sveltejs/kit': link:../../../../kit
       sirv-cli: 2.0.2
       svelte: 3.48.0
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/adapter-vercel:
     specifiers:
@@ -247,7 +250,7 @@ importers:
       svelte: ^3.48.0
       svelte-preprocess: ^4.10.6
       typescript: ^4.7.4
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     dependencies:
       '@fontsource/fira-mono': 4.5.8
       '@lukeed/uuid': 2.0.0
@@ -258,7 +261,7 @@ importers:
       svelte: 3.48.0
       svelte-preprocess: 4.10.7_lvfi2wesz6u4l5rfbnetbucfmm
       typescript: 4.7.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/create-svelte/templates/skeleton:
     specifiers:
@@ -284,7 +287,7 @@ importers:
       marked: ^4.0.16
       mime: ^3.0.0
       node-fetch: ^3.2.4
-      rollup: ^2.75.7
+      rollup: ^2.78.1
       sade: ^1.8.1
       set-cookie-parser: ^2.4.8
       sirv: ^2.0.2
@@ -294,9 +297,9 @@ importers:
       typescript: ^4.7.4
       undici: ^5.8.1
       uvu: ^0.5.3
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     dependencies:
-      '@sveltejs/vite-plugin-svelte': 1.0.1_svelte@3.48.0+vite@3.0.9
+      '@sveltejs/vite-plugin-svelte': 1.0.1_le3uwffmhe7iwfccb43atcj5xe
       cookie: 0.5.0
       devalue: 3.1.2
       kleur: 4.1.5
@@ -318,12 +321,12 @@ importers:
       '@types/sade': 1.7.4
       '@types/set-cookie-parser': 2.4.2
       marked: 4.0.17
-      rollup: 2.75.7
+      rollup: 2.78.1
       svelte: 3.48.0
       svelte-preprocess: 4.10.7_lvfi2wesz6u4l5rfbnetbucfmm
       typescript: 4.7.4
       uvu: 0.5.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/kit/test/apps/amp:
     specifiers:
@@ -334,7 +337,7 @@ importers:
       svelte: ^3.48.0
       svelte-check: ^2.7.1
       typescript: ^4.7.4
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/amp': link:../../../../amp
       '@sveltejs/kit': link:../../..
@@ -343,7 +346,7 @@ importers:
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.7.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/kit/test/apps/basics:
     specifiers:
@@ -353,7 +356,7 @@ importers:
       svelte: ^3.48.0
       svelte-check: ^2.7.1
       typescript: ^4.7.4
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/kit': link:../../..
       cross-env: 7.0.3
@@ -361,7 +364,7 @@ importers:
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.7.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/kit/test/apps/dev-only:
     specifiers:
@@ -371,7 +374,7 @@ importers:
       svelte: ^3.48.0
       svelte-check: ^2.7.1
       typescript: ^4.7.4
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/kit': link:../../..
       cross-env: 7.0.3
@@ -379,7 +382,7 @@ importers:
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.7.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/kit/test/apps/options:
     specifiers:
@@ -388,14 +391,14 @@ importers:
       svelte: ^3.48.0
       svelte-check: ^2.7.1
       typescript: ^4.7.4
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/kit': link:../../..
       cross-env: 7.0.3
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.7.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/kit/test/apps/options-2:
     specifiers:
@@ -405,7 +408,7 @@ importers:
       svelte: ^3.48.0
       svelte-check: ^2.7.1
       typescript: ^4.7.4
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/adapter-node': link:../../../../adapter-node
       '@sveltejs/kit': link:../../..
@@ -413,7 +416,7 @@ importers:
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.7.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/kit/test/apps/writes:
     specifiers:
@@ -423,7 +426,7 @@ importers:
       svelte: ^3.48.0
       svelte-check: ^2.7.1
       typescript: ^4.7.4
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/kit': link:../../..
       cross-env: 7.0.3
@@ -431,7 +434,7 @@ importers:
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.7.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/kit/test/prerendering/basics:
     specifiers:
@@ -440,14 +443,14 @@ importers:
       svelte-check: ^2.7.1
       typescript: ^4.7.4
       uvu: ^0.5.3
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/kit': link:../../..
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.7.4
       uvu: 0.5.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/kit/test/prerendering/fallback:
     specifiers:
@@ -456,14 +459,14 @@ importers:
       svelte-check: ^2.7.1
       typescript: ^4.7.4
       uvu: ^0.5.3
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/kit': link:../../..
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.7.4
       uvu: 0.5.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/kit/test/prerendering/options:
     specifiers:
@@ -472,14 +475,14 @@ importers:
       svelte-check: ^2.7.1
       typescript: ^4.7.4
       uvu: ^0.5.3
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/kit': link:../../..
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.7.4
       uvu: 0.5.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/kit/test/prerendering/paths-base:
     specifiers:
@@ -488,14 +491,14 @@ importers:
       svelte-check: ^2.7.1
       typescript: ^4.7.4
       uvu: ^0.5.3
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/kit': link:../../..
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.7.4
       uvu: 0.5.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/kit/test/prerendering/trailing-slash:
     specifiers:
@@ -504,14 +507,14 @@ importers:
       svelte-check: ^2.7.1
       typescript: ^4.7.4
       uvu: ^0.5.4
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
     devDependencies:
       '@sveltejs/kit': link:../../..
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.7.4
       uvu: 0.5.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
 
   packages/migrate:
     specifiers:
@@ -572,7 +575,7 @@ importers:
       shiki-twoslash: ^3.0.2
       svelte: ^3.48.0
       typescript: ^4.7.4
-      vite: ^3.0.9
+      vite: ^3.1.0-beta.1
       vite-imagetools: ^4.0.3
     devDependencies:
       '@sveltejs/adapter-auto': link:../../packages/adapter-auto
@@ -588,7 +591,7 @@ importers:
       shiki-twoslash: 3.1.0
       svelte: 3.48.0
       typescript: 4.7.4
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
       vite-imagetools: 4.0.4
 
 packages:
@@ -954,47 +957,47 @@ packages:
   /@polka/url/1.0.0-next.21:
     resolution: {integrity: sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==}
 
-  /@rollup/plugin-commonjs/22.0.1_rollup@2.75.7:
+  /@rollup/plugin-commonjs/22.0.1_rollup@2.78.1:
     resolution: {integrity: sha512-dGfEZvdjDHObBiP5IvwTKMVeq/tBZGMBHZFMdIV1ClMM/YoWS34xrHFGfag9SN2ZtMgNZRFruqvxZQEa70O6nQ==}
     engines: {node: '>= 12.0.0'}
     peerDependencies:
       rollup: ^2.68.0
     dependencies:
-      '@rollup/pluginutils': 3.1.0_rollup@2.75.7
+      '@rollup/pluginutils': 3.1.0_rollup@2.78.1
       commondir: 1.0.1
       estree-walker: 2.0.2
       glob: 7.2.3
       is-reference: 1.2.1
       magic-string: 0.25.9
       resolve: 1.22.0
-      rollup: 2.75.7
+      rollup: 2.78.1
     dev: true
 
-  /@rollup/plugin-json/4.1.0_rollup@2.75.7:
+  /@rollup/plugin-json/4.1.0_rollup@2.78.1:
     resolution: {integrity: sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==}
     peerDependencies:
       rollup: ^1.20.0 || ^2.0.0
     dependencies:
-      '@rollup/pluginutils': 3.1.0_rollup@2.75.7
-      rollup: 2.75.7
+      '@rollup/pluginutils': 3.1.0_rollup@2.78.1
+      rollup: 2.78.1
     dev: true
 
-  /@rollup/plugin-node-resolve/13.3.0_rollup@2.75.7:
+  /@rollup/plugin-node-resolve/13.3.0_rollup@2.78.1:
     resolution: {integrity: sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw==}
     engines: {node: '>= 10.0.0'}
     peerDependencies:
       rollup: ^2.42.0
     dependencies:
-      '@rollup/pluginutils': 3.1.0_rollup@2.75.7
+      '@rollup/pluginutils': 3.1.0_rollup@2.78.1
       '@types/resolve': 1.17.1
       deepmerge: 4.2.2
       is-builtin-module: 3.1.0
       is-module: 1.0.0
       resolve: 1.22.0
-      rollup: 2.75.7
+      rollup: 2.78.1
     dev: true
 
-  /@rollup/pluginutils/3.1.0_rollup@2.75.7:
+  /@rollup/pluginutils/3.1.0_rollup@2.78.1:
     resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==}
     engines: {node: '>= 8.0.0'}
     peerDependencies:
@@ -1003,7 +1006,7 @@ packages:
       '@types/estree': 0.0.39
       estree-walker: 1.0.1
       picomatch: 2.3.1
-      rollup: 2.75.7
+      rollup: 2.78.1
     dev: true
 
   /@rollup/pluginutils/4.2.1:
@@ -1019,7 +1022,7 @@ packages:
       golden-fleece: 1.0.9
     dev: true
 
-  /@sveltejs/vite-plugin-svelte/1.0.1_svelte@3.48.0+vite@3.0.9:
+  /@sveltejs/vite-plugin-svelte/1.0.1_le3uwffmhe7iwfccb43atcj5xe:
     resolution: {integrity: sha512-PorCgUounn0VXcpeJu+hOweZODKmGuLHsLomwqSj+p26IwjjGffmYQfVHtiTWq+NqaUuuHWWG7vPge6UFw4Aeg==}
     engines: {node: ^14.18.0 || >= 16}
     peerDependencies:
@@ -1037,7 +1040,7 @@ packages:
       magic-string: 0.26.2
       svelte: 3.48.0
       svelte-hmr: 0.14.12_svelte@3.48.0
-      vite: 3.0.9
+      vite: 3.1.0-beta.1
     transitivePeerDependencies:
       - supports-color
     dev: false
@@ -2517,10 +2520,16 @@ packages:
       ci-info: 3.3.2
     dev: true
 
+  /is-core-module/2.10.0:
+    resolution: {integrity: sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==}
+    dependencies:
+      has: 1.0.3
+
   /is-core-module/2.9.0:
     resolution: {integrity: sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==}
     dependencies:
       has: 1.0.3
+    dev: true
 
   /is-date-object/1.0.5:
     resolution: {integrity: sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==}
@@ -3548,7 +3557,7 @@ packages:
     resolution: {integrity: sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==}
     hasBin: true
     dependencies:
-      is-core-module: 2.9.0
+      is-core-module: 2.10.0
       path-parse: 1.0.7
       supports-preserve-symlinks-flag: 1.0.0
 
@@ -3583,8 +3592,8 @@ packages:
       estree-walker: 0.6.1
     dev: false
 
-  /rollup/2.75.7:
-    resolution: {integrity: sha512-VSE1iy0eaAYNCxEXaleThdFXqZJ42qDBatAwrfnPlENEZ8erQ+0LYX4JXOLPceWfZpV1VtZwZ3dFCuOZiSyFtQ==}
+  /rollup/2.78.1:
+    resolution: {integrity: sha512-VeeCgtGi4P+o9hIg+xz4qQpRl6R401LWEXBmxYKOV4zlF82lyhgh2hTZnheFUbANE8l2A41F458iwj2vEYaXJg==}
     engines: {node: '>=10.0.0'}
     hasBin: true
     optionalDependencies:
@@ -4495,8 +4504,8 @@ packages:
       magic-string: 0.26.2
     dev: true
 
-  /vite/3.0.9:
-    resolution: {integrity: sha512-waYABTM+G6DBTCpYAxvevpG50UOlZuynR0ckTK5PawNVt7ebX6X7wNXHaGIO6wYYFXSM7/WcuFuO2QzhBB6aMw==}
+  /vite/3.1.0-beta.1:
+    resolution: {integrity: sha512-JGEnWSC0hfarcduTCQr6wnRjPLbT62iLCK59HBJXYt9oyWSUMtrvcnDqzvLFC+lHV6KGFQkmWlZucyIQmgUnLA==}
     engines: {node: ^14.18.0 || >=16.0.0}
     hasBin: true
     peerDependencies:
@@ -4517,7 +4526,7 @@ packages:
       esbuild: 0.14.54
       postcss: 8.4.16
       resolve: 1.22.1
-      rollup: 2.75.7
+      rollup: 2.78.1
     optionalDependencies:
       fsevents: 2.3.2
 
diff --git a/sites/kit.svelte.dev/package.json b/sites/kit.svelte.dev/package.json
index 1a2cd1c4a..714ae8a34 100644
--- a/sites/kit.svelte.dev/package.json
+++ b/sites/kit.svelte.dev/package.json
@@ -21,7 +21,7 @@
 		"shiki-twoslash": "^3.0.2",
 		"svelte": "^3.48.0",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.9",
+		"vite": "^3.1.0-beta.1",
 		"vite-imagetools": "^4.0.3"
 	},
 	"type": "module"


Test patch:
diff --git a/packages/adapter-static/test/apps/prerendered/package.json b/packages/adapter-static/test/apps/prerendered/package.json
index ef581f5c6..6d08946db 100644
--- a/packages/adapter-static/test/apps/prerendered/package.json
+++ b/packages/adapter-static/test/apps/prerendered/package.json
@@ -10,7 +10,7 @@
 	"devDependencies": {
 		"@sveltejs/kit": "workspace:*",
 		"svelte": "^3.48.0",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/adapter-static/test/apps/spa/package.json b/packages/adapter-static/test/apps/spa/package.json
index 859b0929f..078ca3436 100644
--- a/packages/adapter-static/test/apps/spa/package.json
+++ b/packages/adapter-static/test/apps/spa/package.json
@@ -12,7 +12,7 @@
 		"@sveltejs/kit": "workspace:*",
 		"sirv-cli": "^2.0.2",
 		"svelte": "^3.48.0",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/apps/amp/package.json b/packages/kit/test/apps/amp/package.json
index 0cc8e95fa..44ee6b06f 100644
--- a/packages/kit/test/apps/amp/package.json
+++ b/packages/kit/test/apps/amp/package.json
@@ -19,7 +19,7 @@
 		"svelte": "^3.48.0",
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/apps/basics/package.json b/packages/kit/test/apps/basics/package.json
index e29507332..c03892121 100644
--- a/packages/kit/test/apps/basics/package.json
+++ b/packages/kit/test/apps/basics/package.json
@@ -18,7 +18,7 @@
 		"svelte": "^3.48.0",
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/apps/dev-only/package.json b/packages/kit/test/apps/dev-only/package.json
index cbba7da8d..cb478186e 100644
--- a/packages/kit/test/apps/dev-only/package.json
+++ b/packages/kit/test/apps/dev-only/package.json
@@ -16,7 +16,7 @@
 		"svelte": "^3.48.0",
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/apps/options-2/package.json b/packages/kit/test/apps/options-2/package.json
index dd612d2c4..5df9ac735 100644
--- a/packages/kit/test/apps/options-2/package.json
+++ b/packages/kit/test/apps/options-2/package.json
@@ -18,7 +18,7 @@
 		"svelte": "^3.48.0",
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/apps/options/package.json b/packages/kit/test/apps/options/package.json
index 48734ac77..a1e46953a 100644
--- a/packages/kit/test/apps/options/package.json
+++ b/packages/kit/test/apps/options/package.json
@@ -17,7 +17,7 @@
 		"svelte": "^3.48.0",
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/apps/writes/package.json b/packages/kit/test/apps/writes/package.json
index 3c6cab88a..6c31c655c 100644
--- a/packages/kit/test/apps/writes/package.json
+++ b/packages/kit/test/apps/writes/package.json
@@ -18,7 +18,7 @@
 		"svelte": "^3.48.0",
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/prerendering/basics/package.json b/packages/kit/test/prerendering/basics/package.json
index 2a60f53f9..0e1c014d6 100644
--- a/packages/kit/test/prerendering/basics/package.json
+++ b/packages/kit/test/prerendering/basics/package.json
@@ -15,7 +15,7 @@
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
 		"uvu": "^0.5.3",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/prerendering/fallback/package.json b/packages/kit/test/prerendering/fallback/package.json
index 9835390fe..56e9dd9a1 100644
--- a/packages/kit/test/prerendering/fallback/package.json
+++ b/packages/kit/test/prerendering/fallback/package.json
@@ -15,7 +15,7 @@
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
 		"uvu": "^0.5.3",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/prerendering/options/package.json b/packages/kit/test/prerendering/options/package.json
index 7c75411c6..955df094d 100644
--- a/packages/kit/test/prerendering/options/package.json
+++ b/packages/kit/test/prerendering/options/package.json
@@ -15,7 +15,7 @@
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
 		"uvu": "^0.5.3",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/prerendering/paths-base/package.json b/packages/kit/test/prerendering/paths-base/package.json
index 10eb75923..0fd9e44b6 100644
--- a/packages/kit/test/prerendering/paths-base/package.json
+++ b/packages/kit/test/prerendering/paths-base/package.json
@@ -15,7 +15,7 @@
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
 		"uvu": "^0.5.3",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/prerendering/trailing-slash/package.json b/packages/kit/test/prerendering/trailing-slash/package.json
index d149c42bf..f7373da48 100644
--- a/packages/kit/test/prerendering/trailing-slash/package.json
+++ b/packages/kit/test/prerendering/trailing-slash/package.json
@@ -15,7 +15,7 @@
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
 		"uvu": "^0.5.4",
-		"vite": "^3.0.9"
+		"vite": "^3.1.0-beta.1"
 	},
 	"type": "module"
 }