storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
83.77k stars 9.18k forks source link

[Bug]: re-exported Story from different file disabling "Show code / Hide code" button #23187

Open Demiurg77 opened 1 year ago

Demiurg77 commented 1 year ago

Describe the bug

In Storybook 7 while re-exporting stories via:

export { Basic } from "./avatar.basic.story";

I can see a story, but I can't preview the source ("Show code / Hide code" button is disabled)

BTW - using old way with asterisk (Storybook 5, 6) in Storybook 7 doesn't show the story, neither the source code:

export * from "./avatar.basic.story";

Some stories are quite large and I need to keep them in separate tsx files.

To Reproduce

Storybook preview: https://64978ad79679888cd8f5f436-fzgpjawimm.chromatic.com/?path=/docs/example-button--docs

Repository: https://github.com/Demiurg77/my-storybook-reproduction/tree/main/src/stories

Reproduction build details: https://www.chromatic.com/build?appId=64978ad79679888cd8f5f436&number=2

System

Environment Info:

  System:
    OS: macOS 13.4
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 18.12.1 - ~/.nodenv/versions/18.12.1/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.2 - ~/.nodenv/versions/18.12.1/bin/npm
  Browsers:
    Chrome: 114.0.5735.133
    Edge: 110.0.1587.57
    Firefox: 114.0.2
    Safari: 16.5
  npmPackages:
    @storybook/addon-essentials: ^7.0.20 => 7.0.20 
    @storybook/addon-interactions: ^7.0.20 => 7.0.20 
    @storybook/addon-links: ^7.0.20 => 7.0.20 
    @storybook/addon-storysource: ^7.0.21 => 7.0.21 
    @storybook/blocks: ^7.0.20 => 7.0.20 
    @storybook/react: ^7.0.20 => 7.0.20 
    @storybook/react-webpack5: ^7.0.20 => 7.0.20 
    @storybook/testing-library: ^0.0.14-next.2 => 0.0.14-next.2

Additional context

No response

shilman commented 1 year ago

I'm a little surprised about this -- I would expect it to work. Do you a have a reproduction repo you can share? If not, can you create one? Go to https://storybook.new or see repro docs. I'd be happy to take a look.

Demiurg77 commented 1 year ago

@shilman I added reproduction repo and storybook preview to "To Reproduce" section

shilman commented 1 year ago

Thanks so much! I'll take a look

Demiurg77 commented 1 year ago

Hi @shilman. Any updates on this? Code preview is the only feature that stops us from migrating to v7. Also could you remove "needs reproduction" tag from this thread?

BTW, one more aspect regarding source preview, connected with this issue: https://github.com/storybookjs/storybook/discussions/23135

shilman commented 1 year ago

@Demiurg77 I was out last week but will try to get to the bottom of it this week. Thanks for your patience!

shilman commented 1 year ago

@Demiurg77 Side note -- I don't understand why this is blocking you from upgrading to v7, given that according to you this doesn't work in v5/v6 either.

Demiurg77 commented 1 year ago

@Demiurg77 Side note -- I don't understand why this is blocking you from upgrading to v7, given that according to you this doesn't work in v5/v6 either.

@shilman I guess I didn't make myself clear, but both methods work fine in previous versions. The problem is only with Storybook 7.

In storybook 6.5 I can successfully use export * from "./avatar.basic.story" or export { Basic } from "./avatar.basic.story", and source preview works as expected

shilman commented 1 year ago

@Demiurg77 Gotcha, thanks for clarifying!