storybookjs/storybook

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

開放

#22,205 建立於 2023年4月21日

 (0 則留言) (9 個反應) (0 位負責人)TypeScript (10,058 個分叉)batch import
corefeature requesthelp wanted

倉庫指標

星標
 (89,909 顆星)
PR 合併指標
 (平均合併 7天 22小時) (30 天內合併 184 個 PR)

描述

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_

貢獻者指南