-
Notifications
You must be signed in to change notification settings - Fork 20
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
import.meta.url #26
Comments
One motivating use case is things like asset references through @ljharb Can you say why it's undesirable that |
For one, because I'd expect it to occasionally be used as a cache key. I don't know what I'd expect it to be in module blocks - |
Would it make sense for For example: console.log(import.meta.url); // https://example.com/index.js
let mod = module {
console.log(import.meta.url); // https://example.com/index.js#L3C10
}; (where By doing so,
This wouldn't still work for cache keys. |
Indeed nullish wouldn't work for caching, but at least it would avoid caching the wrong thing. |
@nicolo-ribaudo I like your suggestions. @ljharb Any other concerns regarding inheriting |
@surma i mean, i'm not sure what more concerns are needed besides "a URL for a resource is supposed to point to that resource" ¯_(ツ)_/¯ like duplicating an ID in the DOM, it kind of defeats the point of a uniform resource locator if it can't uniformly locate a resource. |
A bit of a tangential idea: if we made a URL pattern like There's a slight compatibility risk here, as What would people think about this direction? |
That would break at runtime whenever code is bundled, concatenated, minified, or compiled. |
Right, offset is probably not a good naming. What if, instead, the name can either be explicit (like |
On second thought, that direction might be a not-so-great one. For example, it would basically rule out defining a module block inside of |
A further problem with a form of module blocks based on strings is that it makes lifetime management more complicated. Strings, unlike objects, can be reconstructed "from scratch", so there is no reference that the lifetime of the string can be associated with. If there is a literal fragment explicitly in the JS (ruling out dynamic eval and non-parser-generated script tags), then it would be possible to re-fetch, but if we want to allow dynamic generation, you could imagine a UUID in the fragment. But then, it's not clear how long this should stay alive--unlike blobs, it would be incorrect to just let this fall out of cache. Overall, for these reasons, I think it wouldn't be viable to make it so that you can I think this issue does not block Stage 2, as it's in the scope of host environments. We should work out all of the details here by Stage 3, however. |
From the Incubator Call: We should do some research of how |
It seems very undesirable to me to have different modules result in the same import.meta.url - i see that value as the thing i can import to get the same module back. Why would it make sense to have a module block’s url match the document that contains it (but may not export it)?
The text was updated successfully, but these errors were encountered: