banira
    Preparing search index...

    Function lowerHtmlImports

    • Lowers an HTML import into a module-level <template> that is parsed once, so every component instance clones it instead of re-parsing markup — the markup analog of the constructable-stylesheet lowering in lowerCssImports:

      import tpl from './card.html';
      // …in the constructor:
      root.appendChild(tpl.content.cloneNode(true));

      becomes, in the emitted module:

      const tpl = (() => { const t = document.createElement("template"); t.innerHTML = "…html…"; return t; })();
      

      The HTML file is read at compile time and inlined as a JS string literal (it is author-controlled source, like the component itself). Imports with no default binding, or whose HTML file can't be read, are left as-is.

      Parameters

      Returns TransformerFactory<SourceFile>