tobiasdiez / storybook-vue-addon

Storybook stories in native Vue format
MIT License
46 stars 1 forks source link

[Bug] adding `<docs lang="md"></docs>` fails without `@mdx-js/react` dependency explicitly installed #66

Open floroz opened 1 year ago

floroz commented 1 year ago

When creating a new Story, and adding a <docs /> blog, an error is thrown:

11:35:16 AM [vite] Internal server error: Failed to resolve import "@mdx-js/react" from "src/components/b-button/b-button.stories.vue?vue&type=stories". Does the file exist?
  Plugin: vite:import-analysis
  File: /Users/floroz/Repository/brink/packages/brink-ui/src/components/b-button/b-button.stories.vue?vue&type=stories:25:57
  23 |  };
  24 |  
  25 |  import { useMDXComponents as _provideComponents } from "@mdx-js/react";
     |                                                          ^
  26 |  import { jsx as _jsx } from "react/jsx-runtime";
  27 |  import {
      at formatError (file:///Users/floroz/Repository/brink/node_modules/.pnpm/vite@4.4.8_@types+node@18.17.0_sass@1.64.2/node_modules/vite/dist/node/chunks/dep-75f53616.js:43944:46)
      at TransformContext.error (file:///Users/floroz/Repository/brink/node_modules/.pnpm/vite@4.4.8_@types+node@18.17.0_sass@1.64.2/node_modules/vite/dist/node/chunks/dep-75f53616.js:43940:19)
      at normalizeUrl (file:///Users/floroz/Repository/brink/node_modules/.pnpm/vite@4.4.8_@types+node@18.17.0_sass@1.64.2/node_modules/vite/dist/node/chunks/dep-75f53616.js:41754:33)
      at async file:///Users/floroz/Repository/brink/node_modules/.pnpm/vite@4.4.8_@types+node@18.17.0_sass@1.64.2/node_modules/vite/dist/node/chunks/dep-75f53616.js:41898:47
      at async Promise.all (index 2)
      at async TransformContext.transform (file:///Users/floroz/Repository/brink/node_modules/.pnpm/vite@4.4.8_@types+node@18.17.0_sass@1.64.2/node_modules/vite/dist/node/chunks/dep-75f53616.js:41823:13)
      at async Object.transform (file:///Users/floroz/Repository/brink/node_modules/.pnpm/vite@4.4.8_@types+node@18.17.0_sass@1.64.2/node_modules/vite/dist/node/chunks/dep-75f53616.js:44234:30)
      at async loadAndTransform (file:///Users/floroz/Repository/brink/node_modules/.pnpm/vite@4.4.8_@types+node@18.17.0_sass@1.64.2/node_modules/vite/dist/node/chunks/dep-75f53616.js:54901:29)
      at async viteTransformMiddleware (file:///Users/floroz/Repository/brink/node_modules/.pnpm/vite@4.4.8_@types+node@18.17.0_sass@1.64.2/node_modules/vite/dist/node/chunks/dep-75f53616.js:64296:32)

Explicitly installing @mdx-js/react solves the issue.

System info:

  System:
    OS: macOS 13.1
  Binaries:
    Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
  Browsers:
    Chrome: 115.0.5790.170
    Firefox: 112.0.1
    Safari: 16.2
  npmPackages:
    @storybook/addon-a11y: 7.1.0 => 7.1.0 
    @storybook/addon-docs: 7.1.0 => 7.1.0 
    @storybook/addon-essentials: 7.1.0 => 7.1.0 
    @storybook/addon-interactions: 7.1.0 => 7.1.0 
    @storybook/addon-links: 7.1.0 => 7.1.0 
    @storybook/addon-mdx-gfm: 7.1.0 => 7.1.0 
    @storybook/addons: 7.1.0 => 7.1.0 
    @storybook/api: 7.1.0 => 7.1.0 
    @storybook/blocks: 7.1.0 => 7.1.0 
    @storybook/components: 7.1.0 => 7.1.0 
    @storybook/core-events: 7.1.0 => 7.1.0 
    @storybook/manager-api: 7.1.0 => 7.1.0 
    @storybook/preview-api: 7.1.0 => 7.1.0 
    @storybook/testing-library: 0.2.0 => 0.2.0 
    @storybook/theming: 7.1.0 => 7.1.0 
    @storybook/vue3: 7.1.0 => 7.1.0 
    @storybook/vue3-vite: 7.1.0 => 7.1.0 
   storybook-vue-addon: 0.4.0
tobiasdiez commented 1 year ago

This is strange, for me its pulled-in by the docs addon: https://github.com/tobiasdiez/storybook-vue-addon/blob/02839f9b53c304ec562f34df20d9bf7bc6aa4897/pnpm-lock.yaml#L2140

Maybe related to https://github.com/storybookjs/storybook/issues/19821?

floroz commented 1 year ago

This is strange, for me its pulled-in by the docs addon:

https://github.com/tobiasdiez/storybook-vue-addon/blob/02839f9b53c304ec562f34df20d9bf7bc6aa4897/pnpm-lock.yaml#L2140

Maybe related to storybookjs/storybook#19821?

I need to check if I can reproduce it on a new vite project using pnpm as package manager and in a new pnpm workspaces / vite project.