openarm icon indicating copy to clipboard operation
openarm copied to clipboard

website: fix build failure when popular issues data is absent

Open devin-lai opened this issue 5 months ago • 3 comments

Problem

On a fresh checkout, npm run build (and npm start) fail to compile:

× Cannot find module '@site/static/data/popular-issues.json' for matched aliased key '@site'
[ERROR] Client bundle compiled with errors therefore further build is impossible.

src/components/GitHubIssues.tsx loads @site/static/data/popular-issues.json via require(). The webpack bundle resolves that import at build time, so the try/catch around it cannot prevent the failure. The file is produced by npm 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-issues before build. The local workflow documented in website/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 as prestart/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. GitHubIssues already renders an empty state when there are no issues.

Verification

  • Fresh state (no static/data/): npm run build failed before, succeeds after.
  • With existing data present: the file is not overwritten.
  • npm run typecheck and npm run lint pass.

Reproduce

cd website
npm install
npm run build   # fails on main, succeeds with this change

devin-lai avatar Jun 15 '26 10:06 devin-lai

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.

github-actions[bot] avatar Jun 15 '26 10:06 github-actions[bot]

Does this really happen?

We ignore @site/static/data/popular-issues.json not found error: https://github.com/enactic/openarm/blob/5d878b697c24e944f6c6b89d67050c7d07d00602/website/src/components/GitHubIssues.tsx#L108-L113

kou avatar Jun 15 '26 11:06 kou

Does this really happen?

We ignore @site/static/data/popular-issues.json not found error:

https://github.com/enactic/openarm/blob/5d878b697c24e944f6c6b89d67050c7d07d00602/website/src/components/GitHubIssues.tsx#L108-L113

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: cd website mv static/data/popular-issues.json /tmp/ npx docusaurus build

It exits with Cannot find module '@site/static/data/popular-issues.json' Since static/data/* is gitignored and the file only exists after fetch-popular-issues, an empty [] is enough to unblock the build. No worries if you still can’t repro — feel free to ignore this if it’s too minor

devin-lai avatar Jun 15 '26 12:06 devin-lai

@otegami Could you check this case?

kou avatar Jun 17 '26 02:06 kou

@devin-lai How about #533?

kou avatar Jun 21 '26 01:06 kou

@devin-lai How about #533? #533 looks great to me, thanks

devin-lai avatar Jun 21 '26 07:06 devin-lai

I closed this in favor of #533.

kou avatar Jun 22 '26 00:06 kou