-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: include server assets for Vercel serverless functions (#10979)
* add ability to copy server assets per route * changeset * fix test * fix doc * fix asset copying * change process dir when using vite preview * remove process.chdir from vite preview * include assets used by default error pages * fix doc link * better doc example * fix doc type * ok for real * add tests for vercel adapter * prettier * fix tests * fix types * more type fixes * try this * documentation * skip adapter-vercel tests if on node v20 * oopsie wrong PR * move server asset metadata resolving to function * update changesets * revert builder test fixes * fix lockfile * prettier * lint * fix vercel tsc errors * prepublish only * fix: avoid running load functions when prerendering if no server load function exists and SSR is off (#11405) * chore: upgrade eslint-plugin-unicorn (#11432) * Version Packages (#11420) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore(deps): update dependency worktop to v0.8.0-next.16 (#11437) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * i don't think we need this any more (#11439) Co-authored-by: Rich Harris <rich.harris@vercel.com> * fix: only disallow dynamic env access when prerendering (#11436) * only disallow dynamic env access when prerendering * changeset * add test * sigh --------- Co-authored-by: Rich Harris <rich.harris@vercel.com> * docs: fix links to sveltesociety.dev (#11441) * Version Packages (#11442) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * fix: set ESLint config type to `Config` instead of `FlatConfig` (#11453) * Version Packages (#11457) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * fix: improve warning when encountering import.meta.env (#11440) * empty commit (#11469) Co-authored-by: Rich Harris <rich.harris@vercel.com> * fix form actions docs (#11470) Co-authored-by: Rich Harris <rich.harris@vercel.com> * Version Packages (#11468) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore(deps): update pnpm to v8.13.1 (#11471) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * docs: add performance page (#11424) * docs: add performance page * address minor feedback issues * lazy loading and waterfalls * prefetching * Apply suggestions from code review * Apply suggestions from code review * various * tweak * MDN page says nothing about lazy-loading videos * fix link * Update documentation/docs/40-best-practices/05-performance.md Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * move images page * Update documentation/docs/40-best-practices/05-performance.md Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * update font section (no point mentioning font-display without a recommended value) * various tweaks --------- Co-authored-by: Rich Harris <richard.a.harris@gmail.com> Co-authored-by: Rich Harris <rich.harris@vercel.com> * chore(deps): update pnpm to v8.14.0 (#11504) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * feat: use latest Azure adapter in adapter-auto (#11496) * fix: update @vercel/nft to 0.26.1 (#11508) * Version Packages (#11507) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * exclude universal nodes * include assets imported by server hooks * update adapter-vercel tests * fix tests * fix and add test for server hooks assets * update adapter-vercel test app packages * im gonna lose my mind * ignore hashes for filenames in tests * oops * fix tests? * revert adapter-vercel types fix * improve readability of route asset for loop * simplify file reading in serverless functions example --------- Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Rich Harris <richard.a.harris@gmail.com> Co-authored-by: Rich Harris <rich.harris@vercel.com> Co-authored-by: Geoff Rich <4992896+geoffrich@users.noreply.github.com>
- Loading branch information
1 parent
22ed677
commit fe1a11e
Showing
52 changed files
with
1,278 additions
and
617 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/adapter-vercel': minor | ||
--- | ||
|
||
feat: bundle server assets with serverless functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': minor | ||
--- | ||
|
||
feat: adapter method to get server assets used by each route |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.DS_Store | ||
node_modules | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.DS_Store | ||
node_modules | ||
/build | ||
/.svelte-kit | ||
/package | ||
.env | ||
.env.* | ||
!.env.example | ||
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
engine-strict=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "~TODO~", | ||
"version": "0.0.1", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite dev", | ||
"build": "vite build", | ||
"preview": "vite preview", | ||
"test": "playwright test" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/kit": "workspace:^", | ||
"svelte": "^4.2.8", | ||
"typescript": "^5.3.3", | ||
"vite": "^5.0.8" | ||
}, | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { config as default } from '../../utils.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// See https://kit.svelte.dev/docs/types#app | ||
// for information about these interfaces | ||
declare global { | ||
namespace App { | ||
// interface Error {} | ||
// interface Locals {} | ||
// interface PageData {} | ||
// interface Platform {} | ||
} | ||
} | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="%sveltekit.assets%/favicon.png" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
%sveltekit.head% | ||
</head> | ||
<body data-sveltekit-preload-data="hover"> | ||
<div style="display: contents">%sveltekit.body%</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import text from '$lib/hooks.server.js.txt'; | ||
|
||
export async function handle({ event, resolve }) { | ||
event.setHeaders({ 'x-server-asset': text }); | ||
return resolve(event); | ||
} |
1 change: 1 addition & 0 deletions
1
packages/adapter-vercel/test/apps/split/src/lib/+error.svelte.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
+error.svelte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
+layout.js |
1 change: 1 addition & 0 deletions
1
packages/adapter-vercel/test/apps/split/src/lib/+layout.server.js.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
+layout.server.js |
1 change: 1 addition & 0 deletions
1
packages/adapter-vercel/test/apps/split/src/lib/+layout.svelte.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
+layout.svelte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
+page.js |
1 change: 1 addition & 0 deletions
1
packages/adapter-vercel/test/apps/split/src/lib/+page.server.js.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
+page.server.js |
1 change: 1 addition & 0 deletions
1
packages/adapter-vercel/test/apps/split/src/lib/+page.svelte.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
+page.svelte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
+server.js |
Empty file.
1 change: 1 addition & 0 deletions
1
packages/adapter-vercel/test/apps/split/src/lib/hooks.server.js.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hooks.server.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
root_error |
1 change: 1 addition & 0 deletions
1
packages/adapter-vercel/test/apps/split/src/lib/root_layout.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
root_layout |
3 changes: 3 additions & 0 deletions
3
packages/adapter-vercel/test/apps/split/src/lib/transitive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import text from './transitive.txt'; | ||
|
||
export { text }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
transitive |
9 changes: 9 additions & 0 deletions
9
packages/adapter-vercel/test/apps/split/src/routes/+error.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script> | ||
import asset from '$lib/root_error.txt'; | ||
/** @type {import('./$types').PageData}*/ | ||
export let data; | ||
</script> | ||
|
||
<h1>{data}</h1> | ||
<p>{asset}</p> |
5 changes: 5 additions & 0 deletions
5
packages/adapter-vercel/test/apps/split/src/routes/+layout.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import layout from '$lib/+layout.js.txt'; | ||
|
||
export function load({ data }) { | ||
return { ...data, layout }; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/adapter-vercel/test/apps/split/src/routes/+layout.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import layout_server from '$lib/+layout.server.js.txt'; | ||
|
||
export function load() { | ||
return { layout_server }; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/adapter-vercel/test/apps/split/src/routes/+page.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { text } from '$lib/transitive'; | ||
|
||
export function load() { | ||
return { text }; | ||
} |
Empty file.
5 changes: 5 additions & 0 deletions
5
packages/adapter-vercel/test/apps/split/src/routes/api/+server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import server_asset from '$lib/+server.js.txt'; | ||
|
||
export function GET() { | ||
return new Response(server_asset); | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/adapter-vercel/test/apps/split/src/routes/load/+error.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import asset from '$lib/+error.svelte.txt'; | ||
</script> | ||
|
||
<p>{asset}</p> |
5 changes: 5 additions & 0 deletions
5
packages/adapter-vercel/test/apps/split/src/routes/load/+layout.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import layout from '$lib/+layout.js.txt'; | ||
|
||
export function load() { | ||
return { layout }; | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/adapter-vercel/test/apps/split/src/routes/load/+layout.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
import asset from '$lib/+layout.svelte.txt'; | ||
</script> | ||
|
||
<p>{asset}</p> | ||
|
||
<slot /> |
5 changes: 5 additions & 0 deletions
5
packages/adapter-vercel/test/apps/split/src/routes/load/+page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import page_data from '$lib/+page.js.txt'; | ||
|
||
export async function load({ parent, data }) { | ||
return { ...data, ...(await parent()), page_data }; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/adapter-vercel/test/apps/split/src/routes/load/+page.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import page_server_text from '$lib/+page.server.js.txt'; | ||
|
||
export async function load({ parent }) { | ||
return { ...(await parent()), page_server_text }; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/adapter-vercel/test/apps/split/src/routes/load/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import asset from '$lib/+page.svelte.txt'; | ||
</script> | ||
|
||
<p>{asset}</p> |
Oops, something went wrong.