Repository: sveltejs/kit
Pull request #6583 (2022-09-05 12:10:40)

bump vite
3.1.0 is released 🎉 

netlify[bot]: ### <span aria-hidden="true">👷</span> Deploy Preview for *kit-demo* processing.


|  Name | Link |
|---------------------------------|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | d5009e6d952349d9d9b2b2ba7c608a72e8f4d175 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/sites/kit-demo/deploys/6315e7425466c7000811cdd8 |

Patch:
diff --git a/.changeset/famous-terms-sniff.md b/.changeset/famous-terms-sniff.md
new file mode 100644
index 000000000..156cc8c1d
--- /dev/null
+++ b/.changeset/famous-terms-sniff.md
@@ -0,0 +1,6 @@
+---
+'create-svelte': patch
+'@sveltejs/kit': patch
+---
+
+Bump vite-plugin-svelte and required vite version
diff --git a/.changeset/five-cooks-hope.md b/.changeset/five-cooks-hope.md
new file mode 100644
index 000000000..bfe3bab21
--- /dev/null
+++ b/.changeset/five-cooks-hope.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+[feat] Support for `$env/dynamic/*` in Vite ecosystem tools
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 51ba2a487..9e374a84e 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -61,7 +61,7 @@ If you would like to test local changes to Vite or another dependency, you can b
 {
 	// ...
 	"dependencies": {
-		"vite": "^3.0.0"
+		"vite": "^3.1.0"
 	},
 	"pnpm": {
 		"overrides": {
diff --git a/packages/adapter-static/package.json b/packages/adapter-static/package.json
index c1c96f054..8dd2269a6 100644
--- a/packages/adapter-static/package.json
+++ b/packages/adapter-static/package.json
@@ -31,6 +31,6 @@
 		"svelte": "^3.48.0",
 		"typescript": "^4.8.2",
 		"uvu": "^0.5.3",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	}
 }
diff --git a/packages/create-svelte/templates/default/package.template.json b/packages/create-svelte/templates/default/package.template.json
index a8dddd263..3a207484d 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.1.0-beta.1"
+		"vite": "^3.1.0"
 	},
 	"type": "module",
 	"dependencies": {
diff --git a/packages/create-svelte/templates/skeleton/package.template.json b/packages/create-svelte/templates/skeleton/package.template.json
index 956d2c910..f836d56cb 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.1.0-beta.1"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/create-svelte/templates/skeletonlib/package.template.json b/packages/create-svelte/templates/skeletonlib/package.template.json
index 0ca385b2b..6b90688f1 100644
--- a/packages/create-svelte/templates/skeletonlib/package.template.json
+++ b/packages/create-svelte/templates/skeletonlib/package.template.json
@@ -12,7 +12,7 @@
 		"svelte": "^3.44.0",
 		"tslib": "^2.3.1",
 		"typescript": "^4.8.2",
-		"vite": "^3.1.0-beta.1"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/package.json b/packages/kit/package.json
index 6cf7fe200..249d358f6 100644
--- a/packages/kit/package.json
+++ b/packages/kit/package.json
@@ -10,7 +10,7 @@
 	"homepage": "https://kit.svelte.dev",
 	"type": "module",
 	"dependencies": {
-		"@sveltejs/vite-plugin-svelte": "^1.0.4",
+		"@sveltejs/vite-plugin-svelte": "^1.0.5",
 		"cookie": "^0.5.0",
 		"devalue": "^3.1.2",
 		"kleur": "^4.1.4",
@@ -38,11 +38,11 @@
 		"svelte-preprocess": "^4.10.6",
 		"typescript": "^4.8.2",
 		"uvu": "^0.5.3",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"peerDependencies": {
 		"svelte": "^3.44.0",
-		"vite": "^3.1.0-beta.1"
+		"vite": "^3.1.0"
 	},
 	"bin": {
 		"svelte-kit": "svelte-kit.js"
diff --git a/packages/kit/src/core/env.js b/packages/kit/src/core/env.js
index 00291a4d0..af17fcfe9 100644
--- a/packages/kit/src/core/env.js
+++ b/packages/kit/src/core/env.js
@@ -24,8 +24,17 @@ export function create_static_module(id, env) {
 	return GENERATED_COMMENT + declarations.join('\n\n');
 }
 
-/** @param {'public' | 'private'} type */
-export function create_dynamic_module(type) {
+/**
+ * @param {'public' | 'private'} type
+ * @param {Record<string, string> | undefined} dev_values If in a development mode, values to pre-populate the module with.
+ */
+export function create_dynamic_module(type, dev_values) {
+	if (dev_values) {
+		const objectKeys = Object.entries(dev_values).map(
+			([k, v]) => `${JSON.stringify(k)}: ${JSON.stringify(v)}`
+		);
+		return `const env = {\n${objectKeys.join(',\n')}\n}\n\nexport { env }`;
+	}
 	return `export { env } from '${runtime_base}/env-${type}.js';`;
 }
 
diff --git a/packages/kit/src/exports/vite/dev/index.js b/packages/kit/src/exports/vite/dev/index.js
index 4ce5b8fb9..aa1bc6bd8 100644
--- a/packages/kit/src/exports/vite/dev/index.js
+++ b/packages/kit/src/exports/vite/dev/index.js
@@ -11,7 +11,7 @@ import { load_error_page, load_template } from '../../../core/config/index.js';
 import { SVELTE_KIT_ASSETS } from '../../../constants.js';
 import * as sync from '../../../core/sync/sync.js';
 import { get_mime_lookup, runtime_base, runtime_prefix } from '../../../core/utils.js';
-import { get_env, prevent_illegal_vite_imports, resolve_entry } from '../utils.js';
+import { prevent_illegal_vite_imports, resolve_entry } from '../utils.js';
 import { compact } from '../../../utils/array.js';
 
 // Vite doesn't expose this so we just copy the list for now
@@ -269,13 +269,6 @@ export async function dev(vite, vite_config, svelte_config, illegal_imports) {
 		}
 	});
 
-	const { set_private_env } = await vite.ssrLoadModule(`${runtime_base}/env-private.js`);
-	const { set_public_env } = await vite.ssrLoadModule(`${runtime_base}/env-public.js`);
-
-	const env = get_env(svelte_config.kit.env, vite_config.mode);
-	set_private_env(env.private);
-	set_public_env(env.public);
-
 	return () => {
 		const serve_static_middleware = vite.middlewares.stack.find(
 			(middleware) =>
@@ -411,7 +404,7 @@ export async function dev(vite, vite_config, svelte_config, illegal_imports) {
 							base: svelte_config.kit.paths.base,
 							assets
 						},
-						public_env: env.public,
+						public_env: {},
 						read: (file) => fs.readFileSync(path.join(svelte_config.kit.files.assets, file)),
 						root,
 						app_template: ({ head, body, assets, nonce }) => {
diff --git a/packages/kit/src/exports/vite/index.js b/packages/kit/src/exports/vite/index.js
index 97a325e52..a613ecd89 100644
--- a/packages/kit/src/exports/vite/index.js
+++ b/packages/kit/src/exports/vite/index.js
@@ -299,9 +299,15 @@ function kit() {
 				case '\0$env/static/public':
 					return create_static_module('$env/static/public', env.public);
 				case '\0$env/dynamic/private':
-					return create_dynamic_module('private');
+					return create_dynamic_module(
+						'private',
+						vite_config_env.command === 'serve' ? env.private : undefined
+					);
 				case '\0$env/dynamic/public':
-					return create_dynamic_module('public');
+					return create_dynamic_module(
+						'public',
+						vite_config_env.command === 'serve' ? env.public : undefined
+					);
 			}
 		},
 
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 0bad458f1..b521796a0 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -151,7 +151,7 @@ importers:
       svelte: ^3.48.0
       typescript: ^4.8.2
       uvu: ^0.5.3
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/kit': link:../kit
       '@types/node': 16.11.42
@@ -159,17 +159,17 @@ importers:
       svelte: 3.48.0
       typescript: 4.8.2
       uvu: 0.5.4
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/adapter-static/test/apps/prerendered:
     specifiers:
       '@sveltejs/kit': workspace:*
       svelte: ^3.48.0
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/kit': link:../../../../kit
       svelte: 3.48.0
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/adapter-static/test/apps/spa:
     specifiers:
@@ -177,13 +177,13 @@ importers:
       '@sveltejs/kit': workspace:*
       sirv-cli: ^2.0.2
       svelte: ^3.48.0
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/adapter-node': link:../../../../adapter-node
       '@sveltejs/kit': link:../../../../kit
       sirv-cli: 2.0.2
       svelte: 3.48.0
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/adapter-vercel:
     specifiers:
@@ -270,7 +270,7 @@ importers:
   packages/kit:
     specifiers:
       '@playwright/test': ^1.25.0
-      '@sveltejs/vite-plugin-svelte': ^1.0.4
+      '@sveltejs/vite-plugin-svelte': ^1.0.5
       '@types/connect': ^3.4.35
       '@types/cookie': ^0.5.1
       '@types/marked': ^4.0.3
@@ -295,9 +295,9 @@ importers:
       typescript: ^4.8.2
       undici: ^5.8.1
       uvu: ^0.5.3
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     dependencies:
-      '@sveltejs/vite-plugin-svelte': 1.0.4_7yzfhf6mtdgjf3hl2tzeed235e
+      '@sveltejs/vite-plugin-svelte': 1.0.5_svelte@3.48.0+vite@3.1.0
       cookie: 0.5.0
       devalue: 3.1.2
       kleur: 4.1.5
@@ -324,7 +324,7 @@ importers:
       svelte-preprocess: 4.10.7_rzeu6t3zqu2xw2nsnbtx3gkaoe
       typescript: 4.8.2
       uvu: 0.5.4
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/kit/test/apps/amp:
     specifiers:
@@ -335,7 +335,7 @@ importers:
       svelte: ^3.48.0
       svelte-check: ^2.7.1
       typescript: ^4.8.2
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/amp': link:../../../../amp
       '@sveltejs/kit': link:../../..
@@ -344,7 +344,7 @@ importers:
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.8.2
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/kit/test/apps/basics:
     specifiers:
@@ -354,7 +354,7 @@ importers:
       svelte: ^3.48.0
       svelte-check: ^2.7.1
       typescript: ^4.8.2
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/kit': link:../../..
       cross-env: 7.0.3
@@ -362,7 +362,7 @@ importers:
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.8.2
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/kit/test/apps/dev-only:
     specifiers:
@@ -372,7 +372,7 @@ importers:
       svelte: ^3.48.0
       svelte-check: ^2.7.1
       typescript: ^4.8.2
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/kit': link:../../..
       cross-env: 7.0.3
@@ -380,7 +380,7 @@ importers:
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.8.2
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/kit/test/apps/options:
     specifiers:
@@ -389,14 +389,14 @@ importers:
       svelte: ^3.48.0
       svelte-check: ^2.7.1
       typescript: ^4.8.2
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/kit': link:../../..
       cross-env: 7.0.3
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.8.2
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/kit/test/apps/options-2:
     specifiers:
@@ -406,7 +406,7 @@ importers:
       svelte: ^3.48.0
       svelte-check: ^2.7.1
       typescript: ^4.8.2
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/adapter-node': link:../../../../adapter-node
       '@sveltejs/kit': link:../../..
@@ -414,7 +414,7 @@ importers:
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.8.2
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/kit/test/apps/writes:
     specifiers:
@@ -424,7 +424,7 @@ importers:
       svelte: ^3.48.0
       svelte-check: ^2.7.1
       typescript: ^4.8.2
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/kit': link:../../..
       cross-env: 7.0.3
@@ -432,7 +432,7 @@ importers:
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.8.2
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/kit/test/prerendering/basics:
     specifiers:
@@ -441,14 +441,14 @@ importers:
       svelte-check: ^2.7.1
       typescript: ^4.8.2
       uvu: ^0.5.3
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/kit': link:../../..
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.8.2
       uvu: 0.5.4
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/kit/test/prerendering/fallback:
     specifiers:
@@ -457,14 +457,14 @@ importers:
       svelte-check: ^2.7.1
       typescript: ^4.8.2
       uvu: ^0.5.3
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/kit': link:../../..
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.8.2
       uvu: 0.5.4
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/kit/test/prerendering/options:
     specifiers:
@@ -473,14 +473,14 @@ importers:
       svelte-check: ^2.7.1
       typescript: ^4.8.2
       uvu: ^0.5.3
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/kit': link:../../..
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.8.2
       uvu: 0.5.4
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/kit/test/prerendering/paths-base:
     specifiers:
@@ -489,14 +489,14 @@ importers:
       svelte-check: ^2.7.1
       typescript: ^4.8.2
       uvu: ^0.5.3
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/kit': link:../../..
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.8.2
       uvu: 0.5.4
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/kit/test/prerendering/trailing-slash:
     specifiers:
@@ -505,14 +505,14 @@ importers:
       svelte-check: ^2.7.1
       typescript: ^4.8.2
       uvu: ^0.5.4
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
     devDependencies:
       '@sveltejs/kit': link:../../..
       svelte: 3.48.0
       svelte-check: 2.8.0_svelte@3.48.0
       typescript: 4.8.2
       uvu: 0.5.4
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
 
   packages/migrate:
     specifiers:
@@ -573,7 +573,7 @@ importers:
       shiki-twoslash: ^3.0.2
       svelte: ^3.48.0
       typescript: ^4.8.2
-      vite: ^3.1.0-beta.2
+      vite: ^3.1.0
       vite-imagetools: ^4.0.7
     devDependencies:
       '@sveltejs/adapter-auto': link:../../packages/adapter-auto
@@ -589,7 +589,7 @@ importers:
       shiki-twoslash: 3.1.0
       svelte: 3.48.0
       typescript: 4.8.2
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
       vite-imagetools: 4.0.7
 
 packages:
@@ -1029,13 +1029,13 @@ packages:
       golden-fleece: 1.0.9
     dev: true
 
-  /@sveltejs/vite-plugin-svelte/1.0.4_7yzfhf6mtdgjf3hl2tzeed235e:
-    resolution: {integrity: sha512-UZco2fdj0OVuRWC0SUJjEOftITc2IeHLFJNp00ym9MuQ9dShnlO4P29G8KUxRlcS7kSpzHuko6eCR9MOALj7lQ==}
+  /@sveltejs/vite-plugin-svelte/1.0.5_svelte@3.48.0+vite@3.1.0:
+    resolution: {integrity: sha512-CmSdSow0Dr5ua1A11BQMtreWnE0JZmkVIcRU/yG3PKbycKUpXjNdgYTWFSbStLB0vdlGnBbm2+Y4sBVj+C+TIw==}
     engines: {node: ^14.18.0 || >= 16}
     peerDependencies:
       diff-match-patch: ^1.0.5
       svelte: ^3.44.0
-      vite: ^3.0.0 || ^3.1.0-beta.1
+      vite: ^3.0.0
     peerDependenciesMeta:
       diff-match-patch:
         optional: true
@@ -1044,10 +1044,10 @@ packages:
       debug: 4.3.4
       deepmerge: 4.2.2
       kleur: 4.1.5
-      magic-string: 0.26.2
+      magic-string: 0.26.3
       svelte: 3.48.0
       svelte-hmr: 0.14.12_svelte@3.48.0
-      vite: 3.1.0-beta.2
+      vite: 3.1.0
     transitivePeerDependencies:
       - supports-color
     dev: false
@@ -3030,6 +3030,13 @@ packages:
     dependencies:
       sourcemap-codec: 1.4.8
 
+  /magic-string/0.26.3:
+    resolution: {integrity: sha512-u1Po0NDyFcwdg2nzHT88wSK0+Rih0N1M+Ph1Sp08k8yvFFU3KR72wryS7e1qMPJypt99WB7fIFVCA92mQrMjrg==}
+    engines: {node: '>=12'}
+    dependencies:
+      sourcemap-codec: 1.4.8
+    dev: false
+
   /make-dir/3.1.0:
     resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==}
     engines: {node: '>=8'}
@@ -4711,6 +4718,32 @@ packages:
       magic-string: 0.26.2
     dev: true
 
+  /vite/3.1.0:
+    resolution: {integrity: sha512-YBg3dUicDpDWFCGttmvMbVyS9ydjntwEjwXRj2KBFwSB8SxmGcudo1yb8FW5+M/G86aS8x828ujnzUVdsLjs9g==}
+    engines: {node: ^14.18.0 || >=16.0.0}
+    hasBin: true
+    peerDependencies:
+      less: '*'
+      sass: '*'
+      stylus: '*'
+      terser: ^5.4.0
+    peerDependenciesMeta:
+      less:
+        optional: true
+      sass:
+        optional: true
+      stylus:
+        optional: true
+      terser:
+        optional: true
+    dependencies:
+      esbuild: 0.15.6
+      postcss: 8.4.16
+      resolve: 1.22.1
+      rollup: 2.78.1
+    optionalDependencies:
+      fsevents: 2.3.2
+
   /vite/3.1.0-beta.2:
     resolution: {integrity: sha512-JD1I8S29RFAEL94/bamrdJd3VlLQROcGwQxb8X1hRWDtwmPTves8TmZCaQ4g460j6zZxyLYwSVHwkGCQ2k07og==}
     engines: {node: ^14.18.0 || >=16.0.0}
@@ -4736,6 +4769,7 @@ packages:
       rollup: 2.78.1
     optionalDependencies:
       fsevents: 2.3.2
+    dev: true
 
   /vscode-oniguruma/1.6.2:
     resolution: {integrity: sha512-KH8+KKov5eS/9WhofZR8M8dMHWN2gTxjMsG4jd04YhpbPR91fUj7rYQ2/XjeHCJWbg7X++ApRIU9NUwM2vTvLA==}
diff --git a/sites/kit.svelte.dev/package.json b/sites/kit.svelte.dev/package.json
index e83354e67..da3806762 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.8.2",
-		"vite": "^3.1.0-beta.2",
+		"vite": "^3.1.0",
 		"vite-imagetools": "^4.0.7"
 	},
 	"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 5e8f654f5..16f341900 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.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/adapter-static/test/apps/spa/package.json b/packages/adapter-static/test/apps/spa/package.json
index f29ea36d8..cd87de548 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.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/apps/amp/package.json b/packages/kit/test/apps/amp/package.json
index 6a1067524..4e641e06a 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.8.2",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/apps/basics/package.json b/packages/kit/test/apps/basics/package.json
index 6856420a9..0feab5822 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.8.2",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/apps/basics/src/routes/env/+page.svelte b/packages/kit/test/apps/basics/src/routes/env/+page.svelte
index 4ee2f424d..a1ab646a4 100644
--- a/packages/kit/test/apps/basics/src/routes/env/+page.svelte
+++ b/packages/kit/test/apps/basics/src/routes/env/+page.svelte
@@ -1,13 +1,1 @@
-<script>
-	import { PUBLIC_STATIC } from '$env/static/public';
-	import { env } from '$env/dynamic/public';
-
-	/** @type {import('./$types').PageData} */
-	export let data;
-</script>
-
-<p id="static-private">PRIVATE_STATIC: {data.PRIVATE_STATIC}</p>
-<p id="dynamic-private">PRIVATE_DYNAMIC: {data.PRIVATE_DYNAMIC}</p>
-
-<p id="static-public">PUBLIC_STATIC: {PUBLIC_STATIC}</p>
-<p id="dynamic-public">PUBLIC_DYNAMIC: {env.PUBLIC_DYNAMIC}</p>
+<a href="/env/includes">Includes</a>
diff --git a/packages/kit/test/apps/basics/src/routes/env/+page.server.js b/packages/kit/test/apps/basics/src/routes/env/includes/+page.server.js
similarity index 100%
rename from packages/kit/test/apps/basics/src/routes/env/+page.server.js
rename to packages/kit/test/apps/basics/src/routes/env/includes/+page.server.js
diff --git a/packages/kit/test/apps/basics/src/routes/env/includes/+page.svelte b/packages/kit/test/apps/basics/src/routes/env/includes/+page.svelte
new file mode 100644
index 000000000..4ee2f424d
--- /dev/null
+++ b/packages/kit/test/apps/basics/src/routes/env/includes/+page.svelte
@@ -0,0 +1,13 @@
+<script>
+	import { PUBLIC_STATIC } from '$env/static/public';
+	import { env } from '$env/dynamic/public';
+
+	/** @type {import('./$types').PageData} */
+	export let data;
+</script>
+
+<p id="static-private">PRIVATE_STATIC: {data.PRIVATE_STATIC}</p>
+<p id="dynamic-private">PRIVATE_DYNAMIC: {data.PRIVATE_DYNAMIC}</p>
+
+<p id="static-public">PUBLIC_STATIC: {PUBLIC_STATIC}</p>
+<p id="dynamic-public">PUBLIC_DYNAMIC: {env.PUBLIC_DYNAMIC}</p>
diff --git a/packages/kit/test/apps/basics/test/test.js b/packages/kit/test/apps/basics/test/test.js
index d46e73f17..9244aeb7a 100644
--- a/packages/kit/test/apps/basics/test/test.js
+++ b/packages/kit/test/apps/basics/test/test.js
@@ -385,8 +385,25 @@ test.describe('Encoded paths', () => {
 });
 
 test.describe('$env', () => {
-	test('includes environment variables', async ({ page }) => {
+	test('includes environment variables', async ({ page, clicknav }) => {
+		await page.goto('/env/includes');
+
+		expect(await page.textContent('#static-private')).toBe(
+			'PRIVATE_STATIC: accessible to server-side code/replaced at build time'
+		);
+		expect(await page.textContent('#dynamic-private')).toBe(
+			'PRIVATE_DYNAMIC: accessible to server-side code/evaluated at run time'
+		);
+
+		expect(await page.textContent('#static-public')).toBe(
+			'PUBLIC_STATIC: accessible anywhere/replaced at build time'
+		);
+		expect(await page.textContent('#dynamic-public')).toBe(
+			'PUBLIC_DYNAMIC: accessible anywhere/evaluated at run time'
+		);
+
 		await page.goto('/env');
+		await clicknav('[href="/env/includes"]');
 
 		expect(await page.textContent('#static-private')).toBe(
 			'PRIVATE_STATIC: accessible to server-side code/replaced at build time'
diff --git a/packages/kit/test/apps/dev-only/package.json b/packages/kit/test/apps/dev-only/package.json
index 552f0d4c4..eeb488e4d 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.8.2",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/apps/options-2/package.json b/packages/kit/test/apps/options-2/package.json
index 9a07a6ba8..3d080e64c 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.8.2",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/apps/options/package.json b/packages/kit/test/apps/options/package.json
index 2a11f361c..c15b9c7d2 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.8.2",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/apps/writes/package.json b/packages/kit/test/apps/writes/package.json
index 824805db1..adc1cc801 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.8.2",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json b/packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json
index 82fd77367..6dd1856f1 100644
--- a/packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json
+++ b/packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json
@@ -14,7 +14,7 @@
 		"svelte": "^3.44.0",
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.4"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/build-errors/apps/private-dynamic-env/package.json b/packages/kit/test/build-errors/apps/private-dynamic-env/package.json
index e247aae3d..6e482a907 100644
--- a/packages/kit/test/build-errors/apps/private-dynamic-env/package.json
+++ b/packages/kit/test/build-errors/apps/private-dynamic-env/package.json
@@ -14,7 +14,7 @@
 		"svelte": "^3.44.0",
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.4"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json b/packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json
index b07b33b90..b09a47e88 100644
--- a/packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json
+++ b/packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json
@@ -14,7 +14,7 @@
 		"svelte": "^3.44.0",
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.4"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/build-errors/apps/private-static-env/package.json b/packages/kit/test/build-errors/apps/private-static-env/package.json
index b4cbb3ea8..e98bf574e 100644
--- a/packages/kit/test/build-errors/apps/private-static-env/package.json
+++ b/packages/kit/test/build-errors/apps/private-static-env/package.json
@@ -15,7 +15,7 @@
 		"svelte": "^3.44.0",
 		"svelte-check": "^2.7.1",
 		"typescript": "^4.7.4",
-		"vite": "^3.0.4"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/prerendering/basics/package.json b/packages/kit/test/prerendering/basics/package.json
index 7287614af..fdde87bff 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.8.2",
 		"uvu": "^0.5.3",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/prerendering/fallback/package.json b/packages/kit/test/prerendering/fallback/package.json
index 141e31dad..d854e3e0d 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.8.2",
 		"uvu": "^0.5.3",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/prerendering/options/package.json b/packages/kit/test/prerendering/options/package.json
index eeb947a66..c8223e01d 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.8.2",
 		"uvu": "^0.5.3",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/prerendering/paths-base/package.json b/packages/kit/test/prerendering/paths-base/package.json
index ca81c420d..ba5d022ed 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.8.2",
 		"uvu": "^0.5.3",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }
diff --git a/packages/kit/test/prerendering/trailing-slash/package.json b/packages/kit/test/prerendering/trailing-slash/package.json
index 05c9efa8c..6146d5733 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.8.2",
 		"uvu": "^0.5.4",
-		"vite": "^3.1.0-beta.2"
+		"vite": "^3.1.0"
 	},
 	"type": "module"
 }