addon-designs: Dependency on @storybook/api or incompatibility with latest alpha of storybook
Affected design types
- figma
- figspec
- link
- image
- iframe
Describe the bug
I updated Storybook from alpha.49 to alpha.54 (next as of today) and storybook-addon-designs from beta.1 to beta.2 and I got the following error:
✘ [ERROR] Could not resolve "@storybook/api"
node_modules/storybook-addon-designs/esm/register/index.js:2:29:
2 │ import { useParameter } from "@storybook/api";
╵ ~~~~~~~~~~~~~~~~
You can mark the path "@storybook/api" as external to exclude it from the bundle, which will
remove this error.
✘ [ERROR] Could not resolve "@storybook/api"
node_modules/storybook-addon-designs/esm/register/containers/Wrapper.js:3:48:
3 │ import { useParameter, useStorybookState } from "@storybook/api";
╵ ~~~~~~~~~~~~~~~~
You can mark the path "@storybook/api" as external to exclude it from the bundle, which will
remove this error.
Installing @storybook/api in project as project’s own devDependency resolves the problem
How to reproduce the bug?
- Install storybook
7.0.0-alpha.49and storybook-addon-designs7.0.0-beta.1, check that storybook starts without errors - update storybook to
alpha.54andstorybook-addon-designstobeta-2, check that there are errors during start of storybook (storybook dev)
Expected behaviour
There’s no need to install @storybook/api in project to make storybook-addon-designs not break storybook dev
After quick bisect it turned out that alpha.54 stopped installing @storybook/api as its dependency
https://github.com/storybookjs/storybook/blob/next/CHANGELOG.md#700-alpha54-november-25-2022
Environment
- Chrome / Chromium / Chromium based browsers
- Firefox
- macOS Safari
- iOS Safari
- Samsung Internet
- Other
Affected versions
7.0.0-beta.2
Storybook versions
7.0.0-alpha.54
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 15
I’m one of the Storybook maintainers. I focus primarily on documentation and community outreach. Just wanted to follow up on this issue, letting you know that the Storybook API for building addons is currently being updated to factor in the changes introduced by the upcoming 7.0 release. If you’re interested in making the required changes to help the community from benefiting from using your addon, we’ve prepared an abridged guide for the required changes here, and if you have any questions or issues, please reach out to us in the #prerelease channel in our Discord Server.
Hope you have a great day!
Stay safe
At the time I wrote https://github.com/pocka/storybook-addon-designs/issues/178#issuecomment-1365765087 and so far in my setup it looks like that:
msw-storybook-addon@1.6.3which requires@storybook/addonsstorybook-addon-designs@7.0.0-beta.2has peerDependency of"@storybook/addons": "^6.4.0 || ^7.0.0"@storybook/addonsas devDependency of my projectand it worked.
Now I removed explicit dependency on
@storybook/addons. Npm moved@storybook/addonstonode_modules/msw-storybook-addon/node_modules/@storybook/addonsand error came backThen I removed and added back
msw-storybook-addonwhich fixed the structure of mynode_modules- now@storybook/addonsis atnode_modules/@storybook/addonsand it works once again, yet now I have@storybook/addons@6.5.15becausemsw-storybook-addonwants^6.0.0.I suppose it now works purely be accident - because I use
msw-storybook-addonand it’s that one which allowsstorybook-addon-designs@7.0.0-beta.2to work without problem.I hope to have some more time to try beta.25 later - maybe something that comes with it (or with
@storybook-addon-essentialswhich it’s probably save to assume vast majority uses) brings back@storybook/addonsBy the end of the week I will check what I have now (last time I updated it was beta.19) and confirm if that problem still exists. And if it does I’ll try bumping to beta.25
I failed to reproduce the
Could not resolve "@storybook/addons"problem, it could have been fixed or is caused by Storybook’s internal dependecy gotchas.mkdir sb-testpackage.jsonnpx -p storybook@next storybook init@storybook/testing-libraryfrompackage.json, as it pulls v6 depsstories/Page.stories.js, as it uses@storybook/testing-librarynpm i -D --force storybook-addon-designs@beta(--forceor--legacy-peer-depsis required as ourpackage.jsondoes not list SB@7beta in peer deps)designparameter to the auto generated storynpm run storybook@jrencz Would you mind sharing which Storybook packages and package manager you’re using?
@jonniebigodes Thank you for reaching out. I believe this addon is already compatible with Storybook v7 API-wise, thanks to these contributions.
Maybe you might escalate that to sb team. It’s still an alpha so maybe it wasn’t intended an/or can be reconsidered?
Oh… that’s an uncomfortable breaking change…
I believe there is no way to avoid manually installing
@storybook/api:@storybook/manager-apibreaks v6.x compatibility@storybook/apiinto regular dependency would very likely cause a version mismatch problemI’ll update README once Storybook v7.0-beta is shipped.