Make third-party dependencies optional to reduce bundle size and version conflicts #770
Replies: 1 comment 15 replies
-
this is actually already the case since recently, see the custom ui property and the lite ui package if you opt to use the lite ui then you won't need any of those dependencies Initially I wanted to reduce the maintenance burden by bringing in some helpful libraries but I did find it made using on other platforms like macos/tv more difficult so I started experimenting with the lite ui that is now available. Note that optional dependencies don't work in older versions of metro, currently I know this does work in recent versions of expo atleast, the same try/catch approach on optional requires is used by reanimated also for example Since this is already solved in my view I'd like to move this to a discussion and we can discuss further there if you like Note that you can already see that the peer deps are optional here |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
I'm always frustrated when Storybook for React Native forces the inclusion of third-party dependencies like react-native-reanimated, react-native-svg, and @gorhom/bottom-sheet in projects that don't actually use these libraries. This creates three main problems:
Version conflicts between the libraries used in our project and those required by Storybook
Unnecessary native module bundling - our final app bundle includes code for libraries we don't use (e.g., we don't use @gorhom/bottom-sheet or react-native-reanimated, but their code is still bundled)
Breaking changes overhead - libraries like react-native-reanimated have a considerable history of breaking changes between versions, increasing maintenance workload for future Android, iOS, and React Native updates
Describe the solution you'd like
I would like Storybook to make these third-party dependencies optional and limit required dependencies to only internal React Native APIs. For example, @gorhom/bottom-sheet could be replaced with React Native's built-in Modal component. This would allow projects to opt-in to additional dependencies only when needed, rather than being forced to include them.
Describe alternatives you've considered
Are you able to assist bring the feature to reality?
Yes, I can contribute to this feature implementation. I have experience in React Native and open-source projects, I'm willing to help with code reviews, testing, and implementation.
Additional context
This issue particularly affects enterprise projects and apps with strict bundle size requirements. Many teams avoid updating Storybook versions due to conflicts with these mandatory dependencies, which impacts the overall developer experience and adoption of newer Storybook features.
Beta Was this translation helpful? Give feedback.
All reactions