-
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
This doesn't entirely solve the url resolution relative to a module problem #75
Comments
Thanks for raising this! Your logic seems sound, which is bad news for Note that as currently envisioned you could get around this by forcing the parsing to happen in someFile.js, e.g. by doing Note that this problem is deeper than just the I'm not sure we can salvage this, although maybe myself or someone else will come up with a brilliant idea. At this point the only intermediate step that comes to mind, besides removing This still solves some of the very basic use cases, around e.g. :( |
Cross-linking to original |
Continuing my thinking out loud... One of the main reasons the OP is troubling is that it means that built-in platform features (like This falls out of the current proto-spec's use of "active script". Inside the implementation of At the cost of additional complexity, one could imagine trying to fix this by some mechanism to say "don't consider me a script for the purposes of |
What about an API to reify an object to represent the url, with context-sensitive data stored in an unobservable internal slot? I suppose it would be the same as “new url”, ergonomically, but it might afford more flexibility than forcing full inline resolution? |
Yeah, I don't see that as being any better than |
As long as there is an explicit API like In JS it feels more confusing than useful to have call-site specific behavior outside of syntax. And yet-another syntax using the |
To take a stab at the ergonomics issue: might URL`import:foo` possibly be nicer than |
I don't understand the defeatism about this, an extra That said, can we set out a clearer view of the solution space? We're talking about a situation where a user of an API is calling into a library, only to discover that the URL string they passed in is not getting resolved as they expected. There are broadly two ways to approach this: Put the responsibility on the user to force early resolution, via e.g.
Put the responsibility on the library author by e.g. asking them to explicitly resolve relative to the caller.
But the choice isn't actually so stark, there's a gradual migration path. We can enable library authors to do the extra work to ensure their API is more convenient and consistent with built-ins, but we don't have to force them to, as users aren't exactly left stuck if library authors fail to adapt quickly. The user can always force resolution at the use-site if they need to. Given enough time we can expect the ecosystem to adapt enough that the user rarely has to worry. As for how each approach might look in practice, there are a few obvious choices, most of which have already been mentioned. User responsibility:
Library responsibility:
Is this really so terrible? |
Potentially relevant: https://github.com/sebmarkbage/ecmascript-asset-references contains a suggestion of |
FYI whatwg/html#3871 is the version currently being considered for implementation. ( |
Is there a proposed solution for HTML and CSS? Maybe you could still permit |
Right, my comment at #75 (comment) briefly talks about how we could salvage something for HTML and CSS. @justinfagnani brought up the interesting point that we could maybe still use "the current file's URL" in those cases. By which I mean:
|
Yeah, my original request for this feature was to be able to access cross- and internal-package resources from within CSS and HTML, where presumably the unresolved I don't think it's necessary in JS. Internal-package URLs can be created with Code that's consuming URLs from markup/CSS might need to resolve |
In the explainer it says that
import:
can be used as a solution to this issue however it really just moves the problem a step higher.While simple examples like
fetch('import:./blah.txt')
ornew Worker('import:./blah.js')
would work we still have the issue of abstractions over those primitives e.g.:In this case any
import:
url we use withTasklet
will be resolved relative to theTasklet.js
file rather thansomeFile.js
which isn't very useful, we'd still need aresolve
-like function in this case to resolve it correctly (e.g.new Tasklet(import.meta.resolve('./foo.js'))
ornew Tasklet(import.meta.resolve('import:some-helper-lib'))
.The text was updated successfully, but these errors were encountered: