Skip to content
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

Prerendering broken with ssr=false, prerender=true (and cloudflare) #12598

Closed
domlen2003 opened this issue Aug 20, 2024 · 2 comments
Closed

Prerendering broken with ssr=false, prerender=true (and cloudflare) #12598

domlen2003 opened this issue Aug 20, 2024 · 2 comments

Comments

@domlen2003
Copy link

Describe the bug

Somehow the following +layout.ts doesn't enable prerender completely, meaning it will generate the index.html but won't put the statically rendered content in it:

export const prerender = true;
export const ssr = false;
<body data-sveltekit-preload-data="hover">
  <div style="display: contents">
    <script>
    ...
    </script>
  </div>
</body>

However when using:

export const prerender = true;
export const ssr = true;

The output is correctly prerendered:

<body data-sveltekit-preload-data="hover">
  <div style="display: contents"><!--[--><!--[--><!----><!----><h1>Welcome to SvelteKit</h1> <p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p><!----><!----><!----><!--]--> <!--[!--><!--]--><!--]-->
  <script>
  ...
  </script>
  </div>
</body>

Maybe this is intended but then im not shure why.

This repro is using svelte v5 so that could also be an issue.

Reproduction

https://github.com/domlen2003/sveltekit-ssr-prerender-repro

Logs

No response

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M1
    Memory: 81.50 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.6.0 - ~/.nvm/versions/node/v22.6.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v22.6.0/bin/npm
    pnpm: 9.7.1 - ~/.nvm/versions/node/v22.6.0/bin/pnpm
  Browsers:
    Chrome: 127.0.6533.120
    Safari: 17.6
  npmPackages:
    @sveltejs/adapter-cloudflare: ^4.7.2 => 4.7.2 
    @sveltejs/kit: ^2.5.24 => 2.5.24 
    @sveltejs/vite-plugin-svelte: ^4.0.0-next.6 => 4.0.0-next.6 
    svelte: ^5.0.0-next.229 => 5.0.0-next.229 
    vite: ^5.4.2 => 5.4.2

Severity

serious, but I can work around it

Additional Information

No response

@Conduitry
Copy link
Member

This is intended. If you're setting ssr = false, then you'll get no server-rendered HTML and your app will essentially be an SPA. I believe prerender = true will continue to render out the underlying data and endpoint responses for that page, however.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Aug 20, 2024
@domlen2003
Copy link
Author

Okay then the docs seem to be a bit unclear here. It sound like its either prerender or ssr. Most people will probably think the prerender option will already give them a fully prerendered page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants