-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Docs: Support Rolldown bundler module namespace objects #33280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Support Rolldown bundler module namespace objects #33280
Conversation
When using vite-rolldown, bundled code creates different object references for the same module imported from multiple files. This caused Map.get() lookups to fail since Maps use object identity. - Add fallback lookup by .default property in resolveModuleExport() - Handles bundlers that don't preserve ES module namespace identity - Add tests for Rolldown compatibility scenarios Fixes storybookjs#31879
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an issue where the Rolldown bundler creates different object references for the same module imported from multiple files, causing Map.get() lookups to fail. The solution adds a fallback lookup mechanism that checks the .default property when direct lookup fails, maintaining compatibility with bundlers that don't preserve ES module namespace object identity.
Key changes:
- Add fallback lookup in
resolveModuleExport()method to check.defaultproperty when direct Map lookup fails - Add comprehensive unit tests for Rolldown compatibility scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.ts | Implements fallback lookup logic in resolveModuleExport() to handle bundlers like Rolldown that create different namespace object references |
| code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.test.ts | Adds unit tests for Rolldown compatibility in both referenceMeta and resolveOf test suites, plus a test for error handling with non-module objects |
code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.test.ts
Outdated
Show resolved
Hide resolved
- Align expected error message in referenceMeta test with the more helpful message in DocsContext that suggests the user may have mistakenly referenced their component instead of their CSF file
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughAdds a fallback resolution mechanism in DocsContext to handle bundlers like Rolldown that don't preserve module namespace identity. When direct lookup fails and the object contains a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
✨ Finishing touches
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (8)**/*.{test,spec}.{ts,tsx}📄 CodeRabbit inference engine (.cursorrules)
Files:
**/*.test.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.cursor/rules/spy-mocking.mdc)
Files:
**/*.{js,jsx,json,html,ts,tsx,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
code/**/*.{ts,tsx,js,jsx,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
code/**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
code/**/*.{test,spec}.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
code/**/*.{js,jsx,json,html,ts,tsx,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🧠 Learnings (3)📚 Learning: 2025-11-24T17:49:59.279ZApplied to files:
📚 Learning: 2025-11-24T17:49:59.279ZApplied to files:
📚 Learning: 2025-11-28T14:50:24.889ZApplied to files:
🧬 Code graph analysis (1)code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.test.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (3)
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 |
Docs: Support Rolldown bundler module namespace objects (cherry picked from commit e0d0d04)
What I did
When using vite-rolldown, bundled code creates different object references for the same module imported from multiple files. This caused Map.get() lookups to fail since Maps use object identity.
Closes #31879
The changes in this PR are covered in the following automated tests:
Manual testing
Cloned the repro repo posted in the GitHub issue: https://github.com/beaussan/repro-storybook-rolldown-story-of
Documentation
MIGRATION.MD
Checklist for Maintainers
storybook-10.2.0-alpha.3.tgz
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.