You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building a library of React components that also makes use of styled-components for styling.
Storybook of course needs styled-components to be installed to work.
However, when I npm link my library and install it in an example app I'm building, the app throws an error due to multiple versions of styled-components loading.
I'm using rollup to package up my library and manage externals, and it works fine when npm installed normally.
I guess this is something to do with the way npm link works.
I've noticed that if I run npm install styled-components --no-save, it works, but I wouldn't know how to deploy the storybook to the web without its dependencies fully listed.
Expected behavior
I need a way to split up the dependencies (?) so that the things I need installed to run storybook don't leak out through npm link and break my example app.
I am not sure whether this can be considered a bug or a request for improved docs.
Code snippets
My rollup config for packaging the library:
import resolve from '@rollup/plugin-node-resolve'
import babel from 'rollup-plugin-babel'
import images from "@rollup/plugin-image"
import autoExternal from "rollup-plugin-auto-external"
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
export default {
input: 'src/index.js',
output: {
file: 'dist/bundle.js',
format: 'cjs'
},
plugins: [
peerDepsExternal(),
autoExternal(),
resolve({
extensions: [
".js",
".jsx"
]
}),
images(),
babel({
exclude: 'node_modules/**'
}),
],
}
Additional context
This feels like it should be made clearer, since storybook is meant for making UI libraries, most of those libraries end up as npm modules, and surely a big fraction of those use styled-components.
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!
Describe the bug
I'm building a library of React components that also makes use of
styled-components
for styling.Storybook of course needs
styled-components
to be installed to work.However, when I
npm link
my library and install it in an example app I'm building, the app throws an error due to multiple versions ofstyled-components
loading.I'm using
rollup
to package up my library and manage externals, and it works fine whennpm install
ed normally.I guess this is something to do with the way
npm link
works.I've noticed that if I run
npm install styled-components --no-save
, it works, but I wouldn't know how to deploy the storybook to the web without its dependencies fully listed.Expected behavior
I need a way to split up the dependencies (?) so that the things I need installed to run storybook don't leak out through
npm link
and break my example app.I am not sure whether this can be considered a bug or a request for improved docs.
Code snippets
My rollup config for packaging the library:
My library's package.json:
System:
Additional context
This feels like it should be made clearer, since storybook is meant for making UI libraries, most of those libraries end up as npm modules, and surely a big fraction of those use
styled-components
.styled-components
guidance for situations like this: https://styled-components.com/docs/faqs#i-am-a-library-author-should-i-bundle-styledcomponents-with-my-libraryThe text was updated successfully, but these errors were encountered: