reactjsmdxstorybook

Storybook 7 throws typeerror for file named 'name.stories.mdx' but if I rename it to 'name.stories.anything.mdx' it works with the exact same content


I have upgraded our storybook 6.x project to storybook 7.5.1, fixed versions on everything. Our DS uses react-vite.

I have made sure to test with solely 1 single MDX file if I can start up storybook but ran into this issue:

It will throw:

Unable to index ./src/name.stories.mdx:
WARN   TypeError: indexer.createIndex is not a function

for every single .MDX file in our project. The weird thing is, if I update the pathmatcher to only look for name.stories.anything.mdx it will render the story perfectl with the exact same content.

I can't find any rhyme or reason to this issue or any references to it, googling by using this type error and 'storybook' yields 4-5 unrelated results, absolutely obscure.

Anyone have any ideas of why this might be happening at all? any suggestions of what to try?

full main.ts file:

import type { StorybookConfig } from '@storybook/react-vite'
import { mergeConfig } from 'vite'

const config: StorybookConfig = {
  stories: [
    '../src/name.stories.@(mdx)',
  ],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials',
    '@storybook/addon-interactions',
    '@storybook/addon-onboarding',
  ],
  framework: '@storybook/react-vite',
  docs: {
    autodocs: 'tag',
  },
  viteFinal: async (config) =>
    mergeConfig(config, {
      base: './', // Set the base path for Storybook builds to ensure assets are loaded correctly
    }),
}

export default config


Solution

  • Had same issue and noticed that all my storybook dependencies didn't have the same version. Have you tried making sure that all have same version even patch ? Confirmed it works in 7.5.3