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

[Bug?]: can't prerender routes using npm install #1162

Closed
2 tasks done
birkskyum opened this issue Dec 20, 2023 · 10 comments
Closed
2 tasks done

[Bug?]: can't prerender routes using npm install #1162

birkskyum opened this issue Dec 20, 2023 · 10 comments
Labels
bug Something isn't working vinxi related to vinxi

Comments

@birkskyum
Copy link
Member

birkskyum commented Dec 20, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

initializing the basic template, and enabling prerender with this vite config (setting ssr: true doesn't change things):

import { defineConfig } from "@solidjs/start/config";

export default defineConfig({
  start: {
    server: {
      prerender: {
        crawlLinks: true, // (or routes: ["/"], both break)
      },
    },
  },
});

then running npm run build gives this error:

┌────────────────────────────────────────┐
│ ⚙  Preparing app for node-server...    │
└────────────────────────────────────────┘
vinxi hook app:build:nitro:config                                                                                 11:43:20 PM
vinxi hook app:build:nitro:assets:copy:start                                                                      11:43:20 PM
✔ Generated public .output/public                                                                          vinxi 11:43:20 PM
vinxi hook app:build:nitro:assets:copy:end                                                                        11:43:20 PM
vinxi hook app:build:nitro:prerender:start                                                                        11:43:20 PM
ℹ Initializing prerenderer                                                                                 vinxi 11:43:20 PM

 ERROR  Should be provided by compiler                                                                            11:43:20 PM

  at .vinxi/prerender/index.mjs:1232:7
  at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
  at async ModuleLoader.import (node:internal/modules/esm/loader:308:24)
  at async prerender (node_modules/nitropack/dist/shared/nitro.0a84349b.mjs:56:26)
  at async createBuild (node_modules/vinxi/lib/build.js:306:2)
  at async Object.run (node_modules/vinxi/bin/cli.mjs:156:5)
  at async runCommand (node_modules/citty/dist/index.mjs:316:16)
  at async runCommand (node_modules/citty/dist/index.mjs:307:11)
  at async runMain (node_modules/citty/dist/index.mjs:441:7) 



 ERROR  Should be provided by compiler                                                                            11:43:20 PM

Expected behavior 🤔

I expected not getting an error here

Steps to reproduce 🕹

Steps:

  1. npm create solid
  2. choose bare
  3. update vite.config.ts with crawlLinks flag
  4. npm install (important step, as yarn, pnpm i or bun i will work as expected)
  5. npm run build

Context 🔦

No response

Your environment 🌎

deps

    "@solidjs/meta": "^0.29.2",
    "@solidjs/router": "^0.10.5",
    "@solidjs/start": "^0.4.0",
    "solid-js": "^1.8.7",
    "vinxi": "0.0.52"

macos arm
chrome 120
@birkskyum birkskyum added the bug Something isn't working label Dec 20, 2023
@birkskyum
Copy link
Member Author

@atilafassina have you managed to prerender anything so far with start/vinxi?

@ryansolid
Copy link
Member

Interestingly our docs are pre-rendered using this technique. And all CSR uses prerendering. Maybe this is a combo with server functions. That compiler error looks similar to when you access a server function that hasn't been transformed.

@birkskyum
Copy link
Member Author

birkskyum commented Dec 21, 2023

Great point. I used the solid-start docs to narrow down what goes wrong, and it's quite odd, but I've found that it breaks as explained above only when using npm i (tested the versions bundled with Node 18/20). Using yarn, pnpm i or bun i (like in the case of the solid-start/docs with pnpm), before either of pnpm/yarn/npm run build will work as expected.

@birkskyum birkskyum changed the title [Bug?]: can't prerender routes [Bug?]: can't prerender routes using npm install Dec 21, 2023
@ryansolid
Copy link
Member

Hmm.. I wonder if this is why @nksaraf had the resolution code (that was breaking prerendering for me) before. What was happening before was completely different so I can't use that as any basis. But its odd that package manager would impact this so.

@ryansolid ryansolid added the vinxi related to vinxi label Dec 21, 2023
@nksaraf
Copy link
Member

nksaraf commented Dec 21, 2023

This usually means something went wrong with the fs-router.. i'll look into it ,gotta admit haven't used npm in a while. Wondering if I can reproduce this in a stackblitz.

@birkskyum
Copy link
Member Author

birkskyum commented Dec 22, 2023

I haven't been able to run the basic example of start 0.4 in stackblitz as is (no prerender flags), because I get this error:

[h3] [unhandled] TypeError: Cannot read properties of undefined (reading 'assets')
    at get assets [as assets] (/home/projects/pariwmzoo.github/node_modules/.pnpm/@solidjs+start@0.4.2_solid-js@1.8.7_vinxi@0.0.54_vite@5.0.10/node_modules/@solidjs/start/server/StartServer.tsx:50:109)

@nksaraf
Copy link
Member

nksaraf commented Dec 22, 2023

@birkskyum I tried your repro setup:

Screenshot 2023-12-22 at 6 24 56 AM

Seems to work for me.. Mind making a repo or something on stackblitz with the error you are describing. Have you got the latest versions of stuff?

@brenelz
Copy link
Contributor

brenelz commented Dec 22, 2023

I was able to replicate on "vinxi": "0.0.52" but 0.0.54 seems to have it fixed

I think you need ssr: false to replicate

@birkskyum
Copy link
Member Author

@brenelz , you're very right - 0.0.53 was the latest when I opened the ticket, and updating to 0.0.54 did the trick. Thanks you all

@atilafassina
Copy link
Member

@atilafassina have you managed to prerender anything so far with start/vinxi?

Sorry @birkskyum. I was absolutely disconnected on vacation, only catching up with things now... 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vinxi related to vinxi
Projects
None yet
Development

No branches or pull requests

5 participants