Repository: sveltejs/kit
Pull request #7835 (2022-11-28 00:01:04)

[fix] don't pass second arg to `generateManifest`
This was removed in https://github.com/sveltejs/kit/pull/7820 and is causing lint to fail. It didn't fail on that PR because Turbo is a giant steaming pile of shit. Here is the Turbo output from that PR:

>@sveltejs/adapter-netlify:check: cache hit, suppressing output 98cf59e7443a315b
@sveltejs/adapter-netlify:lint: cache hit, suppressing output e148ef9617701497

No changeset necessary since it's only a lint fix and won't impact users

changeset-bot[bot]: ###  ⚠️  No Changeset found

Latest commit: 403f446ec08201f399f5dfa65091d437b31bbfda

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/benmccann/kit/new/generateManifest?filename=.changeset/ninety-lobsters-cough.md&value=---%0A%22%40sveltejs%2Fadapter-netlify%22%3A%20patch%0A---%0A%0A%5Bfix%5D%20don't%20pass%20second%20arg%20to%20%60generateManifest%60%0A)



Patch:
diff --git a/.changeset/clever-pillows-turn.md b/.changeset/clever-pillows-turn.md
new file mode 100644
index 000000000..6f7d49fb0
--- /dev/null
+++ b/.changeset/clever-pillows-turn.md
@@ -0,0 +1,5 @@
+---
+"@sveltejs/kit": patch
+---
+
+[chore] upgrade undici
diff --git a/.changeset/rude-actors-serve.md b/.changeset/rude-actors-serve.md
new file mode 100644
index 000000000..42c58ed54
--- /dev/null
+++ b/.changeset/rude-actors-serve.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+Make `$page.url` resilient against mutations
diff --git a/package.json b/package.json
index 063f412e0..a0db35cd1 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
 		"turbo": "^1.6.1",
 		"typescript": "^4.8.4"
 	},
-	"packageManager": "pnpm@7.16.1",
+	"packageManager": "pnpm@7.17.1",
 	"engines": {
 		"pnpm": "^7.0.0"
 	},
diff --git a/packages/adapter-netlify/index.js b/packages/adapter-netlify/index.js
index 8cb617cb8..99b0aa85a 100644
--- a/packages/adapter-netlify/index.js
+++ b/packages/adapter-netlify/index.js
@@ -188,8 +188,7 @@ async function generate_lambda_functions({ builder, publish, split }) {
 				filter: (other) => matches(route.segments, other.segments),
 				complete: (entry) => {
 					const manifest = entry.generateManifest({
-						relativePath: '../server',
-						format: 'esm'
+						relativePath: '../server'
 					});
 
 					const fn = `import { init } from '../serverless.js';\n\nexport const handler = init(${manifest});\n`;
@@ -206,8 +205,7 @@ async function generate_lambda_functions({ builder, publish, split }) {
 		builder.log.minor('Generating serverless functions...');
 
 		const manifest = builder.generateManifest({
-			relativePath: '../server',
-			format: 'esm'
+			relativePath: '../server'
 		});
 
 		const fn = `import { init } from '../serverless.js';\n\nexport const handler = init(${manifest});\n`;
diff --git a/packages/kit/package.json b/packages/kit/package.json
index 2a14e9097..3c1826b2e 100644
--- a/packages/kit/package.json
+++ b/packages/kit/package.json
@@ -21,7 +21,7 @@
 		"set-cookie-parser": "^2.5.1",
 		"sirv": "^2.0.2",
 		"tiny-glob": "^0.2.9",
-		"undici": "5.12.0"
+		"undici": "5.13.0"
 	},
 	"devDependencies": {
 		"@playwright/test": "1.25.0",
diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js
index f159f77c7..23c0b9180 100644
--- a/packages/kit/src/runtime/client/client.js
+++ b/packages/kit/src/runtime/client/client.js
@@ -478,7 +478,7 @@ export function create_client({ target, base }) {
 				params,
 				route,
 				status,
-				url,
+				url: new URL(url),
 				form,
 				// The whole page store is updated, but this way the object reference stays the same
 				data: data_changed ? data : page.data
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 056557421..4eac67c0b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -284,7 +284,7 @@ importers:
       svelte-preprocess: ^4.10.7
       tiny-glob: ^0.2.9
       typescript: ^4.8.4
-      undici: 5.12.0
+      undici: 5.13.0
       uvu: ^0.5.6
       vite: ^3.2.1
     dependencies:
@@ -299,7 +299,7 @@ importers:
       set-cookie-parser: 2.5.1
       sirv: 2.0.2
       tiny-glob: 0.2.9
-      undici: 5.12.0
+      undici: 5.13.0
     devDependencies:
       '@playwright/test': 1.25.0
       '@types/connect': 3.4.35
@@ -592,22 +592,6 @@ importers:
       uvu: 0.5.6
       vite: 3.2.3
 
-  packages/kit/test/prerendering/fallback:
-    specifiers:
-      '@sveltejs/kit': workspace:*
-      svelte: ^3.52.0
-      svelte-check: ^2.9.2
-      typescript: ^4.8.4
-      uvu: ^0.5.6
-      vite: ^3.2.1
-    devDependencies:
-      '@sveltejs/kit': link:../../..
-      svelte: 3.53.1
-      svelte-check: 2.9.2_svelte@3.53.1
-      typescript: 4.8.4
-      uvu: 0.5.6
-      vite: 3.2.3
-
   packages/kit/test/prerendering/options:
     specifiers:
       '@sveltejs/kit': workspace:*
@@ -4486,8 +4470,8 @@ packages:
       which-boxed-primitive: 1.0.2
     dev: true
 
-  /undici/5.12.0:
-    resolution: {integrity: sha512-zMLamCG62PGjd9HHMpo05bSLvvwWOZgGeiWlN/vlqu3+lRo3elxktVGEyLMX+IO7c2eflLjcW74AlkhEZm15mg==}
+  /undici/5.13.0:
+    resolution: {integrity: sha512-UDZKtwb2k7KRsK4SdXWG7ErXiL7yTGgLWvk2AXO1JMjgjh404nFo6tWSCM2xMpJwMPx3J8i/vfqEh1zOqvj82Q==}
     engines: {node: '>=12.18'}
     dependencies:
       busboy: 1.6.0


Test patch:
diff --git a/packages/kit/test/apps/basics/src/routes/load/mutated-url/+page.js b/packages/kit/test/apps/basics/src/routes/load/mutated-url/+page.js
new file mode 100644
index 000000000..dffb07ca8
--- /dev/null
+++ b/packages/kit/test/apps/basics/src/routes/load/mutated-url/+page.js
@@ -0,0 +1,6 @@
+/** @type {import('./$types').PageLoad} */
+export function load({ url }) {
+	return {
+		q: url.searchParams.get('q')
+	};
+}
diff --git a/packages/kit/test/apps/basics/src/routes/load/mutated-url/+page.svelte b/packages/kit/test/apps/basics/src/routes/load/mutated-url/+page.svelte
new file mode 100644
index 000000000..12877cdc0
--- /dev/null
+++ b/packages/kit/test/apps/basics/src/routes/load/mutated-url/+page.svelte
@@ -0,0 +1,15 @@
+<script>
+	import { goto } from '$app/navigation';
+	import { page } from '$app/stores';
+
+	/** @type {import('./$types').PageData} */
+	export let data;
+
+	function update_q() {
+		$page.url.searchParams.set('q', 'updated');
+		goto($page.url);
+	}
+</script>
+
+<h1>{data.q}</h1>
+<button on:click={update_q}>update q</button>
diff --git a/packages/kit/test/apps/basics/test/client.test.js b/packages/kit/test/apps/basics/test/client.test.js
index 103855f34..0e6a69c45 100644
--- a/packages/kit/test/apps/basics/test/client.test.js
+++ b/packages/kit/test/apps/basics/test/client.test.js
@@ -1046,6 +1046,14 @@ test.describe.serial('Invalidation', () => {
 		await clicknav('[href="/load/invalidation/route/shared/b"]');
 		expect(await page.textContent('h1')).toBe('route.id: /load/invalidation/route/shared/b');
 	});
+
+	test('$page.url can safely be mutated', async ({ page }) => {
+		await page.goto('/load/mutated-url?q=initial');
+		expect(await page.textContent('h1')).toBe('initial');
+
+		await page.click('button');
+		expect(await page.textContent('h1')).toBe('updated');
+	});
 });
 
 test.describe('data-sveltekit attributes', () => {