Skip to content

An exception is thrown when using createShadowRootUi, but it does not affect the functionality. #2162

@ggymzz

Description

@ggymzz

Describe the bug

https://wxt.dev/guide/resources/faq.html#my-component-library-doesn-t-work-in-content-scripts
`import { StyleProvider } from '@ant-design/cssinjs';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';

const ui = await createShadowRootUi(ctx, {
// ...
onMount: (container, shadow) => {
const cssContainer = shadow.querySelector('head')!;
const root = ReactDOM.createRoot(container);
root.render(


,
);
return root;
},
});`
[wxt] Failed to load styles @ chrome-extension://hjciipegaogklkbaphcleocmajmpnpjk/content-scripts/content.css. Did you forget to import the stylesheet in your entrypoint? TypeError: Failed to fetch
at loadCss (shadow-root.mjs:72:23)
at createShadowRootUi (shadow-root.mjs:22:26)
at main (index.tsx:13:5)

Reproduction

My component library doesn't work in content scripts
This is usually caused by one of two things (or both) when using createShadowRootUi:

Styles are added outside the ShadowRoot ...

Steps to reproduce

No response

System Info

examples/react-content-script-ui  win11 edge

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending-triageSomeone (usually a maintainer) needs to look into this to see if it's a bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions