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

Source-loader: Support function declaration story exports #9092

Merged
merged 1 commit into from
Dec 7, 2019
Merged

Source-loader: Support function declaration story exports #9092

merged 1 commit into from
Dec 7, 2019

Conversation

pocka
Copy link
Contributor

@pocka pocka commented Dec 7, 2019

Issue: fix #8401

What I did

Added support for export function story() {} style stories in source-loader.

How to test

  • Is this testable with Jest or Chromatic screenshots? ... perhaps
  • Does this need a new example in the kitchen sink apps? ... maybe, but I don't know where to add the example
  • Does this need an update to the documentation? ... no

I added the test fixture in __mocks__/inject-decorator.ts.csf.txt.

@vercel
Copy link

vercel bot commented Dec 7, 2019

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/storybook/monorepo/9as17wdug
🌍 Preview: https://monorepo-git-fork-pocka-fix-function-export-no-source.storybook.now.sh

@pocka pocka changed the title Source-loader: Support function declaration exports Source-loader: Support exporting function declaration Dec 7, 2019
Added support for named exports with function declaration in
source-loader, in order to fix that the story's source code doesn't show
up in Docs mode's code preview.

The changes in generate-helpers.js is necessary because we can't wrap
named export functions:

```
export function foo() {}

// turns into this if we just wrapped it

export wrapper(function foo() {}) // syntax error!
```
@shilman shilman added this to the 5.3.0 milestone Dec 7, 2019
@shilman shilman changed the title Source-loader: Support exporting function declaration Source-loader: Support function declaration story exports Dec 7, 2019
@shilman shilman merged commit 8cca68d into storybookjs:next Dec 7, 2019
@pocka pocka deleted the fix/function-export-no-source branch December 7, 2019 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code preview in addon-docs only works for arrow functions in CSF
2 participants