Skip to content

fix(contributors): defer .all-contributorsrc read to fix Storybook bundle#18106

Merged
pettinarip merged 1 commit into
stagingfrom
fix/contributors-defer-fs-read
May 1, 2026
Merged

fix(contributors): defer .all-contributorsrc read to fix Storybook bundle#18106
pettinarip merged 1 commit into
stagingfrom
fix/contributors-defer-fs-read

Conversation

@pettinarip
Copy link
Copy Markdown
Member

@pettinarip pettinarip commented May 1, 2026

Summary

Fixes the Chromatic failure on the v11.6.0 release PR (#18104):

Error: page.evaluate: TypeError: (0 , fs_ignored_.readFileSync) is not a function
    at ./src/components/MdComponents/index.tsx
    at ./src/components/MdComponents/MdComponents.stories.tsx

Root cause

src/components/Contributors/index.tsx (added in #18073) called readFileSync(".all-contributorsrc") at module top level. MdComponents/index.tsx barrels in Contributors, and the MdComponents.stories.tsx story imports that barrel — so Storybook's webpack pulls Contributors into the browser bundle.

Storybook stubs fs (fs_ignored_), so evaluating the module hit the stub and crashed. The import "server-only" directive only enforces against the Next.js client bundler, not Storybook.

Fix

Wrap the read in a memoized getter (getShuffledContributors()). Importing the module is now side-effect free; the read still happens once per SSG worker, on first render of <Contributors />.

Test plan

  • Local pnpm build-storybook succeeds
  • Built bundle no longer evaluates readFileSync at top level (call is now inside the function: ()=>{if(!shuffledContributors){const raw=(0,fs_ignored_.readFileSync)(...))
  • npx tsc --noEmit passes
  • Chromatic check on this PR goes green
  • After merge into staging, Chromatic on the release PR (Deploy v11.6.0 #18104) goes green

The module-level `readFileSync` call ran at import time, which broke
Storybook (Chromatic) since `MdComponents` re-exports `Contributors`.
Webpack stubs `fs` in the browser, so importing the module crashed with
`(0 , fs_ignored_.readFileSync) is not a function` and Chromatic could
not extract stories.

Wrap the read in a memoized getter so importing the module is
side-effect free; the read still happens once per SSG worker on first
render.
@netlify
Copy link
Copy Markdown

netlify Bot commented May 1, 2026

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 64a2758
🔍 Latest deploy log https://app.netlify.com/projects/ethereumorg/deploys/69f48ac615aa080008e40608
😎 Deploy Preview https://deploy-preview-18106.ethereum.it
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 69 (🟢 up 15 from production)
Accessibility: 96 (🟢 up 3 from production)
Best Practices: 100 (no change from production)
SEO: 98 (🔴 down 1 from production)
PWA: 59 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@pettinarip pettinarip merged commit 075de6d into staging May 1, 2026
11 of 14 checks passed
@pettinarip pettinarip deleted the fix/contributors-defer-fs-read branch May 1, 2026 11:26
@pettinarip pettinarip mentioned this pull request May 8, 2026
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.

1 participant