-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Naming variable before export default
breaks code display
#11702
Comments
I think I have a similar issue #11738 - I'm speculating that the code preview isn't actually running the module in the JS sense, but doing some other parsing to get the info it needs |
That's right @rikkit. We need the default export to be statically analyzable, so |
👋 Hello there! I've written a blog post that references this issue as an explanation for an adjacent and closely related issue, which is that automatic story source only works with inline, named exports for CSF stories. You can read the applicable excerpt here: Statically analyzable 🤔 GitHub discussion: #18915 ✌️ |
Describe the bug
If you name the top-level story configuration in a stories file -- aka, what is usually done as
export default { ... }
but instead you doconst config = { ... } ; export default config;
no code will be available for display in thedocs
view. It will show "No code available".To Reproduce
Reproduction: https://github.com/aleph-naught2tog/addon-docs-code-issue
Expected behavior
I expect to be able to assign what I am about to export to a variable
thatVariable
, thenexport default thatVariable
and have the code still appear in the "Show Code" portion.Screenshots
n/a
Code snippets
Here is a reproduction issue: https://github.com/aleph-naught2tog/addon-docs-code-issue
This code works and the
Preview
in the MDX page shows the code source just fine.In contrast, this means that the
Preview
in the MDX file cannot show the code (instead says "No Code Available").System:
Environment Info:
System:
OS: macOS 10.15.5
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Binaries:
Node: 12.4.0 - ~/.nvm/versions/node/v12.4.0/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v12.4.0/bin/npm
Browsers:
Chrome: 84.0.4147.89
Safari: 13.1.1
npmPackages:
@storybook/addon-actions: ^5.3.19 => 5.3.19
@storybook/addon-docs: ^5.3.19 => 5.3.19
@storybook/addon-links: ^5.3.19 => 5.3.19
@storybook/addons: ^5.3.19 => 5.3.19
@storybook/preset-create-react-app: ^3.1.4 => 3.1.4
@storybook/react: ^5.3.19 => 5.3.19
Additional context
I verified that this is still an issue on
v6.0.0-rc.15
. I first noticed this issue in my current work code, but it's fully reproducible in the small repo above.The text was updated successfully, but these errors were encountered: