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

Interactions: Correctly load preset when absolute paths are used #30264

Merged
merged 2 commits into from
Jan 15, 2025

Conversation

JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Jan 15, 2025

What I did

Moved the content of /preset.js in addon-interactions to /dist/preset.js (via src/preset.ts), and require that in /preset.js.

This fixes a bug where addon-test postinstall loads all presets to determine if addon-interactions is preset. It does that by looking for a boolean set in addon-interactions' dist/preset.js file.
However, when addons/presets are absolute paths and not package names - eg when using getAbsolutePath('@storybook/addon-interactions') in main.ts - the export map of the package is not taken into account, instead the root /preset.js is loaded. And that file did not contain the boolean. In 99 % of the cases, root /preset.js just need to re-export /dist/preset.js to ensure those two are always in sync, so that's what we did here and that's what fixed this.

In reality this also fixes a bug where the addon order check would only run when absolute paths were used, and not when the regular package name was used.

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 77.9 MB 77.9 MB 0 B 1.73 0%
initSize 131 MB 131 MB 486 B 1.69 0%
diffSize 52.9 MB 52.9 MB 486 B -0.91 0%
buildSize 7.19 MB 7.19 MB 0 B 2.31 0%
buildSbAddonsSize 1.85 MB 1.85 MB 0 B -1.22 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.87 MB 1.87 MB 0 B 3 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.91 MB 3.91 MB 0 B 1.98 0%
buildPreviewSize 3.28 MB 3.28 MB 0 B 2.37 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.5s 24.4s 17.8s 1.45 🔺73.2%
generateTime 19.4s 20.4s 957ms -0.23 4.7%
initTime 12.7s 13.1s 405ms -0.86 3.1%
buildTime 8.6s 9.8s 1.1s 0.6 11.4%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.7s 4.2s -467ms -1.4 🔰-10.9%
devManagerResponsive 3.4s 3.3s -151ms -1.08 -4.6%
devManagerHeaderVisible 641ms 536ms -105ms -1.01 -19.6%
devManagerIndexVisible 676ms 547ms -129ms -1.23 -23.6%
devStoryVisibleUncached 1.8s 1.7s -33ms -0.23 -1.8%
devStoryVisible 675ms 568ms -107ms -1.08 -18.8%
devAutodocsVisible 569ms 520ms -49ms -0.42 -9.4%
devMDXVisible 573ms 458ms -115ms -1.13 -25.1%
buildManagerHeaderVisible 555ms 581ms 26ms -0.06 4.5%
buildManagerIndexVisible 641ms 665ms 24ms -0.04 3.6%
buildStoryVisible 536ms 563ms 27ms -0.09 4.8%
buildAutodocsVisible 495ms 426ms -69ms -0.97 -16.2%
buildMDXVisible 450ms 405ms -45ms -1.21 -11.1%

Greptile Summary

Refactored the interactions addon preset handling to fix issues with absolute paths and ensure consistent addon order checking across different import methods.

  • Modified /code/addons/interactions/preset.js to properly re-export from /dist/preset.js
  • Updated path handling in /code/addons/interactions/src/preset.ts to support both absolute and relative config directories
  • Fixed addon-test postinstall check by ensuring ADDON_INTERACTIONS_IN_USE boolean is accessible via absolute paths
  • Ensured addon order check runs consistently regardless of package import method

Copy link

nx-cloud bot commented Jan 15, 2025

View your CI Pipeline Execution ↗ for commit e447db6.

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 36s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-15 09:41:10 UTC

@JReinhold JReinhold marked this pull request as ready for review January 15, 2025 09:36
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

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

@JReinhold JReinhold merged commit ccb214d into next Jan 15, 2025
56 of 61 checks passed
@JReinhold JReinhold deleted the jeppe/fix-interactions-removal branch January 15, 2025 10:04
@github-actions github-actions bot mentioned this pull request Jan 15, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants