-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add @storybook/icons as a regular dependency #25768
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look right, it's globalized in the manager so it shouldn't be necessary.
https://github.com/storybookjs/storybook/blob/next/code/ui/manager/src/globals/globals.ts#L11
Could you elaborate on the issues you get in Yarn PnP?
It isn't globalized, otherwise yarn wouldn't complain about trying to import it. I also don't think its right to globalize this package because it is a) not a mono repo package and b) the user might install a different version than the one is used in the manager. That's totally valid and would just add unnecessary confusion if we globalize it. |
It should be, so I don't know why Yarn is complaining. What are the reproduction steps?
Why does this matter?
That is correct, this can cause confusion. However it's a perf trade off, if 10 addons install 10 different versions of the icons package, the user will have 10x all icons in their bundle. cc @ndelangen @shilman I recall you two originally decided on this. |
The context: #25688 (comment) We have no versioning rule for non-mono repo packages. Every add-on and every user can install whatever version they need. Doing some swapping in the background to use exactly one version is very magical and unintuitive. The icons were made in a way that they are treeshakable. Therefore, this exact version matching magic is only an advantage, if different add-ons are using the same icon. Otherwise, it doesn't matter. And we are talking here about a couple of kilobytes per icon. So the bundle size reduction only matters for the same icons, not for differently used ones. I think we are sacrificing intuitiveness for marginal build size optimization of I personally vote to remove the globalization of non mono repo packages like |
If we accept it for packages like manager-api, why not accept this for icons?
We discussed this at length as far as i can remember, and we decided to go with the globalization approach, because it resulted in smaller bundles & fewer files to load into the browser overall. Globalization also causes the bundler to exit out of the deep dependency graph and build faster, (though esbuild is already super fast) We made all icons lazy-loaded, right? Maybe I'm misremembering though, because this changed multiple times. I remember looking at the comparison in benchmarks and this approach coming out on top.
Yes, I get why... addon creators might depend on super later version of icons, and that version has an new icon introduced that the prebundled set doesn't have... |
We don't have any choice, do we? Suppose we don't globalize mono-repo packages like |
This argument makes sense to me, it's not the same case for
Yeah I guess this would be the main concern. Maybe prioritising correctness (use the version that the addon author specifies) over perf (globalize) would be best here.
We did not @ndelangen, IIRC we found a bug in ESBuild that when adding the lazy loading logic it would output a non-treeshakable file, but it might be because of something else. If we do decide to go ahead with this PR, it needs to un-globalize the package as well. |
The bug wasn't reproducible anymore. For now, we stay with the globalization of |
Closes N/A
What I did
I moved
@storybook/icon
fromdevDependencies
into thedependencies
section since it isn't a mono repo dependency and doesn't get prebundled. It caused issues with yarn pnpChecklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.馃 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>