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

[Bug]: Storybook server needs an indexer for .stories.json files #20627

Closed
shilman opened this issue Jan 16, 2023 · 5 comments
Closed

[Bug]: Storybook server needs an indexer for .stories.json files #20627

shilman opened this issue Jan 16, 2023 · 5 comments

Comments

@shilman
Copy link
Member

shilman commented Jan 16, 2023

Describe the bug

Storybook adds a new "indexer" system for the sidebar. Because there is no indexer for .stories.json files, Storybook crashes on a new server project.

To Reproduce

2174  mkdir server-test
 2175  cd server-test
 2176  yarn init -y
 2177  npx sb@next init -t server

Results in:

WARN 🚨 Extraction error on stories/button.stories.json: Error: No matching story indexer found for /Users/shilman/projects/testing/server-test/stories/button.stories.json
WARN 🚨 Extraction error on stories/header.stories.json: Error: No matching story indexer found for /Users/shilman/projects/testing/server-test/stories/header.stories.json
WARN 🚨 Extraction error on stories/page.stories.json: Error: No matching story indexer found for /Users/shilman/projects/testing/server-test/stories/page.stories.json
Error: No matching story indexer found for /Users/shilman/projects/testing/server-test/stories/button.stories.json
    at StoryIndexGenerator.extractStories (/Users/shilman/projects/testing/server-test/node_modules/@storybook/core-server/dist/index.js:10:10133)


### System

_No response_

### Additional context

_No response_
@floodfx
Copy link
Contributor

floodfx commented Apr 25, 2023

Hi there. I am running into this issue updating from 6 to 7. We are using storybook for our golang, server-rendered templates and use .stories.json exclusively.

Is there a work around for this?

If not, can you point me in the right direction to implement an indexer for .stories.json files so I can get an idea of what it would take to implement this?

@shilman
Copy link
Member Author

shilman commented Apr 26, 2023

@floodfx Sorry this didn't make the cut. Would be amazing if you could contribute an indexer for .stories.json files! Here's an example:

https://github.com/storybookjs/storybook/blob/next/code/addons/docs/src/preset.ts#L138-L154

The API kind of sucks now and we'd like to redo it in 7.x before making it public, but it's what we've got right now.

The @storybook/server framework would export a storyIndexers function that adds the indexer to the current list of indexers, similar to this example.

The return type of an indexer on a given file is currently a CsfFile object, which is complex, but you can see how it's used here:

https://github.com/storybookjs/storybook/blob/next/code/lib/core-server/src/utils/StoryIndexGenerator.ts#L251-L293

If you give it a try and run into any difficulties, please feel to jump into our Discord https://discord.gg/storybook and we can talk it out in the #contributing channel and hopefully get you unblocked. Hope that helps!

@floodfx
Copy link
Contributor

floodfx commented Apr 27, 2023

@shilman would love feedback on #22296

Thanks

a-h added a commit to a-h/templ that referenced this issue Apr 28, 2023
This was referenced May 8, 2023
@shilman
Copy link
Member Author

shilman commented May 9, 2023

Ooh-la-la!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.1.0-alpha.14 containing PR #22460 that references this issue. Upgrade today to the @future NPM tag to try it out!

npx sb@next upgrade --tag future

@shilman
Copy link
Member Author

shilman commented May 9, 2023

Boo-yah!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.10 containing PR #22460 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb@latest upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants