withastro / starlight

🌟 Build beautiful, accessible, high-performance documentation websites with Astro
https://starlight.astro.build
MIT License
5.05k stars 532 forks source link

Fails to build on stackblitz #252

Closed jlarmstrongiv closed 1 year ago

jlarmstrongiv commented 1 year ago

What version of starlight are you using?

^0.3.0

What version of astro are you using?

^2.5.0

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

I run npm install followed by npm run build

I get a prompt to upgrade to pro? Not sure if it’s sharp or pagefind or the fact that I’m not logged in that causes the issue

image

On the other hand, https://astro.new/basics?on=stackblitz builds just fine

Link to Minimal Reproducible Example

https://astro.new/starlight-basics?on=stackblitz

Participation

TheOtterlord commented 1 year ago

Yep, it seems to be (at least one cause is) image optimisation. Removing the image config option and the sharp package allows it to build (the pop-up still appears, but it builds successfully)

delucis commented 1 year ago

I think something might have broken on StackBlitz’s end because this was definitely working in the past 🤔

Support for sharp is newer there (we used to default to Squoosh mainly for this reason), so maybe there’s a regression.

That modal always displays when building an Astro site on Stackblitz, but usually you can just dismiss it and run the preview command just fine.

jlarmstrongiv commented 1 year ago

What would be the best path forward? Reporting on StackBlitz, switching to Squoosh, or something else?

delucis commented 1 year ago

Good question. I’ve raised this with a contact at StackBlitz, so will see if we get a reply there. I heard they shipped Sharp support last month, but all the Sharp-related issues in OSS repos seem to still be open, so maybe that’s not fully accurate? I kind of hate defaulting to Squoosh as it’s a much slower choice and Sharp does work in most scenarios, but yeah we could think about switching back to Squoosh for now if there’s no other solution.

jlarmstrongiv commented 1 year ago

Oh good! Please keep us posted when you hear back 👍

delucis commented 1 year ago

Will do! Do you have a specific use case that means StackBlitz support is very important? Curious to hear what it is if so!

jlarmstrongiv commented 1 year ago

Yes, I’d like to add an export as website that is client-side only, and using StackBlitz WebContainers seems to be the easiest (and only) way to do that.

I haven’t tried polyfilling the Node.js APIs, since that would probably be heavier and slower—besides, Astro generally already supports StackBlitz.

jlarmstrongiv commented 1 year ago

Upon further inspection, it seems that StackBlitz WebContainers is limited up to 10,000 user sessions/month while CodeSandbox Nodebox cannot be used for commercial purposes.

I checked the polyfills, and not all polyfills are available for the core Node.js imports that Astro uses.

I’ll go ahead and close the issue, but feel free to re-open if it’s an important use-case for starlight.

delucis commented 1 year ago

Ah, I don’t know why I didn’t remember this yesterday — blanked on it I guess — but Starlight itself does not currently actually depend on Sharp, the starter template comes with it installed and configured in astro.config.mjs, but there’s nothing stopping you uninstalling and removing from astro.config.mjs (which is exactly what @TheOtterlord said he did above but somehow my brain still didn’t connect the dots). So maybe that’s a solution for your use case @jlarmstrongiv?

I’ll still keep an eye on this as it’s not ideal if our “Open in StackBlitz” button doesn’t really work.