storybookjs/storybook

[Bug]: `preview` `decorators` ignored if `preview` uses top-level await

Open

#22,205 创建于 2023年4月21日

在 GitHub 查看
 (0 评论) (9 反应) (0 负责人)TypeScript (89,909 star) (10,058 fork)batch import
corefeature requesthelp wanted

描述

Describe the bug

If the preview file (or more likely a file it depends on directly or transitively) uses top-level await, then the decorators it exports (whether directly or as part of a export default preview) are not run. This need not necessarily be considered a bug, because setting experiments.topLevelAwait is likely not technically a supported use case by Storybook, but wanted to make y'all aware of it already because probably at some point it will be supported (and aside from this bug already seems to work quite well).

To Reproduce

  • Check out https://github.com/jeysal/sbrepro
  • yarn install && yarn storybook
  • Open the button story
  • Observe that there is no red background (which the decorator should create)

To further confirm:

  • Comment out the first line (top-level await) in preview.js
  • Observe that the red background appears

System

Environment Info:

  System:
    OS: Linux 6.2 Arch Linux
    CPU: (16) x64 AMD Ryzen 9 5900HS with Radeon Graphics
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
  Browsers:
    Firefox: 112.0
  npmPackages:
    @storybook/addon-essentials: ^7.0.6 => 7.0.6 
    @storybook/addon-interactions: ^7.0.6 => 7.0.6 
    @storybook/addon-links: ^7.0.6 => 7.0.6 
    @storybook/blocks: ^7.0.6 => 7.0.6 
    @storybook/react: ^7.0.6 => 7.0.6 
    @storybook/react-webpack5: ^7.0.6 => 7.0.6 
    @storybook/testing-library: ^0.0.14-next.2 => 0.0.14-next.2 


### Additional context

_No response_

贡献者指南