Skip to content

[Bug]: lit-html is loaded twice #31507

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

Open
jpzwarte opened this issue May 19, 2025 · 2 comments
Open

[Bug]: lit-html is loaded twice #31507

jpzwarte opened this issue May 19, 2025 · 2 comments

Comments

@jpzwarte
Copy link
Member

Describe the bug

Image

As of Storybook 9 (using rc.0 atm), i've noticed the following console error:

lit-html.ts:226 Multiple versions of Lit loaded. Loading multiple versions is not recommended. See https://lit.dev/msg/multiple-versions for more information.

I traced this to lit-html being loaded twice: once by storybook itself, and once because we use Lit for our web components.

@shilman Perhaps consider not bundling lit-html with Storybook and instead make it a peerDependency?

Reproduction link

http://localhost:6006/?path=/story/actions-button--basic

Reproduction steps

lit-html only outputs the warning when in dev mode, so i can't link to our production storybook.

System

Storybook Environment Info:

  System:
    OS: macOS 15.5
    CPU: (16) arm64 Apple M4 Max
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.15.1 - /opt/homebrew/bin/node
    Yarn: 4.8.1 - /opt/homebrew/bin/yarn <----- active
    npm: 10.9.2 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 136.0.7103.114
    Safari: 18.5
  npmPackages:
    @storybook/addon-a11y: ^9.0.0-rc.0 => 9.0.0-rc.0 
    @storybook/addon-docs: ^9.0.0-rc.0 => 9.0.0-rc.0 
    @storybook/web-components-vite: ^9.0.0-rc.0 => 9.0.0-rc.0 
    chromatic: ^11.28.2 => 11.28.2 
    storybook: ^9.0.0-rc.0 => 9.0.0-rc.0

Additional context

No response

Copy link
Contributor

greptile-apps bot commented May 19, 2025

** Disclaimer** This information might be inaccurate, due to it being generated automatically
This issue can be resolved by making lit-html a peer dependency in Storybook's web-components framework package. Changes needed: 1. In code/frameworks/web-components-vite/package.json, move lit-html from dependencies to peerDependencies 2. Update the version range to match Lit's recommended version: "lit-html": "^2.0.0" 3. Add lit-html to peerDependenciesMeta as optional: json "peerDependenciesMeta": { "lit-html": { "optional": true } } This will allow projects to use their own version of lit-html without conflicts with Storybook's bundled version.

About Greptile

This response provides a starting point for your research, not a precise solution.

Help us improve! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

Edit Issue Bot Settings · Greptile

@shilman
Copy link
Member

shilman commented May 19, 2025

AFAIK there have been no changes to the framework in SB9, so this is likely an existing an issue. Have you tried yarn dedupe as a workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants