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

[Bug]: vue-docgen-plugin cannot parse functional component #22090

Closed
Kaciras opened this issue Apr 14, 2023 · 4 comments · Fixed by #22285
Closed

[Bug]: vue-docgen-plugin cannot parse functional component #22090

Kaciras opened this issue Apr 14, 2023 · 4 comments · Fixed by #22285
Assignees

Comments

@Kaciras
Copy link

Kaciras commented Apr 14, 2023

Describe the bug

I get an error when add a story for my functional component. The component written in Vue SFC and export a render function.

No suitable component definition found on "D:/Coding/JavaScript/vue3-vite/default-js/src/stories/Button.vue"
18:23:08 [vite] Internal server error: No suitable component definition found on "D:/Coding/JavaScript/vue3-vite/default-js/src/stories/Button.vue"
  Plugin: storybook:vue-docgen-plugin
  File: D:/Coding/JavaScript/vue3-vite/default-js/src/stories/Button.vue
      at <anonymous> (d:\Coding\JavaScript\vue3-vite\default-js\node_modules\.pnpm\vue-docgen-api@4.64.1_vue@3.2.47\node_modules\vue-docgen-api\dist\parse-script.js:67:23)
      at Generator.next (<anonymous>)
      at fulfilled (d:\Coding\JavaScript\vue3-vite\default-js\node_modules\.pnpm\vue-docgen-api@4.64.1_vue@3.2.47\node_modules\vue-docgen-api\dist\parse-script.js:28:58)
<!-- Button.vue -->
<script>
import { h } from "vue";

export default function Button() {
    return h("button");
}
</script>

<style>/* ... */</style>
// Button.stories.js
import Button from './Button.vue';

export default { component: Button };

export const Primary = {};

To Reproduce

https://github.com/Kaciras/sb-issue

System

System:
    OS: Windows 10 10.0.22621
    CPU: (12) x64 AMD Ryzen 5 5625U with Radeon Graphics
  Binaries:
    Node: 19.7.0 - D:\Program Files\NodeJS\node.EXE
    npm: 9.5.0 - D:\Program Files\NodeJS\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.1555.0), Chromium (109.0.1518.78)
  npmPackages:
    @storybook/addon-essentials: ^7.0.4 => 7.0.4
    @storybook/addon-interactions: ^7.0.4 => 7.0.4
    @storybook/addon-links: ^7.0.4 => 7.0.4
    @storybook/blocks: ^7.0.4 => 7.0.4
    @storybook/testing-library: ^0.0.14-next.2 => 0.0.14-next.2
    @storybook/vue3: ^7.0.4 => 7.0.4
    @storybook/vue3-vite: ^7.0.4 => 7.0.4

Additional context

No response

@sneko
Copy link

sneko commented Jun 8, 2023

Hi @Kaciras , I have some stories generated from a documentation and I get this error. Did you find how to disable vue-docgen-plugin?

I disabled the "docs" feature of Storybook on my stories but I'm still getting this.

Thank you,

@Kaciras
Copy link
Author

Kaciras commented Jun 8, 2023

@sneko no, I'm still on the old version. In Storybook v6 it just shows a warning, and in v7 the page fails to load with this error.

@pokkur
Copy link

pokkur commented Aug 4, 2023

@sneko

Try this.

.storybook/main.ts

viteFinal(config) {
   ...
      const vueDocgenIndex = config.plugins.findIndex(({ name }) => name === 'storybook:vue-docgen-plugin')
      if (vueDocgenIndex !== -1) config.plugins.splice(vueDocgenIndex, 1)
    }

@ericvel
Copy link

ericvel commented Nov 17, 2023

@pokkur Do you know if it's possible to disable vue-docgen-plugin for one specific .stories file? I'd like to keep the automatically generated docs for all my other components where this bug doesn't occur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants