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

Open
wants to merge 10 commits into
base: next
Choose a base branch
from

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 77.8 MB 77.8 MB 0 B 1.47 0%
initSize 131 MB 131 MB -40 kB -1.01 0%
diffSize 53 MB 52.9 MB -40 kB -1.01 -0.1%
buildSize 7.19 MB 7.18 MB -6.3 kB -2.92 -0.1%
buildSbAddonsSize 1.85 MB 1.85 MB -747 B -1.02 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.87 MB 1.86 MB -4.95 kB -10.75 -0.3%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.91 MB 3.9 MB -5.7 kB -2.72 -0.1%
buildPreviewSize 3.28 MB 3.28 MB -603 B -Infinity 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 18s 13.3s -4s -648ms 0.37 -34.8%
generateTime 19s 27.5s 8.4s 5.21 🔺30.7%
initTime 12.6s 18.9s 6.3s 3.99 🔺33.3%
buildTime 11.1s 8s -3s -59ms -1.09 -37.9%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 6.8s 4.7s -2s -134ms -0.71 -44.8%
devManagerResponsive 4.5s 3.4s -1s -71ms -0.83 -30.8%
devManagerHeaderVisible 773ms 549ms -224ms -0.82 -40.8%
devManagerIndexVisible 800ms 587ms -213ms -0.71 -36.3%
devStoryVisibleUncached 3.8s 1.9s -1s -942ms -0.15 -100.2%
devStoryVisible 801ms 632ms -169ms -0.47 -26.7%
devAutodocsVisible 780ms 523ms -257ms -0.63 -49.1%
devMDXVisible 755ms 475ms -280ms -0.79 -58.9%
buildManagerHeaderVisible 716ms 536ms -180ms -0.84 -33.6%
buildManagerIndexVisible 843ms 628ms -215ms -0.76 -34.2%
buildStoryVisible 678ms 528ms -150ms -0.82 -28.4%
buildAutodocsVisible 629ms 435ms -194ms -0.94 -44.6%
buildMDXVisible 575ms 449ms -126ms -0.65 -28.1%

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
Contributor

github-actions bot commented Jan 2, 2025

Fails
🚫 PR is marked with "BREAKING CHANGE" label.
🚫

Please choose only one of these labels: ["BREAKING CHANGE","maintenance"]

Generated by 🚫 dangerJS against 2e9cfd8

Copy link

nx-cloud bot commented Jan 2, 2025

View your CI Pipeline Execution ↗ for commit 2e9cfd8.

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

☁️ Nx Cloud last updated this comment at 2025-01-03 11:11:47 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

code/lib/cli/src/core-path.ts Outdated Show resolved Hide resolved
code/lib/cli/src/index.ts Outdated Show resolved Hide resolved
@storybook-pr-benchmarking
Copy link

storybook-pr-benchmarking bot commented Jan 2, 2025

Package Benchmarks

Commit: 2e9cfd8, ran on 3 January 2025 at 11:18:16 UTC

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

storybook

Before After Difference
Dependency count 54 53 🎉 -1 🎉
Self size 22 KB 19.07 MB 🚨 +19.05 MB 🚨
Dependency size 33.51 MB 14.43 MB 🎉 -19.08 MB 🎉
Bundle Size Analyzer Link Link

sb

Before After Difference
Dependency count 55 54 🎉 -1 🎉
Self size 1 KB 1 KB 0 B
Dependency size 33.53 MB 33.50 MB 🎉 -30 KB 🎉
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 396 395 🎉 -1 🎉
Self size 496 KB 496 KB 🚨 +64 B 🚨
Dependency size 75.42 MB 75.39 MB 🎉 -30 KB 🎉
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 112 111 🎉 -1 🎉
Self size 1.11 MB 1.11 MB 0 B
Dependency size 42.64 MB 42.61 MB 🎉 -30 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING CHANGE 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