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

Refactor: Split out docs-loader from source-loader #12561

Closed
4 tasks
shilman opened this issue Sep 24, 2020 · 5 comments
Closed
4 tasks

Refactor: Split out docs-loader from source-loader #12561

shilman opened this issue Sep 24, 2020 · 5 comments
Labels
addon: docs maintenance User-facing maintenance tasks source-loader

Comments

@shilman
Copy link
Member

shilman commented Sep 24, 2020

Currently, source-loader is used by both addon-storysource and addon-docs. It supports both storiesOf and CSF stories.

Until 6.0 the source-loader and CSF cases were quite similar. Late in the release, these use cases diverged a bit for performance's sake (see . Now, the default addon-docs configuration (not required, but recommended) and the required addon-storysource configuration don't match.

There are a number of related issues resulting from this mess, including (but not limited to): #12208 #8055 #12065 #12557

To address this, I propose:

  • Splitting out a separate docs-loader that ONLY supports CSF.
  • Deprecating source-loader.
  • Making a non-deprecated copy of source-loader that lives inside addon-storysource.

A cleanroom docs-loader would be substantially simpler because it doesn't need to deal with all the storiesOf complexity. From there we could easily add stuff like:

@shilman
Copy link
Member Author

shilman commented Sep 24, 2020

More context on the problem: https://github.com/storybookjs/storybook/blob/next/addons/storysource/README.md#displaying-full-source

In a nutshell:

  • Storysource uses the full source of the file and a collection of offsets into that source to show highlights
  • Docs is able to use the same data as Storysource, but loads much more quickly if the source has already been pre-extracted as small snippets that are annotated onto the stories individually.

We shipped the optimized version as the default in 6.0 because we were pressed for time and we were doing everything we could to make performance acceptable before the release.

@yuri-scarbaci-lenio
Copy link
Contributor

Just to add my 2 cents,

Would be nice if we could get a couple of options with the source-code when configuring the parameters globally (let's say in preview.js)

Maybe adding the possibility for parameters.storySource.source to either be a string or a function that receives the finalFormattedSource, rawSource as parameters so going forward people can configure their own source code easly and/or add their own preamble/post-comments/formatting

if rawSource going forward would ALWAYS be the result of ONLY reading the content of the story as a string this could help heavy-customization-user to get a more stable implementation and worry a lot less about breaking changes of configurations when updating/upgrading the versions.

In our specific case that would be more than welcome and more than enough (and to be honest would also be our prefeered way to handle it)

@stale
Copy link

stale bot commented Dec 25, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Dec 25, 2020
@yuri-scarbaci-lenio
Copy link
Contributor

Stale bot just doesn't like this issue and related issues uh? :)

@shilman
Copy link
Member Author

shilman commented Feb 4, 2023

Fixed in 7.0 and released as @storybook/csf-plugin

@shilman shilman closed this as completed Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: docs maintenance User-facing maintenance tasks source-loader
Projects
None yet
Development

No branches or pull requests

2 participants