Daydreamer-riri / vite-react-ssg

Static-site generation for React on Vite.
https://vite-react-ssg.netlify.app/
MIT License
127 stars 6 forks source link

ReferenceError: window is not defined in build #44

Open cinderblock opened 15 hours ago

cinderblock commented 15 hours ago

I'm building a simple static site on GitHub Actions (for publishing on GH Pages) and am getting an error that requested I report it here.

Excerpt below. See the full project/build here: https://github.com/cinderblock/awesome-led-list/actions/runs/12092799259/job/33722975047

ReferenceError: window is not defined
    at n (/home/runner/work/awesome-led-list/awesome-led-list/node_modules/fork-me-on-github/lib/index.js:1:9915)
    at i (/home/runner/work/awesome-led-list/awesome-led-list/node_modules/fork-me-on-github/lib/index.js:1:10003)
    at e.exports (/home/runner/work/awesome-led-list/awesome-led-list/node_modules/fork-me-on-github/lib/index.js:1:13575)
    at Object.<anonymous> (/home/runner/work/awesome-led-list/awesome-led-list/node_modules/fork-me-on-github/lib/index.js:1:8533)
    at r (/home/runner/work/awesome-led-list/awesome-led-list/node_modules/fork-me-on-github/lib/index.js:1:124)
    at Module.<anonymous> (/home/runner/work/awesome-led-list/awesome-led-list/node_modules/fork-me-on-github/lib/index.js:1:4231)
    at r (/home/runner/work/awesome-led-list/awesome-led-list/node_modules/fork-me-on-github/lib/index.js:1:124)
    at /home/runner/work/awesome-led-list/awesome-led-list/node_modules/fork-me-on-github/lib/index.js:1:923
    at Object.<anonymous> (/home/runner/work/awesome-led-list/awesome-led-list/node_modules/fork-me-on-github/lib/index.js:1:932)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:203:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:[337](https://github.com/cinderblock/awesome-led-list/actions/runs/12092799259/job/33722975047#step:4:338):24)
    at async build (file:///home/runner/work/awesome-led-list/awesome-led-list/node_modules/vite-react-ssg/dist/shared/vite-react-ssg.BdRX-qCI.mjs:789:88)
    at async Object.handler (file:///home/runner/work/awesome-led-list/awesome-led-list/node_modules/vite-react-ssg/dist/node/cli.mjs:51:5)
Daydreamer-riri commented 13 hours ago

This is because fork-me-on-github does not support server-side rendering.

You can wrap it in ClientOnly. Or open an issue in the fork-me-on-github repo.

cinderblock commented 11 hours ago

Ah, that makes sense.

What changes (high level) would be needed to make it SSR-able?

Think it's worth updating, forking, finding a different package, or just extracting the source?

Daydreamer-riri commented 11 hours ago

I don't familiar with this library. But I think it should have alternatives to support server-side rendering.