-
Notifications
You must be signed in to change notification settings - Fork 507
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
use @storybook/preset-typescript and support MDX on Storybook template #440
Comments
I tried using MDX may be cool, but again - tried that in a personal project and faced tons of issues... I think there is just so much going on in 5.3 it's just gonna be awhile before everything is working together. |
agreed. also had issues with MDX and 5.3. i think @shilman is aware of these things and just needs time to figure it out. |
Okay. Up to guys if you want to keep this ticket open or not. If it helps: Using these versions (some are required by the preset):
|
I think it's fair to keep open! I like both ideas, I just wouldn't bother trying them right now. I'm keeping my ears relatively close to Storybook. I'll update if I see things change on my end. Also, if you can get it working feel free! I would just love to see it deployed first with the config as you're sharing. |
@mariusespejo maybe post up a repo for kyle if you can share it |
Sure, here's a minimal example with the config proposed above @kylemh I documented the steps I took to convert to that config in the README if that helps, or see my commits. Running demo of an example MDX story with blocks for preview and props: Click here |
Thanks a ton! Ah, I see where I went wrong... At this point in the docs, we're not told that Awesome, yeah feel free to at least PR for the preset change. Sounds like we should hear back from Jared regarding using MDX. |
Thanks guys. I merged a bad PR in Over the past year we've migrated most of Storybook's packages and public APIs to typescript, but we haven't done much to fix its DX for Typescript users. Since this is a community for TypeScript DX, I would be INCREDIBLY, OVERWHELMINGLY grateful if anybody wanted to team up to get Storybook's TypeScript experience over the line. We're in striking distance and this would be super high leverage work! |
fyi, wanted to post an update on this:
If I understood it correctly, it sounds like starting in Storybook v6 The v2 preset-typescript doesn't seem to play well with the base
For those that run into this ticket basically if you want to use
For everyone else, the original webpack config from @kylemh still works great, no additional changes needed. My recommendation for this ticket is to wait for Storybook v6 and I believe at that point you can just use the typescript-preset without any additional config like so:
Will try to confirm that once it's released. |
I'll be integrating TSDX into a work project this weekend, so I'll be fixing the template up to match current recommendations if I can get it working. I agree waiting for Storybook 6 will likely be the best course. |
Will the new
As far as I understand, EDIT: this was actually a bug in the template |
It won't. I think we should leave that to somebody that uses MDX to integrate with personally. |
I dropped in this change and it worked first try no issue on a new new tsdx react-storybook project. Regardless if this get's added, would be nice in to toss it in the docs, because I was having trouble making this work until I found this. |
I'm opening a PR today to update the preset 💃 Edit: I dove into this a bunch and chatted a bunch with Michael. Unfortunately, I'll simply update the latest v2 preset and add an MDX example and consider the update done for now. |
Thanks for the updates everybody. At Storybook we're doing our best to nail this thing, but flying half blind. All input welcome to try to get this working smoothly. Re: MDX I'm not sure what it means to support MDX. AFAIK MDX itself doesn't support TS, so you should be able to write your components in TS and use them in TS, but JS only inside the MDX file. |
hey folks just wanted to provide an update here before I mark this closed. The conversation here is no longer relevant with the release of Storybook v6 which looks like has direct support for typescript. Sounds like However the storybook template config does still need to be updated which looks like someone already took the effort to determine the next best minimal config on PR #805 (which I tested myself, works great with docs addon and is able to automatically do the docgen stuff behind the scenes, allowing for prop tables to automatically show, etc.). Anyways I'm not familiar with the PR process for this project but I would suggest reviewing and merging #805 to resolve the original intent of this ticket (to rely on Storybook's own recommended way to configure TS and stick to the intention of this project of minimizing the config). |
Current Behavior
Desired Behavior
Suggested Solution
First of all, I noticed that the config was recently cleaned up in #435 (thanks @kylemh !) and expanding on that work, I believe that by taking advantage of @storybook/preset-typescript, we should be able to replace the custom webpack config (can be seen in #435) like so:
I believe that this will better support the tsdx goal of minimal/zero config. The above config still supports docgen extracting comments out of the component files.
From what I can tell, the webpack config was originally introduced in #318 to add support for a
'@'
import alias, which support for that alias was then removed in #435. What's left seems to be completely supported in the typescript preset, unless I am completely missing something here please let me know.Also notice that support for
.mdx
files is very easily added by adding it to the stories blob config above. With that in place, you can add a basic sample MDX file to the template like:Who does this impact? Who is this for?
All users looking to use this library to create a React component library with storybook and typescript.
Describe alternatives you've considered
Alternatively maybe adding to the documentation would help.
Additional context
Open to making a PR (or if someone on the team wants to make the quick change that would be cool too), just wanted to make sure this makes sense to folks and that I'm not completely missing something. Let me know what you guys think, thanks.
The text was updated successfully, but these errors were encountered: