Skip to content

CLI: Fix sb CLI by explicitly exporting bin/index.cjs from storybook package#31922

Merged
ghengeveld merged 2 commits into
nextfrom
export-storybook-bin-index.cjs
Jul 1, 2025
Merged

CLI: Fix sb CLI by explicitly exporting bin/index.cjs from storybook package#31922
ghengeveld merged 2 commits into
nextfrom
export-storybook-bin-index.cjs

Conversation

@ghengeveld
Copy link
Copy Markdown
Member

@ghengeveld ghengeveld commented Jul 1, 2025

Closes #31807

What I did

Added an entry for ./bin/index.cjs to the exports map for the storybook package so that require('storybook/bin/index.cjs') does not throw ERR_PACKAGE_PATH_NOT_EXPORTED.

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-31922-sha-01fa8b2d. Try it out in a new sandbox by running npx storybook@0.0.0-pr-31922-sha-01fa8b2d sandbox or in an existing project with npx storybook@0.0.0-pr-31922-sha-01fa8b2d upgrade.

More information
Published version 0.0.0-pr-31922-sha-01fa8b2d
Triggered by @ghengeveld
Repository storybookjs/storybook
Branch export-storybook-bin-index.cjs
Commit 01fa8b2d
Datetime Tue Jul 1 15:58:11 UTC 2025 (1751385491)
Workflow run 16004313012

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=31922

Greptile Summary

Fixed the Storybook CLI (sb) by adding ./bin/index.cjs to the package exports map, resolving the ERR_PACKAGE_PATH_NOT_EXPORTED error when running CLI commands like npx sb@latest upgrade.

  • Added explicit export mapping for ./bin/index.cjs in code/core/package.json
  • Ensures proper binary entrypoint accessibility following Node.js package exports rules
  • Maintains compatibility with both CommonJS (require()) and ESM import patterns
  • Fixes critical CLI functionality that was previously broken for end users

@ghengeveld ghengeveld requested a review from ndelangen July 1, 2025 15:20
@ghengeveld ghengeveld added bug cli patch:yes Bugfix & documentation PR that need to be picked to main branch ci:normal labels Jul 1, 2025
Copy link
Copy Markdown
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 reviewed, no comments
Edit PR Review Bot Settings | Greptile

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jul 1, 2025

View your CI Pipeline Execution ↗ for commit 01fa8b2.

Command Status Duration Result
nx run-many -t check -c production --parallel=7 ✅ Succeeded 1s View ↗
nx run-many -t build -c production --parallel=3 ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2025-07-02 13:59:11 UTC

@ghengeveld ghengeveld enabled auto-merge July 1, 2025 18:11
@ghengeveld ghengeveld merged commit 06c6056 into next Jul 1, 2025
58 of 59 checks passed
@ghengeveld ghengeveld deleted the export-storybook-bin-index.cjs branch July 1, 2025 18:24
@ghengeveld ghengeveld restored the export-storybook-bin-index.cjs branch July 2, 2025 13:55
@storybook-app-bot
Copy link
Copy Markdown

Package Benchmarks

Commit: 01fa8b2, ran on 2 July 2025 at 14:03:26 UTC

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

storybook

Before After Difference
Dependency count 51 51 0
Self size 31.75 MB 31.73 MB 🎉 -19 KB 🎉
Dependency size 17.43 MB 17.43 MB 0 B
Bundle Size Analyzer Link Link

@storybook/nextjs

Before After Difference
Dependency count 536 537 🚨 +1 🚨
Self size 903 KB 903 KB 0 B
Dependency size 58.92 MB 58.97 MB 🚨 +49 KB 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs-vite

Before After Difference
Dependency count 130 130 0
Self size 3.08 MB 3.08 MB 0 B
Dependency size 22.25 MB 22.27 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-native-web-vite

Before After Difference
Dependency count 161 161 0
Self size 35 KB 35 KB 🎉 -129 B 🎉
Dependency size 23.26 MB 23.28 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-vite

Before After Difference
Dependency count 120 120 0
Self size 32 KB 32 KB 0 B
Dependency size 20.20 MB 20.22 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-webpack5

Before After Difference
Dependency count 285 285 0
Self size 25 KB 25 KB 0 B
Dependency size 43.52 MB 43.53 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@storybook/vue3-vite

Before After Difference
Dependency count 104 104 0
Self size 34 KB 34 KB 0 B
Dependency size 42.70 MB 42.73 MB 🚨 +32 KB 🚨
Bundle Size Analyzer Link Link

sb

Before After Difference
Dependency count 52 52 0
Self size 1 KB 1 KB 0 B
Dependency size 49.18 MB 49.16 MB 🎉 -19 KB 🎉
Bundle Size Analyzer Link Link

@storybook/preset-react-webpack

Before After Difference
Dependency count 176 176 0
Self size 24 KB 24 KB 0 B
Dependency size 30.35 MB 30.36 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

ghengeveld added a commit that referenced this pull request Jul 8, 2025
….cjs

CLI: Fix `sb` CLI by explicitly exporting `bin/index.cjs` from `storybook` package
(cherry picked from commit 06c6056)
@github-actions github-actions Bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Jul 8, 2025
@ndelangen ndelangen removed the patch:yes Bugfix & documentation PR that need to be picked to main branch label Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug ci:normal cli 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.

[Bug]: cannot run npx sb@latest upgrade

2 participants