Maintenance: Enable syntax minification for dead code elimination#33001
Maintenance: Enable syntax minification for dead code elimination#33001ndelangen merged 11 commits intostorybookjs:nextfrom
Conversation
|
View your CI Pipeline Execution ↗ for commit 0d98abb
☁️ Nx Cloud last updated this comment at |
This comment was marked as spam.
This comment was marked as spam.
|
@mrginglymus It does not look like the are actually any size-changes detected? |
|
This branch might just be out of date, but Even allowing for a different set of features, react-dom is down from 235.6kb to 232.9kb, not sure where the bulk of that is coming from then... oh - next has |
|
I'm okay with this change |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 2 | 2 | 0 |
| Self size | 181 KB | 414 KB | 🚨 +232 KB 🚨 |
| Dependency size | 2.97 MB | 2.97 MB | 0 B |
| Bundle Size Analyzer | Link | Link |
@storybook/addon-vitest
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 2 | 6 | 🚨 +4 🚨 |
| Self size | 376 KB | 441 KB | 🚨 +66 KB 🚨 |
| Dependency size | 338 KB | 570 KB | 🚨 +232 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/builder-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 17 | 11 | 🎉 -6 🎉 |
| Self size | 304 KB | 291 KB | 🎉 -13 KB 🎉 |
| Dependency size | 2.00 MB | 1.30 MB | 🎉 -701 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/builder-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 191 | 187 | 🎉 -4 🎉 |
| Self size | 75 KB | 66 KB | 🎉 -9 KB 🎉 |
| Dependency size | 32.19 MB | 31.98 MB | 🎉 -215 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 39 | 44 | 🚨 +5 🚨 |
| Self size | 19.65 MB | 21.70 MB | 🚨 +2.05 MB 🚨 |
| Dependency size | 16.40 MB | 17.16 MB | 🚨 +755 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/angular
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 191 | 187 | 🎉 -4 🎉 |
| Self size | 118 KB | 114 KB | 🎉 -3 KB 🎉 |
| Dependency size | 30.31 MB | 30.00 MB | 🎉 -317 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/ember
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 195 | 191 | 🎉 -4 🎉 |
| Self size | 15 KB | 15 KB | 0 B |
| Dependency size | 28.91 MB | 28.69 MB | 🎉 -224 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/html-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 20 | 14 | 🎉 -6 🎉 |
| Self size | 22 KB | 22 KB | 0 B |
| Dependency size | 2.34 MB | 1.63 MB | 🎉 -715 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 537 | 533 | 🎉 -4 🎉 |
| Self size | 645 KB | 645 KB | 🚨 +230 B 🚨 |
| Dependency size | 59.13 MB | 58.91 MB | 🎉 -225 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 128 | 124 | 🎉 -4 🎉 |
| Self size | 1.12 MB | 1.12 MB | 🚨 +224 B 🚨 |
| Dependency size | 21.95 MB | 21.72 MB | 🎉 -229 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/preact-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 20 | 14 | 🎉 -6 🎉 |
| Self size | 13 KB | 13 KB | 0 B |
| Dependency size | 2.33 MB | 1.61 MB | 🎉 -715 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-native-web-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 160 | 156 | 🎉 -4 🎉 |
| Self size | 30 KB | 30 KB | 🎉 -1 B 🎉 |
| Dependency size | 23.13 MB | 22.90 MB | 🎉 -231 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 118 | 114 | 🎉 -4 🎉 |
| Self size | 35 KB | 35 KB | 🎉 -130 B 🎉 |
| Dependency size | 19.75 MB | 19.52 MB | 🎉 -229 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 277 | 273 | 🎉 -4 🎉 |
| Self size | 24 KB | 24 KB | 🚨 +12 B 🚨 |
| Dependency size | 44.08 MB | 43.85 MB | 🎉 -225 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/server-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 203 | 199 | 🎉 -4 🎉 |
| Self size | 16 KB | 16 KB | 0 B |
| Dependency size | 33.45 MB | 33.23 MB | 🎉 -224 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/svelte-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 24 | 19 | 🎉 -5 🎉 |
| Self size | 56 KB | 56 KB | 🚨 +12 B 🚨 |
| Dependency size | 27.00 MB | 26.75 MB | 🎉 -255 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/sveltekit
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 25 | 20 | 🎉 -5 🎉 |
| Self size | 56 KB | 56 KB | 🎉 -24 B 🎉 |
| Dependency size | 27.06 MB | 26.80 MB | 🎉 -255 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/vue3-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 114 | 109 | 🎉 -5 🎉 |
| Self size | 35 KB | 36 KB | 🚨 +224 B 🚨 |
| Dependency size | 44.15 MB | 43.90 MB | 🎉 -254 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/web-components-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 21 | 15 | 🎉 -6 🎉 |
| Self size | 19 KB | 19 KB | 0 B |
| Dependency size | 2.37 MB | 1.65 MB | 🎉 -715 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 173 | 188 | 🚨 +15 🚨 |
| Self size | 773 KB | 838 KB | 🚨 +64 KB 🚨 |
| Dependency size | 66.62 MB | 71.38 MB | 🚨 +4.76 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 166 | 170 | 🚨 +4 🚨 |
| Self size | 30 KB | 30 KB | 🎉 -11 B 🎉 |
| Dependency size | 65.19 MB | 67.91 MB | 🚨 +2.72 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 40 | 45 | 🚨 +5 🚨 |
| Self size | 999 KB | 1.45 MB | 🚨 +453 KB 🚨 |
| Dependency size | 36.05 MB | 38.86 MB | 🚨 +2.81 MB 🚨 |
| Bundle Size Analyzer | node | node |
|
@mrginglymus I tried to add another thing to this PR, but git told me I'm not authorized for some reason? https://github.com/storybookjs/storybook/pull/33028/files |
@ndelangen whoops! sorry, I must have unchecked the allow edits by maintainers... |
|
I added a few more things to this PR:
I had to add a name property to the StorybookError class for that. |
|
It's odd how the size reporting is completely different from when I had the fork PR open 😕 |
|
@mrginglymus I'm looking at the dist, and there are plenty of unused variables: |
|
Those ones from polished are to be expected; the calls to |
|
You can work around this with deep imports ( |


Closes #32964
What I did
SB 10 does not minify code. Whilst this makes debugging considerably easier, it also means that dead code elimination is not applied (e.g. conditional blocks protected by compile-time constants like
process.env.NODE_ENV).Thankfully, esbuild provides three separate options for minification. Enabling
minifySyntaxwill apply dead code elimination, as well as a couple of other relatively harmless optimisations. A brief scan suggests these include things like:truewith!0{}around single-line blocksHowever, critically, it preserves whitespace and identifiers.
This also appears to give you a small (~10%) saving in runtime code, though much of this may get eaten by gzip
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
Please ensure, the output dist of the storybook packages (just pick a few) (and a few entry-points of core) contain human readable code.
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake 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/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>Summary by CodeRabbit
Chores
Bug Fixes