Closed Bilge closed 7 months ago
Hi, same issue
Since version 5 you have to manually add react-syntax-highlighter
as a dependency. From the readme:
Install the addon and its dependencies.
With NPM:
npm i --save-dev @whitespace/storybook-addon-html prettier react-syntax-highlighter
With Yarn:
yarn add -D @whitespace/storybook-addon-html prettier react-syntax-highlighter
But why? I don't use React. In any case, if this isn't an optional dependency then it should not have to be added manually at all.
The Storybook application uses React, including all the UI and addons, regardless of what framework you use for your components. react-syntax-highlighter
is used in the panel to highlight the HTML syntax. It was added as a peer dependency (that you need to install manually) to allow you to choose which version to use, which was required to solve issue #38.
Did adding react-syntax-highlighter
to you package.json solve the problem for you?
Maybe my understanding of the Node dependency ecosystem is poor, but according to the issue you linked it seems you can (and wish to) declare the library is compatible with versions 13 through 15 of the dependency, react-syntax-highlighter. But rather than do that, you just removed the dependency altogether, despite the fact that you still have such a dependency, and instead just documented that it's the end-user's responsibility to include the dependency.
Now, again, maybe my understanding of NPM and such is poor, but it is my understanding of dependencies and dependency solvers in general that libraries should declare all their dependencies and, if they are compatible with a range of dependencies, to declare that range. It is not, in any scenario, correct to simply yank the dependency and push that burden of knowledge out to the consumer of your library.
For a dependency
, npm always uses the highest version matching the range. There is no config that will allow a project to install version 13 of the dependency (if you depend on it at the root, you will end up with 2 different versions in your node_modules folder)
Upgrading
"@storybook/html": "^6.3.2"
->^6.5.15
(and"@whitespace/storybook-addon-html": "^5.0.0"
->^5.1.1
) causes the following errors at build time:It now seems to assume that
react-syntax-highlighter
would be available, even though it certainly wouldn't, in an HTML-only project that does not use React whatsoever.Edit: Note this error just occurs due to upgrading this addon; upgrading Storybook itself is immaterial. Downgrading to 5.0.0 "fixes" the issue.