- From: James Browning <notifications@github.com>
- Date: Fri, 10 May 2024 22:28:44 -0700
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <WICG/webcomponents/issues/1059/2105569211@github.com>
> I think this might be a reason to not use fragments in the imports. Though maybe when you import from JS, the fragments just reference exports? Fragments already have existing behaviour with JS imports, in particular they trigger multiple evaluations (without triggering multiple fetches compared to using query params): ```js // mod.js console.log(import.meta.url); ``` ```js await import("./mod.js#one"); // Prints BASEURL/mod.js#one await import("./mod.js#two"); // Prints BASEURL/mod.js#two ``` I think it would be preferable to have consistent behaviour rather than special casing import behaviour inside HTML. It'd probably be best if `#` triggered individual module evaluations for HTML modules well. --- One problem that needs to be resolved is how to handle [import attributes](https://github.com/tc39/proposal-import-attributes), in JS import attributes are **required** to import non-JS things like CSS. There's not really anyway to avoid these in HTML either as they define headers and the request type for the associated fetch. It does seem cumbersome to have to specify with attributes in many cases though, if we import per element kind as suggested by @justinfagnani then we could have defaults: ```html <!-- default behaviour imports the default import with attributes { type: "css" }--> <style src="./path-to-css-module.css"></style> <!-- importname and type can be customized with attributes --> <style src"./path-to-js-module.js" import="cssSheet" importtype="js"></style> <style src="./path-to-html-module.html" import="cssSheet" importtype="html"></style> ``` -- Reply to this email directly or view it on GitHub: https://github.com/WICG/webcomponents/issues/1059#issuecomment-2105569211 You are receiving this because you are subscribed to this thread. Message ID: <WICG/webcomponents/issues/1059/2105569211@github.com>
Received on Saturday, 11 May 2024 05:28:48 UTC