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

Storysource: Use story parameters injected by source-loader #7192

Closed
shilman opened this issue Jun 25, 2019 · 2 comments
Closed

Storysource: Use story parameters injected by source-loader #7192

shilman opened this issue Jun 25, 2019 · 2 comments
Assignees
Labels
addon: storysource maintenance User-facing maintenance tasks
Milestone

Comments

@shilman
Copy link
Member

shilman commented Jun 25, 2019

PR #7117 introduced @libetl's @storybook/source-loader, a reusable package for annotating stories with their source code. In addition to emitting an event (old behavior) every time a story is rendered, it also injects story source as story parameters.

The Storysource addon should be refactored to use the story parameters instead of the channel event. There are a few reasons:

  1. There are race conditions on the channel, and parameters don't have this problem.
  2. Story parameters are simpler, and we are standardizing on those for communicating between the preview & manager in many cases.
  3. The event emitter code breaks when you use stories like the one below, because the modified code assumes that stories are called with a context argument, which is not the case in the following example:
import React from 'react';
import { DocsPage, DocsWrapper, DocsContent } from './DocsPage';
import * as storyStories from './Story.stories';
import * as previewStories from './Preview.stories';
import * as propsTableStories from './PropsTable/PropsTable.stories';
import * as sourceStories from './Source.stories';
import * as descriptionStories from './Description.stories';

export const empty = () => (
  <DocsPage title={null}>
    {storyStories.error()}
    {propsTableStories.error()}
    {sourceStories.sourceUnavailable()}
  </DocsPage>
);

On top of all that #7117 introduced a bug where the Storysource addon no longer renders the story source once source-loader has been activated. Please fix this problem, either in source-loader or storysource (I haven't debugged the issue)

@shilman shilman added maintenance User-facing maintenance tasks addon: storysource labels Jun 25, 2019
@shilman shilman added this to the 5.2.0 milestone Jun 25, 2019
@shilman
Copy link
Member Author

shilman commented Jun 26, 2019

It turns out that there is more source-loader follow up work. Filing a separate issue that should be addressed before this one: #7204

@shilman
Copy link
Member Author

shilman commented Jul 8, 2019

Egads!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-alpha.38 containing PR #7272 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: storysource maintenance User-facing maintenance tasks
Projects
None yet
Development

No branches or pull requests

2 participants