preactjs / preset-vite

Preset for using Preact with the vite bundler
https://npm.im/@preact/preset-vite
MIT License
262 stars 27 forks source link

build fails when using prerender #110

Closed mayank99 closed 8 months ago

mayank99 commented 8 months ago

Trying out the prerender plugin with version 2.8.1, I cannot get the build to pass.

x Build failed in 407ms
error during build:
TypeError: [preact:prerender] d is not a function
    at i (file:///<repo>/node_modules/@preact/preset-vite/headless-prerender/prerender-DWVaPvWr.js:1:262)
    at Module.g (file:///<repo>/node_modules/@preact/preset-vite/headless-prerender/prerender-DWVaPvWr.js:1:437)
    at file:///<repo>/node_modules/@preact/preset-vite/headless-prerender/main-DSgznFuN.js:1:16171

See repro: https://stackblitz.com/edit/vitejs-vite-ybgooe?file=src%2Fmain.jsx,vite.config.js&terminal=build

rschristian commented 8 months ago

Can you reproduce outside of stackblitz?

Edit: You don't have preact-render-to-string installed, that's the issue. See https://github.com/preactjs/preset-vite/issues/101

The errors unfortunately suck, and it seems like this is something Vite needs to correct, but we're certainly open to ideas if you got 'em.

mayank99 commented 8 months ago

You don't have preact-render-to-string installed, that's the issue. See #101

Yup, that was it! 🤦 Thanks for the quick response.

rschristian commented 8 months ago

Sorry for the headache!