-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Addon-docs: Source loader library #7117
Conversation
This pull request is automatically deployed with Now. Latest deployment for this branch: https://monorepo-git-7101-source-loader.storybook.now.sh |
@shilman , I don't get why not to reference it in the storysource ? since it looks like a copy paste, hard to understand what exactly changed =) But It looks similar to what I remember it was =) |
@igor-dv you guessed it, storysource will just require it. |
👍 |
@libetl With the latest commit I've updated all the monorepo examples to use source-loader instead of storysource's loader. However, storysource appears to be broken in all of those examples. I'm wondering if you might be able to debug this when you have time. I'll debug the SB Docs side separately, if needed, after this PR is merged. Merci beaucoup! 🙇 Additionally there are a lot of other errors, e.g. for loading MDX. I'm not sure the best way to deal with these. |
p => p.key.name === 'parameters' && p.value.type === 'ObjectExpression' | ||
); | ||
|
||
splicedSource = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@libetl I think the error is here when there are no parameters attached to the default export
@libetl I think there's a bug when using the module format when there are no parameters on the default export. I tested this in the |
fixed. But there seems to be something wrong after the load. all the stories are displaying errors. Can you help me Michael ? |
@libetl Your fix worked but there is still a problem with some of the stories. In
When the source loader modifies the stories, the generated code assumes that the story functions are being called with context, and these are not. Proposed solution:
|
Ok, tell me if I can help in any way |
@@ -77,6 +78,7 @@ module.exports = { | |||
'./lib/core/src/server', | |||
'./lib/node-logger', | |||
'./lib/codemod', | |||
'./lib/source-loader/src', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This directory includes client-side files like preview.js
, we shouldn't apply node target to them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll extract the server part there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,6 @@ | |||
import { transform } from './build'; | |||
|
|||
export { STORY_EVENT_ID } from './events'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shilman is that export used anywhere? I'm going to remove it from index
Issue: #7101
What I did
This is the source loader library by @libetl that replaces
addon-storysource
's loader and extends it in various ways:In addition, it can also embed the story source as a story parameter (which is probably how it should be implemented).
I'll leave the refactor of
addon-storysource
to @libetl for another PR. It might even be worth updating storysource to use the parameter and removing the complicated decorator/event.This will be integrated into docs in a subsequent PR where the
Source
doc block consumes the aforementioned story parameter.How to test