website: fix build failure when popular issues data is absent#525
website: fix build failure when popular issues data is absent#525devin-lai wants to merge 1 commit into
Conversation
The GitHubIssues component imports static/data/popular-issues.json at build time. That file is generated by `npm run fetch-popular-issues` (which needs a GitHub token) and is gitignored, so on a fresh checkout `npm run build` and `npm start` fail with "Cannot find module '@site/static/data/popular-issues.json'". Add a prestart/prebuild step that writes an empty fallback when the file is missing, so the documented local workflow works out of the box. Existing data is never overwritten, leaving CI behavior unchanged.
|
Preview: https://devin-lai.github.io/openarm See https://github.com/enactic/openarm/blob/main/website/README.md#pull-request-and-preview how to configure preview on fork. |
|
Does this really happen? We ignore openarm/website/src/components/GitHubIssues.tsx Lines 108 to 113 in 5d878b6 |
Yeah, I hit it on a fresh checkout. The require('@site/static/data/popular-issues.json') is resolved at build time, so the missing file becomes a bundler error before the try/catch can return []. Repro: It exits with Cannot find module '@site/static/data/popular-issues.json' |
|
@otegami Could you check this case? |
Problem
On a fresh checkout,
npm run build(andnpm start) fail to compile:src/components/GitHubIssues.tsxloads@site/static/data/popular-issues.jsonviarequire(). The webpack bundle resolves that import at build time, so thetry/catcharound it cannot prevent the failure. The file is produced bynpm run fetch-popular-issues(which needs a GitHub token) and is gitignored (static/data/*), so it does not exist after a clean clone.CI builds succeed only because the workflow runs
fetch-popular-issuesbeforebuild. The local workflow documented inwebsite/README.md(npm start/npm run build) does not mention that step, so a new contributor following the docs hits the error — on the page that renders the Contribute doc, no less.Fix
Add
scripts/ensure-popular-issues.mjs, wired asprestart/prebuild, that writes an empty[]fallback when the file is missing. When the file already exists (CI, or after a manual fetch) it is left untouched, so real data and CI behavior are unchanged.GitHubIssuesalready renders an empty state when there are no issues.Verification
static/data/):npm run buildfailed before, succeeds after.npm run typecheckandnpm run lintpass.Reproduce