Skip to content

Conversation

@ndelangen
Copy link
Member

@ndelangen ndelangen commented Jun 11, 2025

What I did

Prebundle more code in the cli package

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>

Greptile Summary

Optimizes the CLI package by prebundling more dependencies and reorganizing imports, primarily focusing on Babel-related code and utilities.

  • Moves utility packages (cross-spawn, envinfo, execa, etc.) from dependencies to devDependencies in code/lib/cli-storybook/package.json to reduce production bundle size
  • Consolidates Babel imports by using storybook/internal/babel instead of direct @babel/* dependencies in multiple files
  • Removes @babel/types dependency and related packages from both CLI and codemod packages
  • Simplifies code in code/lib/codemod/src/transforms/find-implicit-spies.ts by using namespaced Babel type checks

@ndelangen ndelangen changed the title prebundle more in cli-storybook package CLI: Prebundle more in cli-storybook package Jun 11, 2025
@ndelangen ndelangen added maintenance User-facing maintenance tasks cli ci:normal labels Jun 11, 2025
@nx-cloud
Copy link

nx-cloud bot commented Jun 11, 2025

View your CI Pipeline Execution ↗ for commit ff3abbc.

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

☁️ Nx Cloud last updated this comment at 2025-06-11 13:32:50 UTC

@storybook-app-bot
Copy link

storybook-app-bot bot commented Jun 11, 2025

Package Benchmarks

Commit: ff3abbc, ran on 11 June 2025 at 13:35:21 UTC

The following packages have significant changes to their size or dependencies:

@storybook/cli

Before After Difference
Dependency count 324 216 🎉 -108 🎉
Self size 235 KB 582 KB 🚨 +347 KB 🚨
Dependency size 99.89 MB 94.66 MB 🎉 -5.22 MB 🎉
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 267 185 🎉 -82 🎉
Self size 31 KB 31 KB 🎉 -361 B 🎉
Dependency size 82.77 MB 78.74 MB 🎉 -4.03 MB 🎉
Bundle Size Analyzer Link Link

Base automatically changed from norbert/angular-bundled to next June 11, 2025 11:15
- Downgraded giget from version 2.0.0 to 1.0.0 in package.json and yarn.lock.
- Added new dependencies including [email protected], [email protected], and others in yarn.lock.
- Updated various package versions for consistency and compatibility.
@ndelangen ndelangen requested review from a team and Copilot June 11, 2025 12:57
Copy link
Contributor

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 prebundles additional code in the cli package and migrates Babel-related imports from the external '@babel/*' packages to the internal Storybook packages. The changes include migrating type and function imports in several codemod and automigrate modules and cleaning up dependency entries in package.json files.

  • Migrate Babel type and function imports in code/lib/codemod and cli-storybook packages.
  • Remove external Babel dependencies and update dependency versions in package.json files.
  • Refactor iteration over story entries in the codemod transform.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
code/lib/codemod/src/transforms/find-implicit-spies.ts Updated Babel imports and iterates over story entries using Object.values
code/lib/codemod/package.json Removed external Babel dependencies
code/lib/cli-storybook/src/automigrate/helpers/addon-a11y-parameters.ts Updated Babel import to internal package
code/lib/cli-storybook/src/automigrate/fixes/initial-globals.ts Updated type usage for Babel Expression
code/lib/cli-storybook/package.json Updated dependency versions and reorganized dependencies
Comments suppressed due to low confidence (1)

code/lib/codemod/src/transforms/find-implicit-spies.ts:108

  • [nitpick] Changing from Object.entries to Object.values is valid if the key is not needed; please confirm that discarding the key does not affect behavior in other parts of the code.
Object.values(csf.stories).forEach(({ name }) => {

@ndelangen ndelangen requested a review from yannbf June 11, 2025 13:01
@ndelangen ndelangen self-assigned this Jun 11, 2025
@ndelangen ndelangen marked this pull request as ready for review June 11, 2025 13:10
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

5 files reviewed, no comments
Edit PR Review Bot Settings | Greptile

@ndelangen ndelangen merged commit ad8a398 into next Jun 11, 2025
57 checks passed
@ndelangen ndelangen deleted the norbert/prebundle-esm-in-cli branch June 11, 2025 13:54
@github-actions github-actions bot mentioned this pull request Jun 11, 2025
71 tasks
@JReinhold JReinhold added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Jun 26, 2025
@github-actions github-actions bot mentioned this pull request Jun 26, 2025
8 tasks
ghengeveld pushed a commit that referenced this pull request Jun 27, 2025
CLI: Prebundle more in cli-storybook package
(cherry picked from commit ad8a398)
@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:normal cli maintenance User-facing maintenance tasks patch:done Patch/release PRs already cherry-picked to main/release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants