Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance: Remove sourcemaps generation #23936

Merged
merged 3 commits into from
Aug 24, 2023

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Aug 24, 2023

What I did

@yannbf & me noticed that around 6-12mb of static-storybook's size is sourcemaps.

When bindling our code (manager and prebuild) we should not generate sourcemaps, because of the size. We have minifyIdentifiers turned off:

minifyIdentifiers: false,

... therefore sourcemaps do not add a lot to the ability to understand and debug the code.

Thus removing it is the best compromise.

Here is an example of before/after removing sourcemaps in the storybook test-runner example storybook statics:

Before:

472K    storybook-static/sb-preview
 16K    storybook-static/sb-addons/essentials-measure-6
 64K    storybook-static/sb-addons/ui-storybook-11
 56K    storybook-static/sb-addons/essentials-viewport-4
8.0K    storybook-static/sb-addons/links-0
1.1M    storybook-static/sb-addons/interactions-8
496K    storybook-static/sb-addons/designs-10
 16K    storybook-static/sb-addons/essentials-outline-7
 32K    storybook-static/sb-addons/essentials-toolbars-5
 52K    storybook-static/sb-addons/essentials-backgrounds-3
292K    storybook-static/sb-addons/essentials-actions-2
5.1M    storybook-static/sb-addons/storysource-9
2.0M    storybook-static/sb-addons/essentials-controls-1
9.3M    storybook-static/sb-addons
204K    storybook-static/sb-common-assets
3.4M    storybook-static/sb-manager
 19M    storybook-static/assets
 33M    storybook-static

After:

472K    ./storybook-static/sb-preview
4.0K    ./storybook-static/sb-addons/essentials-measure-6
 12K    ./storybook-static/sb-addons/ui-storybook-11
 12K    ./storybook-static/sb-addons/essentials-viewport-4
4.0K    ./storybook-static/sb-addons/links-0
184K    ./storybook-static/sb-addons/interactions-8
 84K    ./storybook-static/sb-addons/designs-10
4.0K    ./storybook-static/sb-addons/essentials-outline-7
8.0K    ./storybook-static/sb-addons/essentials-toolbars-5
 12K    ./storybook-static/sb-addons/essentials-backgrounds-3
 40K    ./storybook-static/sb-addons/essentials-actions-2
1.6M    ./storybook-static/sb-addons/storysource-9
380K    ./storybook-static/sb-addons/essentials-controls-1
2.4M    ./storybook-static/sb-addons
204K    ./storybook-static/sb-common-assets
3.4M    ./storybook-static/sb-manager
 19M    ./storybook-static/assets
 26M    ./storybook-static

A drop of 7M! (21%)

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests
  • benchmarking

Manual testing

I manually tested this on my local machine, by running yarn storybook:ui:build in the code directory.
Then I investigated the output of the static-storybook directory, and verified there are no .map files, except the ones that vite generated.

(We keep the sourcemaps generated by vite, because they are for the preview, and DO actually help the user debug their OWN code better.
The user can chose to disable sourcemaps themselves to get a faster build/deploy)

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/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>

code/lib/cli/src/dev.ts Outdated Show resolved Hide resolved
code/lib/cli/src/dev.ts Outdated Show resolved Hide resolved
Copy link
Member

@yannbf yannbf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@JReinhold JReinhold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗜️

@yannbf
Copy link
Member

yannbf commented Aug 24, 2023

🗜️

more like
image

@yannbf yannbf merged commit 9bdffe1 into next Aug 24, 2023
15 of 17 checks passed
@yannbf yannbf deleted the norbert/no-sourcemaps-for-prebuild-and-addons branch August 24, 2023 08:46
@github-actions github-actions bot mentioned this pull request Aug 24, 2023
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants