storybookjs / builder-vite

A builder plugin to run and build Storybooks with Vite
MIT License
886 stars 109 forks source link

[Issue] Make sveltedoc-parser a peer dependency #563

Open Narretz opened 1 year ago

Narretz commented 1 year ago

What version of vite are you using?

4.0.4

System info and storybook versions

System: OS: Windows 10 10.0.22621 CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz Binaries: Node: 16.14.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.17 - C:\Program Files\nodejs\yarn.CMD npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.22621.1105.0), Chromium (110.0.1587.50) -> also Firefox, why this command forgor 💀 about Firefox? npmPackages: @storybook/addon-actions: ^6.5.16 => 6.5.16 @storybook/addon-essentials: ^6.5.16 => 6.5.16 @storybook/addon-links: ^6.5.16 => 6.5.16 @storybook/builder-vite: ^0.4.0 => 0.4.0 @storybook/vue: ^6.5.16 => 6.5.16

Describe the Bug

I noticed that builder-vite depends on sveltedoc-parser even if your app uses no svelte at all: https://github.com/storybookjs/builder-vite/blob/baf4d7d09e95049a11e38b46e7373ba17d08ceec/packages/builder-vite/plugins/svelte-docgen.ts

Which means that sveltedoc-parser pulls in tons of dependencies, acorn, estree, eslint etc. All which could (and probably will) have different versions, even if you use them in your app. The whole node_modules for me is like 10MB. There really should be a way to do this differently. It's a general problem with storybook, it pulls in too many dependencies that are not relevant.

Could this handled by making sveltedoc-parser a peer dependency and using a dynamic import in the svelte-docgen plugin?

Link to Minimal Reproducible Example

No response

Participation

IanVS commented 1 year ago

You're right that there are some extra dependencies with this builder, because it can be used in lots of different frameworks. That has been re-architected in Storybook 7.0, where frameworks have been redefined to be a combination of a renderer and a builder. So you might install @storybook/react-vite for instance, and that will include only react and vite-related dependencies.

Unfortunately I don't think it makes sense to make big changes to 6.5 at this point. 7.0 will be released out of beta very soon, and if we changed sveltedoc-parser to be a peer dependency, Svelte users will be confused because they won't expect that they will need to install it. If size of dependencies is a concern for you, I would strongly recommend upgrading to the 7.0 beta, which drastically improves the number and size of dependencies. You can use npx sb@next upgrade --prerelease to try it out.

Narretz commented 1 year ago

Thanks @IanVS. I will try storybook 7.