Skip to content
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
This repository was archived by the owner on Aug 27, 2026. It is now read-only.

Support for Web Components, Shadow DOM, adoptedStyleSheets #1092

Description

@fregante

Context

I want to generate a standalone component to be loaded in a shadow DOM.

It seems that this gets me most of what I need:

  • own JS chunk
  • standalone CSS chunk that includes all the CSS dependencies (sub-imports of other .css files)
import shadow from 'react-shadow';

/// partial, pseudo-code

const {Component} = await import('./Component');

return <shadow.div><Component/></shadow.div>

At this point, a Component.css file is being generated and appended to document.head.

**The problem is that this stylesheet should be inside shadow.div

Feature Proposal

I'm not sure what would be the best way to achieve this, but perhaps:

  • add a magic comment to the import() to disable the automatic injection of the stylesheet
    e.g. import(/* webpackCss: no-inject */ './Component');
  • return the URL as an additional property, so that it can be handled autonomously
    e.g. const {Component, __miniCssUrl} = await import('./Component');

Related links

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions