-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
breaking changefeature / enhancementNew feature or requestNew feature or requestsize:largesignificant feature with tricky design questions and multi-day implementationsignificant feature with tricky design questions and multi-day implementation
Milestone
Description
Describe the problem
If an endpoint loads data from the filesystem...
import fs from 'fs';
import marked from 'marked';
export function get({ params }) {
const markdown = fs.readFileSync(`content/${params.slug}.md`, 'utf-8');
return {
body: marked(markdown)
};
}
...then in most environments it will won't work in production — it's only suitable for prerendering. SvelteKit doesn't know that, and will include the endpoint in the built app. This is bad for two reasons:
- it means deploying unnecessary code
- a mistyped URL will 500 instead of 404
We're experiencing this right now with https://kit.svelte.dev/docs/nope.
Describe the proposed solution
If we could mark the endpoint with export const prerender = true
, just like we do with pages, we could avoid including the endpoint in the deployed app.
The semantics are slightly different to export const prerender = true
in pages, where it means 'you can prerender this page' as opposed to 'you can ONLY prerender this endpoint', but I think that's probably fine.
Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response
JustinVoitel, robots4life, furudean, topazrn, SG60 and 9 more
Metadata
Metadata
Assignees
Labels
breaking changefeature / enhancementNew feature or requestNew feature or requestsize:largesignificant feature with tricky design questions and multi-day implementationsignificant feature with tricky design questions and multi-day implementation