You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>HTML Modules would provide a means of referencing HTML through the web's module system. For Web Components specifically, this would allow the usage of <code>import</code> to load and initialize the template of a custom element, much in the same way <ahref="#css-module-scripts">CSS Modules</a> would work for an <code>adoptedStyleSheet</code>.</p>
1775
+
<p>Additionally, this could open up the concept of <ahref="https://github.com/WICG/webcomponents/issues/645#issuecomment-343601237">Single File Components (SFC)</a> to the web.</p>
1773
1776
</section>
1774
1777
<section>
1775
1778
<h3>Status</h3>
1776
1779
<ul>
1777
-
<li>---</li>
1780
+
<li>Chrome (shipped, but not aligned with ESM)</li>
1778
1781
</ul>
1779
1782
</section>
1780
1783
<section>
1781
1784
<h3>Initial API Summary/Quick API Proposal</h3>
1782
-
<p>Summary or proposal based on current status; paragraph(s) and code.</p>
1785
+
<preclass="javascript">
1786
+
import template from 'my-template.html' as HTMLTemplateElement;
1787
+
1788
+
MyCustomElement extends HTMLElement {
1789
+
constructor() {
1790
+
const root = this.attachShadow({mode: 'closed'});
1791
+
root.appendChild(document.importNode(template));
1792
+
}
1793
+
}
1794
+
</pre>
1783
1795
</section>
1784
1796
<section>
1785
1797
<h3>Key Scenarios</h3>
1786
-
<p>---</p>
1798
+
<p>The primary motivation for HTML Modules is to round out ESM so that all of the three main web languages (HTML / CSS / JS) can be leveraged through a module system. For Web Components, this is especially helpful for scenarios related to Server Side Rendering or any form of templating, static or otherwise. Having a common mechanism in JavaScript to author and use Web Components makes for a great experience all around.</p>
1799
+
<p>Additionally it will work great if you prefer to separate your technologies (e.g. <em>my-component.(js|css|html)</em> ), or your (CSS|HTML)-in-JS</p> in one file.
1787
1800
</section>
1788
1801
<section>
1789
1802
<h3>Concerns</h3>
1790
1803
<ul>
1791
-
<li>---</li>
1804
+
<li>Main concern is that now that ESM and Import Assertions are a thing, it is recognized that the proposal for HTML Modules needs to be re-drafted accordingly.</li>
0 commit comments