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

Builder-vite: Replace .at() call with [] in codegen #29048

Merged
merged 6 commits into from
Sep 24, 2024

Conversation

Chudesnov
Copy link
Contributor

@Chudesnov Chudesnov commented Sep 4, 2024

Unblocks loading Storybook instances built with Vite on devices locked to pre-2022 browser versions.

Closes #29030

What I did

Replaced usage of an API potentially unavailable in legacy browsers (Array.prototype.at) with a functionally equivalent alternative ([]). This should allow running Storybook in browsers that support ES Modules (script type="module") but don't have the Array.prototype.at method.

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

Manual testing

  1. Run a sandbox for template, e.g. yarn task --task sandbox --start-from auto --template react-vite/default-ts
  2. Open Storybook in your browser without Array.prototype.at support but with ES modules support (e.g. iOS Safari 15.3)
  3. Access any story

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>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.5 MB 77.5 MB 100 B 3.74 0%
initSize 162 MB 162 MB 117 B 0.39 0%
diffSize 85 MB 85 MB 17 B -0.45 0%
buildSize 7.57 MB 7.57 MB -36 B -0.43 0%
buildSbAddonsSize 1.66 MB 1.66 MB 0 B -0.42 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 2.34 MB 2.34 MB 0 B - 0%
buildSbPreviewSize 352 kB 352 kB 0 B - 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.55 MB 4.55 MB 0 B -0.42 0%
buildPreviewSize 3.02 MB 3.02 MB -36 B -0.45 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 17.5s 5.8s -11s -657ms -1.24 🔰-198.6%
generateTime 22.8s 19.6s -3s -196ms -0.59 -16.2%
initTime 14.6s 14.9s 317ms -0.93 2.1%
buildTime 9.9s 11.6s 1.7s 0.4 14.9%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 6.6s 7.5s 901ms 0.73 12%
devManagerResponsive 4.4s 4.8s 389ms 0.5 8.1%
devManagerHeaderVisible 782ms 1s 231ms 2.89 🔺22.8%
devManagerIndexVisible 817ms 1s 231ms 2.59 🔺22%
devStoryVisibleUncached 1.3s 1.5s 251ms 0.78 15.9%
devStoryVisible 816ms 1s 234ms 2.62 🔺22.3%
devAutodocsVisible 632ms 853ms 221ms 1.17 25.9%
devMDXVisible 666ms 842ms 176ms 1.56 🔺20.9%
buildManagerHeaderVisible 716ms 754ms 38ms -0.39 5%
buildManagerIndexVisible 722ms 763ms 41ms -0.5 5.4%
buildStoryVisible 782ms 844ms 62ms -0.03 7.3%
buildAutodocsVisible 664ms 798ms 134ms 0.8 16.8%
buildMDXVisible 652ms 736ms 84ms 0.39 11.4%

Greptile Summary

This pull request replaces the use of Array.prototype.at() with standard array indexing in the Vite builder's code generation script, improving compatibility with older browsers.

Unblocks loading Storybook instances built with Vite devices with pre-2022 browser versions.

Resolves storybookjs#29030
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@shilman shilman added maintenance User-facing maintenance tasks builder-vite labels Sep 9, 2024
@shilman shilman changed the title Replace .at() call with [] in Vite Builder codegen Builder-vite: Replace .at() call with [] in codegen Sep 9, 2024
Copy link

nx-cloud bot commented Sep 24, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit d80402d. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@kasperpeulen kasperpeulen merged commit f655698 into storybookjs:next Sep 24, 2024
50 of 52 checks passed
@github-actions github-actions bot mentioned this pull request Sep 24, 2024
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builder-vite ci:normal maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Storybook Vite Builder injected runtime uses .at() method, breaking compatibility with older browsers.
3 participants