Skip to content

Commit

Permalink
feat: support Vite 6 (#12270)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored Nov 29, 2024
1 parent da965d7 commit d030f4b
Show file tree
Hide file tree
Showing 67 changed files with 1,365 additions and 1,593 deletions.
8 changes: 8 additions & 0 deletions .changeset/curvy-garlics-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@sveltejs/adapter-cloudflare-workers': minor
'@sveltejs/adapter-cloudflare': minor
'@sveltejs/adapter-netlify': minor
'@sveltejs/adapter-vercel': minor
---

chore: upgrade esbuild to 0.24.0
5 changes: 5 additions & 0 deletions .changeset/purple-comics-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': minor
---

feat: Vite 6 support
2 changes: 1 addition & 1 deletion packages/adapter-auto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"devDependencies": {
"@sveltejs/kit": "workspace:^",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"@types/node": "^18.19.48",
"typescript": "^5.3.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-cloudflare-workers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"dependencies": {
"@cloudflare/workers-types": "^4.20231121.0",
"@iarna/toml": "^2.2.5",
"esbuild": "^0.21.5"
"esbuild": "^0.24.0"
},
"devDependencies": {
"@cloudflare/kv-asset-handler": "^0.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"dependencies": {
"@cloudflare/workers-types": "^4.20231121.0",
"esbuild": "^0.21.5",
"esbuild": "^0.24.0",
"worktop": "0.8.0-next.18"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/adapter-netlify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"dependencies": {
"@iarna/toml": "^2.2.5",
"esbuild": "^0.21.5",
"esbuild": "^0.24.0",
"set-cookie-parser": "^2.6.0"
},
"devDependencies": {
Expand All @@ -51,12 +51,12 @@
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@sveltejs/kit": "workspace:^",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"@types/node": "^18.19.48",
"@types/set-cookie-parser": "^2.4.7",
"rollup": "^4.14.2",
"typescript": "^5.3.3",
"vitest": "^2.0.1"
"vitest": "^2.1.6"
},
"peerDependencies": {
"@sveltejs/kit": "^2.4.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
"devDependencies": {
"@polka/url": "^1.0.0-next.28",
"@sveltejs/kit": "workspace:^",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"@types/node": "^18.19.48",
"polka": "^1.0.0-next.28",
"sirv": "^3.0.0",
"typescript": "^5.3.3",
"vitest": "^2.0.1"
"vitest": "^2.1.6"
},
"dependencies": {
"@rollup/plugin-commonjs": "^28.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/adapter-static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
"devDependencies": {
"@playwright/test": "^1.44.1",
"@sveltejs/kit": "workspace:^",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"@types/node": "^18.19.48",
"sirv": "^3.0.0",
"svelte": "^4.2.10",
"svelte": "^5.2.9",
"typescript": "^5.3.3",
"vite": "^5.3.2"
"vite": "^6.0.1"
},
"peerDependencies": {
"@sveltejs/kit": "^2.0.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/adapter-static/test/apps/prerendered/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
},
"devDependencies": {
"@sveltejs/kit": "workspace:^",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"sirv-cli": "^3.0.0",
"svelte": "^4.2.10",
"vite": "^5.3.2"
"svelte": "^5.2.9",
"vite": "^6.0.1"
},
"type": "module"
}
6 changes: 3 additions & 3 deletions packages/adapter-static/test/apps/spa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"devDependencies": {
"@sveltejs/adapter-node": "workspace:^",
"@sveltejs/kit": "workspace:^",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"sirv-cli": "^3.0.0",
"svelte": "^4.2.10",
"vite": "^5.3.2"
"svelte": "^5.2.9",
"vite": "^6.0.1"
},
"type": "module"
}
6 changes: 3 additions & 3 deletions packages/adapter-vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
},
"dependencies": {
"@vercel/nft": "^0.27.1",
"esbuild": "^0.21.5"
"esbuild": "^0.24.0"
},
"devDependencies": {
"@sveltejs/kit": "workspace:^",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"@types/node": "^18.19.48",
"typescript": "^5.3.3",
"vitest": "^2.0.1"
"vitest": "^2.1.6"
},
"peerDependencies": {
"@sveltejs/kit": "^2.4.0"
Expand Down
8 changes: 4 additions & 4 deletions packages/enhanced-img/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
"devDependencies": {
"@types/estree": "^1.0.5",
"@types/node": "^18.19.48",
"rollup": "^4.14.2",
"svelte": "^5.1.3",
"rollup": "^4.27.4",
"svelte": "^5.2.9",
"typescript": "^5.6.3",
"vite": "^5.3.2",
"vitest": "^2.0.1"
"vite": "^6.0.1",
"vitest": "^2.1.6"
},
"peerDependencies": {
"svelte": "^5.0.0",
Expand Down
16 changes: 8 additions & 8 deletions packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@types/cookie": "^0.6.0",
"cookie": "^0.6.0",
"devalue": "^5.1.0",
"esm-env": "^1.0.0",
"esm-env": "^1.2.1",
"import-meta-resolve": "^4.1.0",
"kleur": "^4.1.5",
"magic-string": "^0.30.5",
Expand All @@ -33,22 +33,22 @@
},
"devDependencies": {
"@playwright/test": "^1.44.1",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"@types/connect": "^3.4.38",
"@types/node": "^18.19.48",
"@types/set-cookie-parser": "^2.4.7",
"dts-buddy": "^0.5.3",
"dts-buddy": "^0.5.4",
"rollup": "^4.14.2",
"svelte": "^4.2.10",
"svelte": "^5.2.9",
"svelte-preprocess": "^6.0.0",
"typescript": "^5.3.3",
"vite": "^5.3.2",
"vitest": "^2.0.1"
"vite": "^6.0.1",
"vitest": "^2.1.6"
},
"peerDependencies": {
"@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1",
"@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1 || ^5.0.0",
"svelte": "^4.0.0 || ^5.0.0-next.0",
"vite": "^5.0.3"
"vite": "^5.0.3 || ^6.0.0"
},
"bin": {
"svelte-kit": "svelte-kit.js"
Expand Down
11 changes: 6 additions & 5 deletions packages/kit/src/exports/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ export interface ActionFailure<T extends Record<string, unknown> | undefined = u
[uniqueSymbol]: true; // necessary or else UnpackValidationError could wrongly unpack objects with the same shape as ActionFailure
}

type UnpackValidationError<T> = T extends ActionFailure<infer X>
? X
: T extends void
? undefined // needs to be undefined, because void will corrupt union type
: T;
type UnpackValidationError<T> =
T extends ActionFailure<infer X>
? X
: T extends void
? undefined // needs to be undefined, because void will corrupt union type
: T;

/**
* This object is passed to the `adapt` function of adapters.
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ async function load_route({ id, invalidating, url, params, route, preload }) {
server_data_node: create_data_node(
// server_data_node is undefined if it wasn't reloaded from the server;
// and if current loader uses server data, we want to reuse previous data.
server_data_node === undefined && loader[0] ? { type: 'skip' } : server_data_node ?? null,
server_data_node === undefined && loader[0] ? { type: 'skip' } : (server_data_node ?? null),
loader[0] ? previous?.server : undefined
)
});
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/server/page/load_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
}
} else {
// simulate CORS errors and "no access to body in no-cors mode" server-side for consistency with client-side behaviour
const mode = input instanceof Request ? input.mode : init?.mode ?? 'cors';
const mode = input instanceof Request ? input.mode : (init?.mode ?? 'cors');
if (mode === 'no-cors') {
response = new Response('', {
status: response.status,
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/server/page/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function render_response({

const form_value =
action_result?.type === 'success' || action_result?.type === 'failure'
? action_result.data ?? null
? (action_result.data ?? null)
: null;

/** @type {string} */
Expand Down
6 changes: 3 additions & 3 deletions packages/kit/test/apps/amp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"devDependencies": {
"@sveltejs/amp": "workspace:^",
"@sveltejs/kit": "workspace:^",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"cross-env": "^7.0.3",
"dropcss": "^1.0.16",
"svelte": "^4.2.10",
"svelte": "^5.2.9",
"svelte-check": "^4.0.1",
"typescript": "^5.5.4",
"vite": "^5.3.2"
"vite": "^6.0.1"
},
"type": "module"
}
6 changes: 3 additions & 3 deletions packages/kit/test/apps/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
},
"devDependencies": {
"@sveltejs/kit": "workspace:^",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
"cross-env": "^7.0.3",
"svelte": "^4.2.10",
"svelte": "^5.2.9",
"svelte-check": "^4.0.1",
"typescript": "^5.5.4",
"vite": "^5.3.2"
"vite": "^6.0.1"
},
"type": "module"
}
40 changes: 24 additions & 16 deletions packages/kit/test/apps/basics/test/cross-platform/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,12 @@ test.describe('Scrolling', () => {
test('url-supplied non-ascii anchor works on navigation to page after manual scroll', async ({
page,
in_view,
clicknav
clicknav,
scroll_to
}) => {
await page.goto('/anchor');
await clicknav('#non-ascii-anchor');
await page.evaluate(() => {
window.scrollTo(0, 50);
});
await scroll_to(0, 50);
await page.locator('#non-ascii-anchor').click();
expect(await in_view('#go-to-encöded')).toBe(true);
});
Expand Down Expand Up @@ -359,7 +358,8 @@ test.describe('Scrolling', () => {

test('scroll is restored after hitting the back button for an in-app cross-document navigation', async ({
page,
clicknav
clicknav,
scroll_to
}) => {
await page.goto('/scroll/cross-document/a');

Expand All @@ -368,7 +368,7 @@ test.describe('Scrolling', () => {
if (!rect) throw new Error('Could not determine bounding box');

const target_scroll_y = rect.y + rect.height - height;
await page.evaluate((y) => scrollTo(0, y), target_scroll_y);
await scroll_to(0, target_scroll_y);

await page.locator('[href="/scroll/cross-document/b"]').click();
expect(await page.textContent('h1')).toBe('b');
Expand Down Expand Up @@ -441,7 +441,8 @@ test.describe('Scrolling', () => {
test('scroll positions are recovered on reloading the page', async ({
page,
app,
browserName
browserName,
scroll_to
}) => {
// No idea why the workaround below works only in dev mode
// A better solution would probably be to set fission.webContentIsolationStrategy: 1
Expand All @@ -451,20 +452,21 @@ test.describe('Scrolling', () => {
}

await page.goto('/anchor');
await page.evaluate(() => window.scrollTo(0, 1000));
await scroll_to(0, 1000);
await app.goto('/anchor/anchor');
await page.evaluate(() => window.scrollTo(0, 1000));
await scroll_to(0, 1000);

await page.reload();
if (browserName === 'firefox') {
// Firefox with Playwright pushed new history entry history after reload
// See https://github.com/microsoft/playwright/issues/22640
await page.goBack();
}
expect(await page.evaluate(() => window.scrollY)).toBe(1000);
await page.waitForFunction(() => window.scrollY === 1000);

const waiter = page.waitForFunction(() => window.scrollY === 1000);
await page.goBack();
expect(await page.evaluate(() => window.scrollY)).toBe(1000);
await waiter;
});

test('scroll position is top of page on ssr:false reload', async ({ page }) => {
Expand All @@ -474,26 +476,32 @@ test.describe('Scrolling', () => {
expect(await page.evaluate(() => window.scrollY)).toBe(0);
});

test('clicking # or #top takes you to the top of the current page', async ({ page }) => {
test('clicking # or #top takes you to the top of the current page', async ({
page,
scroll_to
}) => {
await page.goto('/scroll/top');

for (const href of ['#', '#top']) {
await page.evaluate(() => window.scrollTo(0, 1000));
await scroll_to(0, 1000);
await page.click(`a[href="${href}"]`);
expect(await page.evaluate(() => window.scrollY)).toBe(0);

await page.evaluate(() => window.scrollTo(0, 1000));
await scroll_to(0, 1000);
await page.click(`a[href="${href}"]`);
expect(await page.evaluate(() => window.scrollY)).toBe(0);
}
});

test('Scroll position is correct after going back from a shallow route', async ({ page }) => {
test('Scroll position is correct after going back from a shallow route', async ({
page,
scroll_to
}) => {
await page.goto('/scroll/push-state');
await page.locator('#subpage-link').click();
await page.locator('#back-button').click();

await page.evaluate(() => window.scrollTo(0, 9999));
await scroll_to(0, 9999);

const scroll = await page.evaluate(() => window.scrollY);
expect(scroll).toBeGreaterThan(0);
Expand Down
Loading

0 comments on commit d030f4b

Please sign in to comment.