Skip to content

Module-import side effects: CSS injected into host page even when component never mounts #12

Description

@raimannma

Tracked from upstream issue benjitaylor#186.

Type: bug • Severity: medium

Assessment

Confirmed present in the fork: package/tsup.config.ts's scssModulesPlugin still emits a top-level if (typeof document !== 'undefined') { document.head.appendChild(style) } IIFE per .scss, and src/components/page-toolbar-css/index.tsx calls injectAgentationColorTokens() at module top level (line 227), while package.json declares "sideEffects": false — so a bare import { Agentation } leaks ~10 style tags into the host head even when the component never mounts (freeze-animations.ts also monkey-patches timers at import time). No open PR implements the proposed lazy-injection fix: benjitaylor#169 is a much larger shadow-DOM superset (still open/undecided) and benjitaylor#185 only scopes the design-mode svg rule. The fix is well-understood with a working prototype but spans ~15 files (+130/-65), changes the build plugin and adds a ref-counted lifecycle hook called in 12 components, and overlaps with the in-flight benjitaylor#169/benjitaylor#174 decision — so it's architectural rather than a small low-risk patch.

Upstream: benjitaylor#186

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupstream-trackedTracked from unmaintained upstream

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions