Closed pkyeck closed 5 months ago
Since v7 storybook are advising addon authors to move to devDependencies, are you using v7 yet?
I haven't seen this error in testing yet but the storybook docs don't make it clear specifically which packages are "Globalized" so it's also possible @storybook/icons isn't one of them and it'll need to go back into the dependencies like you suggest.
yes, I'm using v7
"@etchteam/storybook-addon-css-variables-theme": "2.1.0",
"@storybook/addon-essentials": "7.6.18",
"@storybook/addon-links": "7.6.18",
"@storybook/addon-queryparams": "7.0.1",
"@storybook/addon-viewport": "7.6.18",
"@storybook/blocks": "7.6.18",
"@storybook/html": "7.6.18",
"@storybook/html-webpack5": "7.6.18",
"storybook": "7.6.18"
I got most of the storybook modules in my package.json as well but not the icons and that's where the error comes from
I haven't seen this error in testing yet but the storybook docs don't make it clear specifically which packages are "Globalized" so it's also possible @storybook/icons isn't one of them and it'll need to go back into the dependencies like you suggest.
do you refer to this part in the docs? https://storybook.js.org/docs/addons/addon-migration-guide#react-peer-dependency-is-no-longer-required
it also says:
This assumes your addon uses tsup for bundling. If your addon was built with an older version of the Addon Kit that uses Babel for bundling, you must first switch to tsup. For guidance, explore these older changes implemented in the Addon Kit repository.
so maybe it's because you are still using babel atm
It was this globalized packages text that I linked https://github.com/storybookjs/addon-kit?tab=readme-ov-file#globalized-packages
Storybook provides a predefined set of packages that are available in the manager UI and the preview UI. In the final bundle of your addon, these packages should not be included. Instead, the imports should stay in place, allowing Storybook to replace those imports with the actual packages during the Storybook build process.
I did manage to uncover the specific list of globalized packages, there's a separate one for manager and preview:
@storybook/manager/globals
= "react" | "react-dom" | "@storybook/components" | "@storybook/channels" | "@storybook/core-events" | "@storybook/core-events/manager-errors" | "@storybook/router" | "@storybook/theming" | "@storybook/icons" | "@storybook/manager-api" | "@storybook/client-logger" | "@storybook/types"
@storybook/preview/globals
= "@storybook/global" | "@storybook/channels" | "@storybook/client-logger" | "@storybook/core-events" | "@storybook/core-events/preview-errors" | "@storybook/preview-api" | "@storybook/types"
"@storybook/icons" is included there in the manager/globals.
Investigating more it probably is down to a difference between how the two bundlers work – tsup externals won't try to bundle the code into the end package but Babel probably will(?), might explain why it works in some cases and not others.
Ideally, we don't want to be requiring separate versions of global dependencies that Storybook now expects to provide itself. So, I will have a go at moving to the same tsup config as the addon kit now uses to accomplish that.
Thanks for the feedback and sorry for messing up the installation 🙈
@DanWebb Are the globalized packages a storybook v8 feature? B/c I just tried to install #65 but get the same error with v7.
Damn, I got a reproduction up using v7 and can see the same. It looks like Storybook added this package in v8 so it wouldn't be part of the globals until v8.
I think we'll need to bring icons back as a dependency in the v2 line and then release v3 with it removed.
I think releasing the v8 stuff as your v3 would make sense so others don't get the breaking changes via auto-update b/c they have ^2.0.9
in their package.json
hi i updated from 2.0.6 -> 2.1.0 and the plugin is not working anymore b/c you got rid of the dependencies and moved everything to the devDependencies which does not install the required packages :(