storybook: [Bug]: Support bun as a package manager

Describe the bug

Storybook supports npm, pnpm and yarn berry as package managers during installation, automigration, upgrade and startup. Adding support for Bun’s package manager would be great since it allows a wide range of users to initialize, upgrade and automigrate Storybook in repositories using Bun as the package manager.

- [x] Implement a new `BunProxy`. Take a look, how, for example, the PNPMProxy was implemented (https://github.com/storybookjs/storybook/blob/next/code/lib/core-common/src/js-package-manager/PNPMProxy.ts)
- [x] Adjust the JsPackageManagerFactory.getPackageManager to return a new BunProxy (https://github.com/storybookjs/storybook/blob/next/code/lib/core-common/src/js-package-manager/JsPackageManagerFactory.ts#L24)

Acceptance criteria

When Bun is used as a package manager, it should be possible to

  • install Storybook
  • upgrade Storybook
  • run Storybook’s automigrations
  • run and build Storybook

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 49
  • Comments: 26 (9 by maintainers)

Most upvoted comments

Hi @darklight9811

A closed issue doesn’t necessarily mean that it is already part of the latest stable release. We close issues automatically as soon as the related PR is merged. You can see here that it is part of the latest pre-release. Therefore, please try to run bunx storybook@ 8.5.0-alpha.2 init —package-manager=bun instead.

This PR actually looks pretty promising. It is a community PR which I have continued on and finalized.

I have tested:

  • init in a vue3 project
  • upgrade from 8.4.0-beta.0 to 0.0.0-pr-29267-sha-1523974d
  • add command to add a Storybook addon

Please feel free to test out the canary release: 0.0.0-pr-29267-sha-1523974d.

I have even tested running Storybook via the bun runtime, and both the dev and build commands worked successfully in a vue3 example project.

It is likely that we will introduce bun package manager support and bun runtime support in Storybook 8.5.

Please check out the PR above and try out the canary release. Let us know if things are still buggy.

@valentinpalkovic Is this still open?

Hi team, any update on this?

I only hope to use storybook under the project managed by the bun. Is there any solution to achieve this, even if it’s lame. Thanks.

@valentinpalkovic @rhuanbarreto I went ahead and created a PR that would demonstrate what i meant on the previous comment.

Could you try out

  • bun add storybook@0.0.0-pr-29267-sha-1523974d
  • bunx storybook@0.0.0-pr-29267-sha-1523974d init
  • bunx storybook/0.0.0-pr-29267-sha-1523974d init --package-manager=bun

instead?

I haven’t tried to init in an empty directory so far, but only into an existing project.

My first findings:

My fork: next...rhuanbarreto:storybook:next?expand=1 (compare)

Bun doesn’t support many json outputs for detecting package versions. Need to work more on this.

In the meantime, I think we could rely on npm info and npm list and other stuff from npm as a fallback until Bun implements this feature. What are your thoughts?

Thanks for pointing out the way! Will have a look at it tonight!