Skip to content
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

fix(storybook): Resolve MDX Block Loading Issues in Storybook #2388

Closed
3 tasks done
WinkeeFace opened this issue Jan 17, 2025 · 0 comments
Closed
3 tasks done

fix(storybook): Resolve MDX Block Loading Issues in Storybook #2388

WinkeeFace opened this issue Jan 17, 2025 · 0 comments

Comments

@WinkeeFace
Copy link
Contributor

WinkeeFace commented Jan 17, 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:

  1. Add MDX documentation files to your Storybook setup.
  2. Start the Storybook server.
  3. 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 } = await import("vite");

return mergeConfig(config, {
    plugins: [rawMarkdown],
    optimizeDeps: {
        // Pre-bundle @storybook/addon-docs/blocks to avoid runtime errors
        // Required for MDX documentation compatibility
        include: ['@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.
@WinkeeFace WinkeeFace added this to the 15.0.0 milestone Jan 17, 2025
@WinkeeFace WinkeeFace self-assigned this Jan 17, 2025
@WinkeeFace WinkeeFace moved this to In Progress in eBayUI Jan 20, 2025
@WinkeeFace WinkeeFace changed the title fix(vite): Update Vite Configuration for Storybook Compatibility fix(storybook): Resolve MDX Block Loading Issues in Storybook Jan 20, 2025
@agliga agliga moved this from In Progress to Done in eBayUI Jan 21, 2025
@agliga agliga closed this as completed Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants