You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current Storybook configuration with Vite requires a modification to address runtime errors encountered when using MDX documentation. Specifically, the @storybook/addon-docs/blocks module must be pre-imported and pre-bundled. This adjustment ensures compatibility with dynamic imports during the MDX documentation rendering process. The required changes are implemented in .storybook/main.ts.
Steps to Reproduce:
Add MDX documentation files to your Storybook setup.
Start the Storybook server.
Observe runtime errors indicating missing pre-bundled dependencies related to @storybook/addon-docs/blocks.
Proposed Solution:
Modify the .storybook/main.ts file to include the pre-bundling of @storybook/addon-docs/blocks. This is achieved by updating the Vite configuration using the optimizeDeps.include setting. The pre-import ensures that the required dependencies are available during MDX processing.
Updated .storybook/main.ts Configuration:
const{ mergeConfig }=awaitimport("vite");returnmergeConfig(config,{plugins: [rawMarkdown],optimizeDeps: {// Pre-bundle @storybook/addon-docs/blocks to avoid runtime errors// Required for MDX documentation compatibilityinclude: ['@storybook/addon-docs/blocks']}});
Acceptance Criteria:
MDX documentation loads in Storybook without runtime errors.
The updated configuration works seamlessly with existing Storybook workflows.
No regressions are introduced in other areas of the build system.
Additional Context:
Impact: This change improves the stability and compatibility of Storybook when handling MDX files by resolving issues related to dynamic imports of @storybook/addon-docs/blocks.
Technical Rationale: Pre-bundling is necessary because Vite's dependency scanning and bundling process requires explicit inclusion of dynamically imported modules. Without this, the required dependencies are not bundled, leading to runtime failures.
The text was updated successfully, but these errors were encountered:
WinkeeFace
changed the title
fix(vite): Update Vite Configuration for Storybook Compatibility
fix(storybook): Resolve MDX Block Loading Issues in Storybook
Jan 20, 2025
Description:
The current Storybook configuration with Vite requires a modification to address runtime errors encountered when using MDX documentation. Specifically, the
@storybook/addon-docs/blocks
module must be pre-imported and pre-bundled. This adjustment ensures compatibility with dynamic imports during the MDX documentation rendering process. The required changes are implemented in.storybook/main.ts
.Steps to Reproduce:
@storybook/addon-docs/blocks
.Proposed Solution:
Modify the
.storybook/main.ts
file to include the pre-bundling of@storybook/addon-docs/blocks
. This is achieved by updating the Vite configuration using theoptimizeDeps.include
setting. The pre-import ensures that the required dependencies are available during MDX processing.Updated
.storybook/main.ts
Configuration:Acceptance Criteria:
Additional Context:
@storybook/addon-docs/blocks
.The text was updated successfully, but these errors were encountered: