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

Maintenance: Merge @storybook/core with storybook #30168

Merged
merged 33 commits into from
Feb 26, 2025
Merged

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Jan 2, 2025

What I did

This is a proposal of how we could merge the lib/cli and core package into 1.

This PR is a WIP.

  • remove lib/cli
  • rename core's package.json's name-field to storybook
  • deal with the rename (all references to @storybook/core should now become storybook/internal

I am optimistic that this won't be too breaking for end-users, though it would make sense to release this as part of 9.0, when we also remove the shim packages.

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 79.7 MB 79.7 MB 0 B -0.88 0%
initSize 79.7 MB 79.7 MB 0 B -0.88 0%
diffSize 97 B 97 B 0 B - 0%
buildSize 7.32 MB 7.31 MB -6.35 kB 0.45 -0.1%
buildSbAddonsSize 1.88 MB 1.9 MB 16.1 kB 0.43 0.8%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.9 MB 1.89 MB -15.5 kB 0.58 -0.8%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.98 MB 3.98 MB 612 B 2.34 0%
buildPreviewSize 3.34 MB 3.33 MB -6.96 kB -0.17 -0.2%
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 24.9s 14s -10s -890ms 0.02 -77.4%
generateTime 18.8s 19.9s 1s -0.13 5.4%
initTime 4.5s 4.5s -13ms -0.54 -0.3%
buildTime 10.3s 9.2s -1s -70ms -0.31 -11.5%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.6s 5.8s 200ms 0.88 3.4%
devManagerResponsive 5.4s 5.5s 143ms 0.75 2.6%
devManagerHeaderVisible 896ms 1s 196ms 2.4 🔺17.9%
devManagerIndexVisible 971ms 1.1s 165ms 2.25 🔺14.5%
devStoryVisibleUncached 1.9s 2.5s 558ms 1.98 🔺22.3%
devStoryVisible 992ms 1.1s 142ms 2.04 🔺12.5%
devAutodocsVisible 860ms 1s 159ms 2.4 🔺15.6%
devMDXVisible 876ms 900ms 24ms 1.2 2.7%
buildManagerHeaderVisible 804ms 1.1s 299ms 2.24 🔺27.1%
buildManagerIndexVisible 894ms 1.1s 235ms 1.83 🔺20.8%
buildStoryVisible 757ms 950ms 193ms 1.41 🔺20.3%
buildAutodocsVisible 685ms 755ms 70ms 0.85 9.3%
buildMDXVisible 568ms 901ms 333ms 2.89 🔺37%

Greptile Summary

This PR proposes a significant architectural change to merge the lib/cli and core packages into a single package named storybook, with core functionality accessed through storybook/internal.

  • Renames @storybook/core to storybook and moves all core functionality under storybook/internal/* paths
  • Updates hundreds of import paths across the codebase from @storybook/core/* to storybook/internal/*
  • Renames existing lib/cli package from storybook to storybook-renamed to avoid conflicts
  • Adds new CLI entry point in code/core/bin/index.cjs with Node.js version check and error handling
  • Removes @storybook/core dependencies and updates package resolutions to point to the new unified package

The changes are extensive but focused on package organization and import paths, with minimal functional changes. This is planned for Storybook 9.0 release.

@ndelangen ndelangen added maintenance User-facing maintenance tasks BREAKING CHANGE core ci:daily Run the CI jobs that normally run in the daily job. labels Jan 2, 2025
@ndelangen ndelangen self-assigned this Jan 2, 2025
@ndelangen ndelangen requested a review from kasperpeulen January 2, 2025 13:47
Copy link

nx-cloud bot commented Jan 2, 2025

View your CI Pipeline Execution ↗ for commit bf12d25.

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

☁️ Nx Cloud last updated this comment at 2025-02-26 16:34:42 UTC

@ndelangen ndelangen added ci:daily Run the CI jobs that normally run in the daily job. and removed ci:daily Run the CI jobs that normally run in the daily job. labels Jan 2, 2025
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.

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

);
}

throw error;
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Re-throwing error prevents proper error reporting to users. Consider handling the error gracefully instead of throwing

Comment on lines +16 to +21
child.on('exit', (code) => {
if (code != null) {
process.exit(code);
}
process.exit(1);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: The exit handler will always call process.exit(1) after the conditional exit, which means non-zero exit codes will work but zero (success) codes will still exit with 1

})
);
});
});

describe('removeDependencies', () => {
it('with devDep it should run `npm uninstall @storybook/core`', async () => {
it('with devDep it should run `npm uninstall storybook`', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: test description mentions 'npm uninstall' but is testing PNPM's remove command

@@ -25,7 +25,7 @@ vi.mock('@storybook/global', () => ({
},
}));

vi.mock('@storybook/core/client-logger');
vi.mock('storybook/internal/client-logger');
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Duplicate mock declaration - this same mock appears again on line 49

Comment on lines 17 to +19
'storybook/internal/core-errors': '__STORYBOOK_CORE_EVENTS__',
'@storybook/core-events': '__STORYBOOK_CORE_EVENTS__',
'@storybook/core/core-events': '__STORYBOOK_CORE_EVENTS__',
'storybook/internal/core-events': '__STORYBOOK_CORE_EVENTS__',
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: duplicate mapping for core-events - both 'storybook/internal/core-errors' and 'storybook/internal/core-events' map to 'STORYBOOK_CORE_EVENTS'

Comment on lines 44 to +46
'storybook/internal/core-errors': EVENTS,
'@storybook/core-events': EVENTS,
'@storybook/core/core-events': EVENTS,
'storybook/internal/core-events': EVENTS,
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: inconsistent naming - 'core-errors' vs 'core-events' for same EVENTS module

Comment on lines +28 to 33
vi.mock('storybook/internal/channels', async (importOriginal) => {
return {
...(await importOriginal<typeof import('@storybook/core/channels')>()),
...(await importOriginal<typeof import('storybook/internal/channels')>()),
createBrowserChannel: () => mockChannel,
};
});
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: duplicate mock definition - this mock is defined again on lines 46-51

@@ -1,6 +1,6 @@
// FIXME: breaks builder-vite, remove this in 7.0
Copy link
Contributor

Choose a reason for hiding this comment

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

style: this FIXME comment references version 7.0 but should be updated since this is targeting version 9.0

@storybook-pr-benchmarking
Copy link

storybook-pr-benchmarking bot commented Jan 2, 2025

Package Benchmarks

Commit: bf12d25, ran on 26 February 2025 at 16:38:37 UTC

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

@storybook/addon-controls

Before After Difference
Dependency count 3 3 0
Self size 257 KB 268 KB 🚨 +11 KB 🚨
Dependency size 47 KB 47 KB 0 B
Bundle Size Analyzer Link Link

@storybook/addon-docs

Before After Difference
Dependency count 13 13 0
Self size 2.76 MB 2.27 MB 🎉 -492 KB 🎉
Dependency size 9.44 MB 9.43 MB 🎉 -13 KB 🎉
Bundle Size Analyzer Link Link

@storybook/addon-essentials

Before After Difference
Dependency count 32 32 0
Self size 18 KB 18 KB 0 B
Dependency size 16.04 MB 15.54 MB 🎉 -494 KB 🎉
Bundle Size Analyzer Link Link

storybook

Before After Difference
Dependency count 53 52 🎉 -1 🎉
Self size 23 KB 19.41 MB 🚨 +19.39 MB 🚨
Dependency size 33.70 MB 14.26 MB 🎉 -19.44 MB 🎉
Bundle Size Analyzer Link Link

@storybook/blocks

Before After Difference
Dependency count 2 2 0
Self size 639 KB 626 KB 🎉 -13 KB 🎉
Dependency size 1.28 MB 1.28 MB 0 B
Bundle Size Analyzer Link Link

sb

Before After Difference
Dependency count 54 53 🎉 -1 🎉
Self size 1 KB 1 KB 0 B
Dependency size 33.72 MB 33.67 MB 🎉 -52 KB 🎉
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 358 357 🎉 -1 🎉
Self size 278 KB 278 KB 🚨 +5 B 🚨
Dependency size 84.21 MB 84.15 MB 🎉 -59 KB 🎉
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 275 275 0
Self size 622 KB 617 KB 🎉 -5 KB 🎉
Dependency size 65.77 MB 65.74 MB 🎉 -29 KB 🎉
Bundle Size Analyzer Link Link

@ndelangen ndelangen requested a review from JReinhold January 3, 2025 13:07
@ndelangen
Copy link
Member Author

@kasperpeulen I'd love your thoughts on this approach, and how viable you see this PR as "done" for 9.0 release.

@JReinhold Perhaps you could also have a look into this and see if there's something additional you'd want to do...
@shilman mentioned you had some plan to split some parts of the CLI, and that perhaps that should be part of a single PR.

Copy link
Contributor

@kasperpeulen kasperpeulen left a comment

Choose a reason for hiding this comment

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

LGTM

@ndelangen ndelangen merged commit 9c2fc39 into next Feb 26, 2025
106 checks passed
@ndelangen ndelangen deleted the norbert/merge-core-cli branch February 26, 2025 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:daily Run the CI jobs that normally run in the daily job. core maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants