-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split into fetch-maps and import-maps? #211
Comments
I'm a little confused by this issue. Import maps are designed soley to handle JS module specifiers. The issue of handling only bare JS module specifiers was discussed and rejected in #198 |
My favourite feature of import-maps is the ability to "map away hashes in script filenames", but this isn't just a problem for script, it's a problem for any resource that references other resources. In previous versions, import maps proposed solving this using <script type="importmap">
{
"imports": {
"/some-script.js": "/some-script.abc123.js",
"/some-styles.css": "/some-styles.def456.css",
"/bg.png": "/bg.321cba.png"
}
}
</script>
<script>import '/some-script.js';</script>
<link rel="stylesheet" href="import:/some-styles.css"> And the CSS: html {
background: url('import:/bg.png');
} I like that this solves the problem, but it seems weird having CSS go via an import map for a background image. It feels like a more generic "fetch-map" would be less indirection. That leaves import-maps to handle the JS specific stuff. |
JS is somewhat unique in the web ecosystem in having deep dependency trees, which makes the hashes-in-filenames problem so acute there. Although in theory there can be deep dependency trees of |
Yeah, I'm just worried it might feel odd later when we realise we need to solve the same problem for non-JS things.
Sure, but as soon as one of those deep JS resources references an image, font, style, whatever, you've invalidated the tree. |
One example of a potentially common JS-refs-CSS case would be lazy loaded components that may have to reference associated styles (assuming they don't inline all styles in the JavaScript). That's where the issue becomes roughly as big as for scripts. |
The decision to limit import maps to JS specifiers seems like it might have to change if imported CSS subresources participate in the module graph (via the module-attributes proposal). If they do, I would imagine folks would expect them to also be covered by import maps. |
To be clear, any |
For some reason developers are focusing only on single side of imports, whether is JS module or css as here. In my reality I never seen cdn or release deployment comprise only few file types. In addition to binary JS, there are css and images of all kind/resolution, source maps and sources themselves, all kind of metadata... |
I'll close this as the discussion is starting to meander and this doesn't seem to bring any new points that weren't previously discussed and decided in #198. |
@jakearchibald can you dig into this a bit more? It does seem from this discussion that it would be useful to see I'm not sure where the best place would be to continue with work on this though.... a direct HTML spec PR? |
(I think generally it's good to try to gather interest for new proposals in a separate repository, issue, or WICG Discourse thread before proceeding directly to the pull request stage.) |
w.r.t. |
I've made a proposal at https://discourse.wicg.io/t/proposal-fetch-maps/4259 |
I liked the
import:
proposal, but making (for example) a CSS image go through an import map felt a little backwards.Should import-maps be design solely to handle JS module names, whereas another proposal, fetch-maps would handle general URL mapping.
This means import-maps would be mostly used for bare modules (including the prefix feature). Whereas fetch-maps would handle the hash cascade issue. In fact, you could say that import-maps only work for bare modules.
If both an import map and a fetch map existed for a client, the import map would be consulted first, then the fetch map.
This would also remove the Remapping doesn't work for
<script>
gotcha.The text was updated successfully, but these errors were encountered: