storybookjs / addon-kit

Everything you need to build a Storybook addon
https://storybook.js.org/docs/react/addons/writing-addons
MIT License
147 stars 35 forks source link

Support both SB 6 & 7 #46

Closed JesusTheHun closed 1 year ago

JesusTheHun commented 1 year ago

Is there a way to support SB 6 and 7 with the same package? Or do I need to make a breaking change version?

winkerVSbecks commented 1 year ago

That's a really good question. There are some breaking API changes so I wouldn't expect a SB7 addon to work with 6.x and vice versa. The addon kit specifies Storybook dependencies as peer dependencies, so they'll come from your Storybook setup.

IMO you'd have to release a new major version of your addon.

JesusTheHun commented 1 year ago

I have noticed some changes, but I didn't see any hard breaking changes, meaning that if you check for the SB version at runtime, you should be able to branch your code. I don't know SB have much as you do though, hence this issue. What do you think about code branching ?

winkerVSbecks commented 1 year ago

It depends a bit on how your addon is setup.

There are a few changes that could impact your addon:

@storybook/api is still available in 7.0 but you'll see a deprecation warning.

IMO publish an alpha of your addon and try it out. I would be very interested in the results too.

winkerVSbecks commented 1 year ago

Otherwise, check out https://github.com/storybookjs/addon-styling It's been set up to publish two versions. 6x on main and 7.0 on next

auto handles that for you by default

winkerVSbecks commented 1 year ago

Official recommendation is in the migration guide: https://storybook.js.org/docs/react/addons/addon-migration-guide#releasing