#how do i make starlight work with output: "server"

12 messages · Page 1 of 1 (latest)

shy spoke
#

im trying to add starlight docs to my website but all im getting is

 error   Cannot read properties of undefined (reading 'render')
  File:
    /opt/dev/ascellav3/ascella-web/opt/dev/ascellav3/node_modules/.pnpm/@astrojs+starlight@0.4.1_astro@2.7.2/node_modules/@astrojs/starlight/index.astro:12:55
  Stacktrace:
TypeError: Cannot read properties of undefined (reading 'render')
    at /opt/dev/ascellav3/node_modules/.pnpm/@astrojs+starlight@0.4.1_astro@2.7.2/node_modules/@astrojs/starlight/index.astro:12:55
    at index (/opt/dev/ascellav3/node_modules/.pnpm/astro@2.7.2/node_modules/astro/dist/runtime/server/astro-component.js:19:12)
    at renderPage (file:///opt/dev/ascellav3/node_modules/.pnpm/astro@2.7.2/node_modules/astro/dist/runtime/server/render/page.js:96:36)
    at renderPage (file:///opt/dev/ascellav3/node_modules/.pnpm/astro@2.7.2/node_modules/astro/dist/core/render/core.js:109:24)
    at renderPage (file:///opt/dev/ascellav3/node_modules/.pnpm/astro@2.7.2/node_modules/astro/dist/core/render/dev/index.js:133:16)
    at async handleRoute (file:///opt/dev/ascellav3/node_modules/.pnpm/astro@2.7.2/node_modules/astro/dist/vite-plugin-astro-server/route.js:167:20)
    at async run (file:///opt/dev/ascellav3/node_modules/.pnpm/astro@2.7.2/node_modules/astro/dist/vite-plugin-astro-server/request.js:47:14)
    at async runWithErrorHandling (file:///opt/dev/ascellav3/node_modules/.pnpm/astro@2.7.2/node_modules/astro/dist/vite-plugin-astro-server/controller.js:65:5)
    at async handleRequest (file:///opt/dev/ascellav3/node_modules/.pnpm/astro@2.7.2/node_modules/astro/dist/vite-plugin-astro-server/request.js:41:3)
 (x2)

is there a workaround to make starlight work with ssr and cloudflare adapter?

ancient knot
#

Hi @shy spoke! Starlight is designed for static use currently. You may be able to get it working partially with output: 'hybrid' if that’s an option in your project?

#

You’d need to add export const prerender = false; to any existing SSR routes you have.

shy spoke
#

oh thats workable thanks

#

i only have 2 real ssr endpoints anyway

ancient knot
#

Let me know how you get on! We prioritised static builds first as it’s the most common use case for docs sites, but do want to make SSR support better eventually.

shy spoke
#

tested it and works as expected thanks

ancient knot
#

Nice — thanks for letting me know 🙌

shy spoke
#

update: dev works but building doesnt guessing that sharp is the culprit here i havent found a way to disable it

Error: Build failed with 90 errors:
dist/$server_build/_worker.mjs:3:7: ERROR: Could not resolve "fs"
dist/$server_build/_worker.mjs:4:7: ERROR: Could not resolve "node:fs/promises"
dist/$server_build/_worker.mjs:5:7: ERROR: Could not resolve "node:url"
dist/$server_build/_worker.mjs:6:7: ERROR: Could not resolve "node:fs"
dist/$server_build/_worker.mjs:7:7: ERROR: Could not resolve "node:path"
...
    at failureErrorWithLog (/opt/dev/ascellav3/node_modules/.pnpm/esbuild@0.17.19/node_modules/esbuild/lib/main.js:1636:15)
    at /opt/dev/ascellav3/node_modules/.pnpm/esbuild@0.17.19/node_modules/esbuild/lib/main.js:1048:25
    at /opt/dev/ascellav3/node_modules/.pnpm/esbuild@0.17.19/node_modules/esbuild/lib/main.js:993:52
    at buildResponseToResult (/opt/dev/ascellav3/node_modules/.pnpm/esbuild@0.17.19/node_modules/esbuild/lib/main.js:1046:7)
    at /opt/dev/ascellav3/node_modules/.pnpm/esbuild@0.17.19/node_modules/esbuild/lib/main.js:1075:16
    at responseCallbacks.<computed> (/opt/dev/ascellav3/node_modules/.pnpm/esbuild@0.17.19/node_modules/esbuild/lib/main.js:697:9)
    at handleIncomingPacket (/opt/dev/ascellav3/node_modules/.pnpm/esbuild@0.17.19/node_modules/esbuild/lib/main.js:752:9)
    at Socket.readFromStdout (/opt/dev/ascellav3/node_modules/.pnpm/esbuild@0.17.19/node_modules/esbuild/lib/main.js:673:7)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
ancient knot
#

Ahhh. Could be sharp but Starlight doesn't force sharp usage so you should be able to disable and uninstall that if needed. There may be a couple of places we use node deps inside Starlight code though (path utilities specifically I can remember). What's your deploy target?

shy spoke
#

cloudflare pages