Skip to content

Vite: Fix pnpm support by replacing @storybook/global with window#22709

Merged
shilman merged 1 commit into
nextfrom
vite/global-window
May 24, 2023
Merged

Vite: Fix pnpm support by replacing @storybook/global with window#22709
shilman merged 1 commit into
nextfrom
vite/global-window

Conversation

@IanVS
Copy link
Copy Markdown
Member

@IanVS IanVS commented May 23, 2023

Closes #22695

What I did

If we want to use @storybook/global in a virtual module in the vite builder, we'd need to add it to the runtime bundle in order to support pnpm users. Since this is purely preview code, though, we can just use window and avoid the dep entirely.

How to test

Create a pnpm project, add storybook, swap in this change, confirm that stories load. I did that in my own pnpm project and it works well now on 7.0.15.

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@shilman shilman changed the title Vite: replace @storybook/global with window Vite: Fix pnpm support by replacing @storybook/global with window May 24, 2023
@shilman shilman merged commit 3eb2d74 into next May 24, 2023
@shilman shilman deleted the vite/global-window branch May 24, 2023 00:07
@shilman shilman added the patch:yes Bugfix & documentation PR that need to be picked to main branch label May 24, 2023
shilman added a commit that referenced this pull request May 24, 2023
Vite: Fix pnpm support by replacing @storybook/global with `window`
@shilman shilman mentioned this pull request May 24, 2023
@shilman shilman added the patch:done Patch/release PRs already cherry-picked to main/release branch label May 26, 2023
@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 builder-vite patch:done Patch/release PRs already cherry-picked to main/release branch pnpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: PNPM/Vite Failed to resolve import "@storybook/global"

3 participants