Skip to content

[Bug]: MDX breaks when importing a CSF from node_modules #27178

Closed as not planned
@stephiescastle

Description

@stephiescastle

Describe the bug

When importing a CSF from a package in node_modules, the MDX documentation fails to render, with error:

<Meta of={} /> must reference a CSF file module export or meta export

The CSF file is captured by the stories glob in main.js, and if I remove the MDX file and set up autodocs, everything works fine.

To Reproduce

I created a reproduction here: https://github.com/stephiescastle/sb-repro-mdx-import-story

Instructions are in the README and also below:

  1. pnpm install
  2. pnpm run --filter @monorepo/storybook storybook

System

Storybook Environment Info:

  System:
    OS: macOS 14.4.1
    CPU: (12) arm64 Apple M2 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.13.1 - ~/.nvm/versions/node/v20.13.1/bin/node
    npm: 10.5.2 - ~/.nvm/versions/node/v20.13.1/bin/npm
    pnpm: 9.1.1 - ~/.nvm/versions/node/v20.13.1/bin/pnpm <----- active
  Browsers:
    Chrome: 124.0.6367.208
    Edge: 124.0.2478.105
    Safari: 17.4.1
  npmPackages:
    @storybook/addon-essentials: ^8.1.1 => 8.1.1 
    @storybook/addon-interactions: ^8.1.1 => 8.1.1 
    @storybook/addon-links: ^8.1.1 => 8.1.1 
    @storybook/blocks: ^8.1.1 => 8.1.1 
    @storybook/html: ^8.1.1 => 8.1.1 
    @storybook/html-vite: ^8.1.1 => 8.1.1 
    @storybook/test: ^8.1.1 => 8.1.1 
    storybook: ^8.1.1 => 8.1.1

Additional context

I am working in a monorepo via pnpm workspaces. The monorepo structure has been set up in the reproduction repository.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions