Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Apr 3, 2025

What I did

This pull request includes changes to the Instrumenter class in the code/core/src/instrumenter/instrumenter.ts file, aimed at improving the handling of the addons module by removing a workaround for circular dependencies. The most important changes include importing the addons module directly and simplifying the initialization process.

Changes to Instrumenter class:

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 pull request has been released as version 0.0.0-pr-31057-sha-a4eda8b5. Try it out in a new sandbox by running npx [email protected] sandbox or in an existing project with npx [email protected] upgrade.

More information
Published version 0.0.0-pr-31057-sha-a4eda8b5
Triggered by @valentinpalkovic
Repository storybookjs/storybook
Branch norbert/intrumenter-fix
Commit a4eda8b5
Datetime Fri Apr 4 06:39:10 UTC 2025 (1743748750)
Workflow run 14259555721

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=31057

Greptile Summary

Improved the Instrumenter initialization by replacing dynamic imports with direct imports for the addons module and tightening type safety in the typings file.

  • Updated code/core/src/instrumenter/instrumenter.ts to directly import and initialize the addons module, removing circular dependency workarounds.
  • Modified code/core/src/typings.d.ts to explicitly type __STORYBOOK_ADDONS_PREVIEW using the AddonStore type.
  • Simplified initialization by calling addons.ready() directly once addons are available.

…ons. This change improves dependency management and eliminates the need for a circular dependency workaround.
@ndelangen ndelangen changed the title Update typings and refactor instrumenter to use direct import for addons. This change improves dependency management and eliminates the need for a circular dependency workaround. Instrumenter: Fix preview-api import for react-native Apr 3, 2025
@ndelangen ndelangen self-assigned this Apr 3, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the initialization of the addons module in the Instrumenter class by removing the dynamic import workaround for circular dependencies in favor of a direct import. Key changes include:

  • Changing the dynamic import of addons from 'storybook/preview-api' to a static import.
  • Simplifying the initialization logic by directly calling addons.ready() when addons is available.

@ndelangen ndelangen marked this pull request as ready for review April 3, 2025 12:23
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

Copy link

nx-cloud bot commented Apr 3, 2025

View your CI Pipeline Execution ↗ for commit a4eda8b.

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

☁️ Nx Cloud last updated this comment at 2025-04-03 13:37:40 UTC

…s change simplifies mocking and improves code organization by eliminating direct dependency on the global addons channel.
@ndelangen ndelangen merged commit afcd012 into next Apr 3, 2025
50 of 53 checks passed
@ndelangen ndelangen deleted the norbert/intrumenter-fix branch April 3, 2025 14:02
@github-actions github-actions bot mentioned this pull request Apr 3, 2025
9 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