Docs: Fix MDX docs HMR when referenced CSF changes#34868
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughMdxDocsRender.isEqual now accounts for CSF file referential changes when comparing render instances. The implementation checks that referenced CSF files match in length and by reference, and a new test validates that renders backed by different CSF files correctly report inequality. ChangesCSF File Equality Checking
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes an HMR edge case for MDX docs pages that import CSF stories: when the referenced CSF module changes (via HMR) but the MDX module’s exports stay referentially equal, Storybook should still treat the docs render as changed and re-render.
Changes:
- Extend
MdxDocsRender.isEqual()to also compare referenced CSF files (not just MDX exports). - Add a unit test ensuring a referenced CSF change makes two docs renders unequal.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
code/core/src/preview-api/modules/preview-web/render/MdxDocsRender.ts |
Updates docs-render equality to include referenced CSF files so CSF HMR triggers a docs rerender. |
code/core/src/preview-api/modules/preview-web/render/MdxDocsRender.test.ts |
Adds a regression test covering “same MDX exports, different referenced CSF file” equality behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 184 | 184 | 0 |
| Self size | 79 KB | 79 KB | 🎉 -48 B 🎉 |
| Dependency size | 33.24 MB | 33.34 MB | 🚨 +94 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/ember
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 188 | 188 | 0 |
| Self size | 15 KB | 15 KB | 🚨 +18 B 🚨 |
| Dependency size | 29.96 MB | 30.06 MB | 🚨 +94 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 534 | 534 | 0 |
| Self size | 662 KB | 662 KB | 0 B |
| Dependency size | 61.37 MB | 61.46 MB | 🚨 +94 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 271 | 271 | 0 |
| Self size | 23 KB | 23 KB | 🚨 +12 B 🚨 |
| Dependency size | 45.91 MB | 46.00 MB | 🚨 +94 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/server-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 196 | 196 | 0 |
| Self size | 16 KB | 16 KB | 0 B |
| Dependency size | 34.51 MB | 34.60 MB | 🚨 +94 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/preset-react-webpack
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 164 | 164 | 0 |
| Self size | 18 KB | 18 KB | 0 B |
| Dependency size | 32.25 MB | 32.34 MB | 🚨 +94 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
|
Hi @tatakaisun, Due to a recent high volume of unreviewed AI-generated PRs, we are requesting verification and proof that the implemented fix actually works. Please provide a simple GIF/Video or image of how the fix works, optimally with before-and-after comparisons. Thank you for your understanding! |
|
This PR only updates documentation/comments and does not change runtime behavior. The changes clarify replay semantics in:
Verification performed:
No implementation logic or durable execution behavior was changed. |
Summary
Fix MDX docs render equality so referenced CSF file changes trigger a docs rerender.
Why
When an MDX docs page imports stories, the MDX module can remain unchanged while the referenced CSF module changes via HMR. The previous equality check only compared the MDX exports, so the docs render could be treated as unchanged.
Changes
MdxDocsRender.isEqual().Testing
git diff --checkKnown Issues
Summary by CodeRabbit