banira
    Preparing search index...

    Function lowerCssImports

    • Lowers a CSS import into a shared, deduped constructable stylesheet so every component instance — and every module — shares one parse instead of an inline <style>:

      import styles from './styles.css';              // #9: bare CSS import
      import sheet from './styles.css' with { type: 'css' }; // #10: CSS Module Script syntax

      become, in the emitted module:

      const __baniraAdoptStyles = (css) => { … cache on globalThis … };
      const styles = __baniraAdoptStyles("…css…");

      The binding is module-level (all instances that adoptedStyleSheets = [styles] share the one sheet), and the helper's cache lives on globalThis keyed by the CSS text, so two different modules importing the same stylesheet adopt the same CSSStyleSheet — the documented adoptedStyleSheets dedupe win. adoptedStyleSheets is Baseline widely available; the CSS Module Script with { type: 'css' } syntax is not (Safari), which is why even the standard form is shimmed here.

      Imports with no default binding, or whose CSS file can't be read, are left as-is.

      Parameters

      Returns TransformerFactory<SourceFile>