-
-
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: implement readAsset * lint etc * maybe make it work on netlify? no idea how to test, manual deploys dont appear to respect .netlify directory * set length/type from manifest * tidy up * regenerate types * lint * missed a spot * more efficient manifest generation * working on vercel * lint/fix * Update packages/adapter-vercel/index.js Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> * fix * createReadable helper * more future-proof API * account for basepath * lint * rename to just `read` * inline docs * it is already deprecated, we just need to remove it * read_asset -> read_implementation * add test * Apply suggestions from code review Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * improve searchability * prevent $app/server being imported client-side * regenerate types * add dev time feature tracking mechanism * test feature support at build time * lint * lint * regenerate types * account for hooks.server.js, mostly * regenerate types * fix * bump peerdeps, add changesets * createReadable -> createReadableStream * Apply suggestions from code review Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * remove unnecessary if * replace docs for find_server_assets * update adapter author docs * regenerate types * explain what __SVELTEKIT_TRACK__ does * mention `$app/server` on server-only modules page * minor details * oh ffs * exclude prerendered routes from feature detection, handle /@fs assets in dev * use read to populate content.json * fix prerendering * simplify * simplify docs logic * fix * style * simplify * lockfile * Apply suggestions from code review Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * capitalize * Apply suggestions from code review Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> --------- Co-authored-by: Rich Harris <rich.harris@vercel.com> Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
- Loading branch information
1 parent
7d3cccd
commit 288f731
Showing
57 changed files
with
800 additions
and
235 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,7 @@ | ||
--- | ||
'@sveltejs/adapter-netlify': major | ||
'@sveltejs/adapter-vercel': major | ||
'@sveltejs/adapter-node': major | ||
--- | ||
|
||
breaking: update peer dependency on `@sveltejs/kit` |
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: add `$app/server` module with `read` function for reading assets from filesystem |
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 @@ | ||
--- | ||
'@sveltejs/adapter-netlify': minor | ||
'@sveltejs/adapter-vercel': minor | ||
'@sveltejs/adapter-node': minor | ||
--- | ||
|
||
feat: support `read` from `$app/server` |
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
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 |
---|---|---|
|
@@ -51,6 +51,6 @@ | |
"vitest": "^1.2.0" | ||
}, | ||
"peerDependencies": { | ||
"@sveltejs/kit": "^2.0.0" | ||
"@sveltejs/kit": "^2.4.0" | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -50,6 +50,6 @@ | |
"rollup": "^4.9.5" | ||
}, | ||
"peerDependencies": { | ||
"@sveltejs/kit": "^2.0.0" | ||
"@sveltejs/kit": "^2.4.0" | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -42,6 +42,6 @@ | |
"vitest": "^1.2.0" | ||
}, | ||
"peerDependencies": { | ||
"@sveltejs/kit": "^2.0.0" | ||
"@sveltejs/kit": "^2.4.0" | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
packages/kit/src/core/generate_manifest/find_server_assets.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,52 @@ | ||
import { find_deps } from '../../exports/vite/build/utils.js'; | ||
|
||
/** | ||
* Finds all the assets that are imported by server files associated with `routes` | ||
* @param {import('types').BuildData} build_data | ||
* @param {import('types').RouteData[]} routes | ||
*/ | ||
export function find_server_assets(build_data, routes) { | ||
/** | ||
* All nodes actually used in the routes definition (prerendered routes are omitted). | ||
* Root layout/error is always included as they are needed for 404 and root errors. | ||
* @type {Set<any>} | ||
*/ | ||
const used_nodes = new Set([0, 1]); | ||
|
||
// TODO add hooks.server.js asset imports | ||
/** @type {Set<string>} */ | ||
const server_assets = new Set(); | ||
|
||
/** @param {string} id */ | ||
function add_assets(id) { | ||
if (id in build_data.server_manifest) { | ||
const deps = find_deps(build_data.server_manifest, id, false); | ||
for (const asset of deps.assets) { | ||
server_assets.add(asset); | ||
} | ||
} | ||
} | ||
|
||
for (const route of routes) { | ||
if (route.page) { | ||
for (const i of route.page.layouts) used_nodes.add(i); | ||
for (const i of route.page.errors) used_nodes.add(i); | ||
used_nodes.add(route.page.leaf); | ||
} | ||
|
||
if (route.endpoint) { | ||
add_assets(route.endpoint.file); | ||
} | ||
} | ||
|
||
for (const n of used_nodes) { | ||
const node = build_data.manifest_data.nodes[n]; | ||
if (node?.server) add_assets(node.server); | ||
} | ||
|
||
if (build_data.manifest_data.hooks.server) { | ||
add_assets(build_data.manifest_data.hooks.server); | ||
} | ||
|
||
return Array.from(server_assets); | ||
} |
Oops, something went wrong.