-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
Fix for storybook to resolve alias #589
Conversation
@pavish How do I test this PR locally? |
@kgodey Please make sure to restart the ui container before testing. There are new package dependencies, which wont be installed unless the container is restarted or rebuilt. Alternatively, you could also do |
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.
Looks great, thank you!
I think it would be good to add the instructions to run storybook to the main README
file. You can do it in this PR and then merge it. Thanks!
@kgodey The frontend readme file contains information on all aspects of frontend development. Considering storybook is only going to be used for reusable components, I am not sure if we should place it on the main readme. I have placed a link to the frontend readme file in the main readme, in this commit: 880d042 Let me know if this is okay, or if you feel it would be better to also mention it on the main readme, I'll include it. |
@pavish I think linking to the frontend |
Fixes #528
This PR:
Technical details
Configuring storybook to work with aliases was straight forward. All we had to do was specify the aliases in webpackFinal field, and it does the trick.
It lead to the identification of another problem. Storybook was not able to render the components, when optional chaining or nullish coalescing was used.
Turns out webpack4 has this issue, because it uses an older version of acorn. Reference: webpack/webpack#10227
One of the workarounds was to force the resolution of acorn to a later version. When doing this, storybook did not work properly.
The other option was to try a different builder. Webpack5 or vite. I tried both.
When I tried using webpack5, it lead to svelte components not being able to render within storybook. The errors did not provide relevant information to debug this.
I switched to vite, which had even more issues since the support was still experimental. To start with, hmr didn't work, and svelte-addon-csf didn't work well with it.
It look a while to try different workarounds and options which didn't lead to fruition. However, I did come across this issue in the addon-svelte-csf package, when working with webpack5: storybookjs/addon-svelte-csf#23
It gave more clarity on how the package worked, essentially it has 2 separate svelte bundles/runtimes, one for the code itself and one for the stories written in svelte.
The fix for it was as simple as specifying the path to svelte modules, as an alias.
Checklist
Update index.md
).master
branch of the repositoryvisible errors.
Developer Certificate of Origin
Developer Certificate of Origin