Skip to content

Prerender during build rather than adapt #4112

@Rich-Harris

Description

@Rich-Harris

Describe the problem

Currently, prerendering happens inside adapters. This creates various minor problems:

  • svelte-kit preview doesn't use prerendered pages — loss of fidelity, and slow performance that's unreflective of production build
  • adapters have to be careful to prerender before generating manifests
  • prerendering doesn't happen if you haven't configured an adapter, or you're doing svelte-kit build locally with adapter-auto (unless you prefix it like VERCEL=1 npm run build)

Describe the proposed solution

I think prerendering should happen during build, before the adapter runs.

The fly in the ointment is adapter-static, which needs to specify that all pages should be prerendered (not just those explicitly marked as capable of being prerendered) unless a fallback is specified. A config.kit.prerender.all or config.kit.prerender.default option could stand in for that, and could also mean 'prerender everything without export const prerender = false. Together with a builder.prerenderFallback method, we could solve the adapter-static problem in a way that gives everyone a bit more flexibility. (Would probably need to make adapter-static aware of the all/default option via the builder so that it can instruct people to update their config accordingly.)

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions