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

Addon Test: Only optimize react deps if applicable in vitest-plugin #29617

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Nov 14, 2024

Closes #29616

What I did

This PR changes the logic in the dep optimization so that it only includes react-dom/test-utils (which we use in sb for react) if applicable

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

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

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-storybook/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 78.2 MB 78.2 MB 0 B 1.26 0%
initSize 143 MB 143 MB 0 B 1.05 0%
diffSize 65.2 MB 65.2 MB 0 B 0.34 0%
buildSize 6.88 MB 6.88 MB 0 B 1.72 0%
buildSbAddonsSize 1.51 MB 1.51 MB 0 B 0.33 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.9 MB 1.9 MB 0 B 1.74 0%
buildSbPreviewSize 271 kB 271 kB 0 B - 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.88 MB 3.88 MB 0 B 1.72 0%
buildPreviewSize 3 MB 3 MB 0 B - 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 6.7s 23.1s 16.4s 1.36 🔺71%
generateTime 20s 19.5s -499ms -0.68 -2.6%
initTime 14.4s 13.6s -820ms -1.53 🔰-6%
buildTime 8.3s 7.7s -623ms -0.95 -8%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.7s 6.6s 1.9s 1.55 🔺28.9%
devManagerResponsive 3s 4.1s 1.1s 1.68 🔺28.4%
devManagerHeaderVisible 496ms 535ms 39ms -0.45 7.3%
devManagerIndexVisible 527ms 571ms 44ms -0.76 7.7%
devStoryVisibleUncached 1s 1s -33ms -0.3 -3.2%
devStoryVisible 526ms 570ms 44ms -0.62 7.7%
devAutodocsVisible 400ms 564ms 164ms 0.68 29.1%
devMDXVisible 436ms 463ms 27ms -0.68 5.8%
buildManagerHeaderVisible 483ms 556ms 73ms -0.17 13.1%
buildManagerIndexVisible 496ms 594ms 98ms 0.09 16.5%
buildStoryVisible 484ms 546ms 62ms -0.28 11.4%
buildAutodocsVisible 380ms 475ms 95ms 0.16 20%
buildMDXVisible 370ms 487ms 117ms 0.57 24%

Greptile Summary

Modifies the Vitest plugin to conditionally optimize React dependencies, preventing failures in non-React frameworks while maintaining functionality for React-based projects.

  • Modified code/addons/test/src/vitest-plugin/index.ts to conditionally include 'react-dom/test-utils' in optimizeDeps only for React/Next.js frameworks
  • Added framework detection logic to prevent dependency resolution errors in non-React environments
  • Added debug logging for optimizeDeps configuration troubleshooting

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.

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

config.optimizeDeps.include.push('react-dom/test-utils');
}

console.log(config.optimizeDeps);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Remove debug console.log statement before merging

@yannbf yannbf added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Nov 14, 2024
@yannbf yannbf force-pushed the yann/fix-dep-optimization-issue branch from b7b7b1c to 7e4d45a Compare November 14, 2024 12:20
Copy link

nx-cloud bot commented Nov 14, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 7e4d45a. 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.

@yannbf yannbf merged commit b3a9dfd into next Nov 14, 2024
58 of 61 checks passed
@yannbf yannbf deleted the yann/fix-dep-optimization-issue branch November 14, 2024 13:03
yannbf added a commit that referenced this pull request Nov 14, 2024
…issue

Addon Test: Only optimize react deps if applicable in vitest-plugin

(cherry picked from commit b3a9dfd)
@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Nov 14, 2024
@github-actions github-actions bot mentioned this pull request Nov 16, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: test bug ci:normal patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Storybook 8.4.3 Failed to resolve dependency: react-dom/test-utils, present in 'optimizeDeps.include'
2 participants