Skip to content

website: fix build failure when popular issues data is absent#525

Open
devin-lai wants to merge 1 commit into
enactic:mainfrom
devin-lai:fix-build-without-popular-issues
Open

website: fix build failure when popular issues data is absent#525
devin-lai wants to merge 1 commit into
enactic:mainfrom
devin-lai:fix-build-without-popular-issues

Conversation

@devin-lai

Copy link
Copy Markdown

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

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.
@github-actions

Copy link
Copy Markdown

@kou

kou commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Does this really happen?

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

try {
return require('@site/static/data/popular-issues.json');
} catch (_) {
// If you need popular issues, please run: npm run fetch-popular-issues
return [];
}

@devin-lai

Copy link
Copy Markdown
Author

Does this really happen?

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

try {
return require('@site/static/data/popular-issues.json');
} catch (_) {
// If you need popular issues, please run: npm run fetch-popular-issues
return [];
}

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

@kou

kou commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

@otegami Could you check this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants