roxiness / routify

Automated Svelte routes
https://routify.dev
1.85k stars 86 forks source link

[Routify V3] SSR (or at least prerendering) seems to be broken in 3.0.0-next.162 #522

Closed jfaust closed 11 months ago

jfaust commented 11 months ago

Describe the bug

In 3.0.0-next.162, every page I prerender results in the same content, with basically nothing in it:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width,initial-scale=1" />

        <title>Svelte app</title>

        <!-- Google Fonts -->
        <link
            rel="stylesheet"
            href="https://fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic"
        />

        <!-- CSS Reset -->
        <link
            rel="stylesheet"
            href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css"
        />

        <!-- Milligram CSS -->
        <link
            rel="stylesheet"
            href="https://cdnjs.cloudflare.com/ajax/libs/milligram/1.4.1/milligram.css"
        />

      <script type="module" crossorigin src="/assets/index-41f120a6.js"></script>
    </head>

    <body>
        <div data-routify-anchor-parent style="display: contents"></div>
    </body>
</html>

This appears to have started because of the introduction of a promise/await to ComposeFragments.svelte in https://github.com/roxiness/routify/commit/4fb080e9698ec759d0914b6db6eb1124e49683dc.

Reproduction

(These steps assume pnpm, modify for npm or yarn)

  1. Create a new project via npx @roxi/routify@next create
  2. Ensure it's setup for ssr/prerendering (I force-enabled ssr & hydratable in the vite config)
  3. Update dependencies to latest: pnpm update --latest @roxi/routify@next vite svelte @sveltejs/vite-plugin-svelte mdsvex @sveltejs/vite-plugin-svelte spank
  4. Run pnpm build
  5. You may hit an error about fetch not being found, this is fine for now, though that's another issue
  6. cd dist/server
  7. node serve.js render /hello-world
  8. Note that the output does not include the Hello World contents, just a single root div
  9. Downgrade to 3.0.0-next.161
  10. Run the build
  11. Run the serve command
  12. Note that the output includes everything you'd expect

Logs

No response

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
    Memory: 22.03 GB / 31.30 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.16.0/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
    pnpm: 8.6.0 - ~/.local/share/pnpm/pnpm
  npmPackages:
    @roxi/routify: 3.0.0-next.162 => 3.0.0-next.162 
    svelte: ^4.0.5 => 4.0.5 
    vite: ^4.4.4 => 4.4.4
jakobrosenberg commented 11 months ago

Thanks for the thorough reproduction. 🙏 I'm hoping to have a fix released today.

jakobrosenberg commented 11 months ago

Fixed in 163