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(vite/storybook): resolved runtime error for dynamic imports #2389

Conversation

WinkeeFace
Copy link
Contributor

Description:

The current Vite configuration requires an update to prevent runtime errors when using MDX documentation within Storybook. Specifically, the @storybook/addon-docs/blocks module needs to be pre-bundled for compatibility during dynamic imports. This update adds the necessary adjustments to the optimizeDeps section of the Vite configuration.

Steps to Reproduce:

  1. Attempt to use MDX documentation in Storybook.
  2. Observe runtime errors related to missing pre-bundled dependencies.

Proposed Solution:

Integrate the following changes into the Vite configuration:

const { mergeConfig } = await import("vite");
return mergeConfig(config, {
    plugins: [rawMarkdown],
    optimizeDeps: {
        // Pre-bundle @storybook/addon-docs/blocks to avoid runtime errors
        // This is needed because MDX documentation requires these blocks to be available
        // during dynamic imports
        include: ['@storybook/addon-docs/blocks']
    }
});

Acceptance Criteria:

  • Storybook loads MDX documentation without runtime errors.
  • The Vite configuration changes are compatible with existing workflows.
  • Ensure that these changes do not introduce regressions in other parts of the build system.

Additional Context:

  • This update aligns with the requirement to dynamically import Storybook blocks during MDX rendering.

@WinkeeFace WinkeeFace added this to the 15.0.0 milestone Jan 17, 2025
@WinkeeFace WinkeeFace requested a review from a team January 17, 2025 13:24
Copy link

changeset-bot bot commented Jan 17, 2025

⚠️ No Changeset found

Latest commit: f85e098

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@WinkeeFace WinkeeFace self-assigned this Jan 17, 2025
@agliga agliga force-pushed the 2388-fixvite-update-vite-configuration-for-storybook-compatibility branch from adfe4e3 to f85e098 Compare January 18, 2025 00:38
@agliga agliga merged commit fb8ddec into 15.0.0 Jan 18, 2025
3 checks passed
@agliga agliga deleted the 2388-fixvite-update-vite-configuration-for-storybook-compatibility branch January 18, 2025 00:39
@agliga agliga removed this from the 15.0.0 milestone Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants