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

Function exports not detected as stories with storyStoreV7 enabled #16828

Closed
eirslett opened this issue Nov 29, 2021 · 1 comment
Closed

Function exports not detected as stories with storyStoreV7 enabled #16828

eirslett opened this issue Nov 29, 2021 · 1 comment

Comments

@eirslett
Copy link
Contributor

Describe the bug

A story file like this...

export default {
  title: "Example Stories"
}

export const A = () => <div>A</div>;
export function B() { return <div>B</div>; }

...will only show story A in the Storybook menu. The reason is that the CSF file parsing/story detection doesn't detect Story B.

To Reproduce

It's possible to reproduce this as a failing unit test, in CsfFile.test.ts:

    it('function exports', () => {
      expect(
        parse(
          dedent`
          export default { title: 'foo/bar' };
          export function A() {}
          export function B() {}
      `
        )
      ).toMatchInlineSnapshot(`
        meta:
          title: foo/bar
          id: custom-id
        stories:
          - id: foo-bar--a
            name: A
          - id: foo-bar--b
            name: B
      `);
    });

I tried diving into the code to fix it myself, but CsfFile.ts is quite complex to work with, and I wouldn't want to ruin anything else while working in there!

This is unfortunately a blocker at our company, before we can start using story store V7. All the stories are written as export function. Would it be possible to have a bugfix thas is backported on the 6.4 release?

@shilman
Copy link
Member

shilman commented Nov 30, 2021

Jeepers creepers!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.1 containing PR #16829 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants