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

CPC: Core Package Consolidation #27039

Merged
merged 365 commits into from
Jul 1, 2024
Merged

CPC: Core Package Consolidation #27039

merged 365 commits into from
Jul 1, 2024

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented May 6, 2024

Relates to #27209

What

This PR tries to solve a variety of very complex & large problems in the storybook ecosystem:

  • package bloat, where storybook will install a large number of packages
    • installing storybook takes a long time
    • adding storybook to a project can decrease CI performance
  • hoisting issues, where storybook installs many version of itself
    • storybook is comprised of many packages that depend on each other, it's easy to get into a situation where multiple versions are installed, causing hoisting problems, and magnifying the "package bloat" problem.
  • maintenance complexity/burdon
    • share utilities/code is done through packages, but each package must be compiled
    • packages need to be published & version bumped
    • All this takes time on our local machine, and in our CI
    • packages are usually compiled with a specific target (node | browser), limiting their re-use in the other target.
  • public/private APIs
    • Due to how many packages exist it's not easy to know what is actually internal & public of our APIs.

How

How this PR achieves to solve these problem is by consolidating the storybook core packages into a singular package called @storybook/core.

The packages that are to be consolidated:

  • @storybook/channels
  • @storybook/client-logger
  • @storybook/core-common
  • @storybook/core-events
  • @storybook/csf-tools
  • @storybook/docs-tools
  • @storybook/node-logger
  • @storybook/preview-api
  • @storybook/router
  • @storybook/telemetry
  • @storybook/theming
  • @storybook/types
  • @storybook/manager-api
  • @storybook/manager
  • @storybook/preview
  • @storybook/core-server
  • @storybook/builder-manager
  • @storybook/components

However, the @storybook/core package is never directly used by storybook consumers.
Every usage of the consolidated packages inside the storybook monorepo have been remapped to the storybook package.

The storybook package (previously just a shim for @storybook/cli) has been given a range of extra exports (in the package.json exports field) so every entrypoint of @storybook/core is accessible through the storybook package.

This was a deliberate choice because of the following:

How every package in the storybook ecosystem has a peerDependency on the storybook package.

Backwards compatible

We deem this to NOT be a breaking change, because the storybook package has been a required package to have in your package.json since storybook 7.0.
Additionally, the package/dependency structure was already shaky, and this should improve the situation for the vast majority of users, though the possibility of users getting a broken storybook when upgrading cannot be eliminated completely.

The consolidated packages will still be published at least until storybook 9.0. They will contain no code, but will have a peerDependency on the storybook package, and simply re-exports a sub-export. We call these shim packages.
The code for these packages is still in the monorepo, in the deprecated directory.

Community addons

We've decided to not push this change to addon authors yet.

We want to try this new architecture for a while ourselves, work out any potential issues, before we commit to making this new architecture truly public facing with documentation.

We will do that work before 9.0; including improving the addon-kit, as well as update the addon creation documentation.

Community addons should continue to work, though there will likely be missing peerDependency warnings.

Addon authors could already start adding the storybook package as a peerDependency in their package.json, of the major version of storybook they have tested their addon with.

CPC in 2 images

Screenshot 2024-06-25 at 15 19 31 Screenshot 2024-06-25 at 15 19 45

We plan to later improve further, and consolidate the storybook and @storybook/core packages together:

Screenshot 2024-06-25 at 15 19 52

🦋 Canary release

This pull request has been released as version 0.0.0-pr-27039-sha-fbc11962. Try it out in a new sandbox by running npx storybook@0.0.0-pr-27039-sha-fbc11962 sandbox or in an existing project with npx storybook@0.0.0-pr-27039-sha-fbc11962 upgrade.

More information
Published version 0.0.0-pr-27039-sha-fbc11962
Triggered by @ndelangen
Repository storybookjs/storybook
Branch norbert/cpc
Commit fbc11962
Datetime Fri Jun 28 16:58:31 UTC 2024 (1719593911)
Workflow run 9716240992

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

@ndelangen ndelangen self-assigned this May 6, 2024
Copy link

nx-cloud bot commented May 7, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 1aec38d. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@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 Jun 28, 2024
@storybookjs storybookjs deleted a comment from storybook-bot Jun 28, 2024
@ndelangen ndelangen merged commit 56f188a into next Jul 1, 2024
104 checks passed
@ndelangen ndelangen deleted the norbert/cpc branch July 1, 2024 11:14
@yk-kd yk-kd mentioned this pull request Jul 1, 2024
8 tasks
@ndelangen ndelangen mentioned this pull request Jul 29, 2024
8 tasks
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 dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tracking] Core package consolidation
7 participants