-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: implement read
#11649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: implement read
#11649
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
f53ca45
feat: implement readAsset
Rich-Harris 716c594
lint etc
Rich-Harris a294256
maybe make it work on netlify? no idea how to test, manual deploys do…
Rich-Harris 15880de
set length/type from manifest
Rich-Harris 5163e36
tidy up
Rich-Harris 289155a
regenerate types
Rich-Harris da88785
lint
Rich-Harris caf010f
missed a spot
Rich-Harris 4eba560
more efficient manifest generation
Rich-Harris 6045dfc
working on vercel
Rich-Harris 5c6f2df
lint/fix
Rich-Harris c9bfc03
Update packages/adapter-vercel/index.js
Rich-Harris 41514d3
fix
Rich-Harris c4ecda4
createReadable helper
Rich-Harris fbd02c8
Merge branch 'read-asset' of github.com:sveltejs/kit into read-asset
Rich-Harris 809fafd
more future-proof API
Rich-Harris d559345
account for basepath
Rich-Harris d5b98da
lint
Rich-Harris 8f5fd84
rename to just `read`
Rich-Harris 08fd1b1
inline docs
Rich-Harris 8d606a2
it is already deprecated, we just need to remove it
Rich-Harris 7609aa0
read_asset -> read_implementation
Rich-Harris b3dfa65
add test
Rich-Harris 38e1419
Apply suggestions from code review
Rich-Harris 2c0f579
improve searchability
Rich-Harris 0169191
Merge branch 'read-asset' of github.com:sveltejs/kit into read-asset
Rich-Harris 8ec59df
prevent $app/server being imported client-side
Rich-Harris 2c4a2cc
regenerate types
Rich-Harris a2c469c
add dev time feature tracking mechanism
Rich-Harris e338d78
test feature support at build time
Rich-Harris 12c0e46
lint
Rich-Harris 55c9637
lint
Rich-Harris 2447b56
regenerate types
Rich-Harris 75f22a3
account for hooks.server.js, mostly
Rich-Harris 12b91b5
regenerate types
Rich-Harris 501491f
fix
Rich-Harris 5c140b3
bump peerdeps, add changesets
Rich-Harris 2f2bccc
createReadable -> createReadableStream
Rich-Harris 73bd682
Apply suggestions from code review
Rich-Harris 39d4e6d
remove unnecessary if
Rich-Harris 3353c1f
replace docs for find_server_assets
Rich-Harris 8409574
update adapter author docs
Rich-Harris f8df6cb
regenerate types
Rich-Harris aea2992
explain what __SVELTEKIT_TRACK__ does
Rich-Harris 2b44e59
mention `$app/server` on server-only modules page
Rich-Harris 2e38c71
minor details
Rich-Harris 36a39fb
oh ffs
Rich-Harris 2bd0faa
exclude prerendered routes from feature detection, handle /@fs assets…
Rich-Harris 501fa0e
use read to populate content.json
Rich-Harris 1a35f7f
fix prerendering
Rich-Harris 10be71f
simplify
Rich-Harris 984e9b4
simplify docs logic
Rich-Harris 0eebe9f
fix
Rich-Harris b85d699
style
Rich-Harris 92fb9f6
simplify
Rich-Harris 71ba727
lockfile
Rich-Harris 86c22cc
Apply suggestions from code review
Rich-Harris a53c0b6
capitalize
Rich-Harris 2b3746c
Apply suggestions from code review
Rich-Harris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.