Skip to content

SvelteKit generates __data.json request even if +page.* does not export a load function #7967

@ivanhofer

Description

@ivanhofer

Describe the bug

A SvelteKit application makes a request to __data/json even when no actual load function gets exported inside +page.server.js.

I would expect that no unnecessary request gets made as it should be clear to SvelteKit that it can't fetch any data from that endpoint.

Someone could argue if an empty +page.server.ts file makes sense at all.
Maybe SvelteKit should throw an error if it sees that a +page.server.ts file does not export anything that is useful to SvelteKit.
I could imagine there will be some users that create a load function, but forget to export it. In this case an error message would be really helpful before they have to figure out what they did wrong.

Of course this would make sense for all other +*.ts files

Reproduction

Repo: https://stackblitz.com/edit/sveltejs-kit-template-default-djcepj?file=src/routes/test/+page.server.ts

  1. start the application
  2. hover over the link
  3. check the logs, a request to /test/__data.json was made, even if +page,server,ts does not export a load function

Logs

No response

System Info

StackBlitz

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions