-
Notifications
You must be signed in to change notification settings - Fork 69
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
Reserved specifiers after import maps #101
Comments
Leaving the opportunity to extend resolution semantics is a valuable goal, but I think it makes more sense to do this based on the content of the import map so everything is still declared in the same place and under user control. For example by adding support for new forms of address, or even new top-level entries #80. (Bear in mind also FWIW that bare addresses are already reserved according to the current spec #94.) I think what you're suggesting is essentially to reserve the opportunity to prescribe new global semantics for interpreting the meaning of a specifier. But I think it's more valuable to reserve the opportunity to allow the user to declare such semantics in the import map. For any new semantics you could dream up add to reserved specifier patterns, it would also be possible to add new rules to the map such that the semantics could be expressed there. |
This sounds like a great suggestion to me. The following represents a valid package name on npm (worked out from https://github.com/npm/validate-npm-package-name, although which seems to have higher complexity rules than necessary for the cases):
I tend to disagree with the restriction to latin characters, but given this is effectively the ecosystem standard for bare specifiers currently, such a whitelist may well make said. Perhaps it would maintain specific symbols as invalid like in filenames - That way such symbols could introduce new semantics in future. |
I'm not sure we should ever introduce "un-mappable" specifiers. Given that the import maps proposal explicitly wants to allow mapping over built-in module specifiers, I can't imagine what we would want to add to the platform that cannot be mapped over. |
Here are some examples of the sorts of things that could be added to specifiers. I don't personally support any of these, just throwing out ideas. In fact, most of these are terrible ideas:
The argument simply being, we don't know what we might want in future, and reserving syntax doesn't seem like it comes at any cost. |
(and that there might be an actually good idea yet to be found...) |
Sure, but we could add any or all of those and still allow import maps to override them. There's no need to reserve or prevent import maps from working in those cases. |
Yes exactly, we would be forced to allow import maps to override any future syntax. There may be circularity issues with that since many of the above definitions assume import maps running on modules specified there. But I will rest my argument here. |
I share @guybedford's skepticism that, if we want to support these features in specifier strings, it would just work out if we don't reserve it. However, I am not really excited about defining new syntaxes within the specifier string; I think these examples would be better handled by a more complex object in JSON in the import map itself, when explaining what the string specifier translates to. The fallback list will let us add more of these over time in a graceful degradation-friendly way. |
Exactly, like I said, express it with new forms of address instead, or other additions to the map. New forms of address would compose better too, for example you wouldn't be left with the parsing problem of encountering a specifier like e.g. Which also makes me think, even if you do want to express new semantics with new syntax at the specifier use-site, why embed that syntax within the specifier string in the first place? Just add new forms of import statement. |
I'm glad, if anything, that the terrible examples managed to become a convincing argument against any syntax in the specifier :) |
For the sake of completion, there's the classic AMD/SystemJS syntax for loader plugins: import name from "plugin-package!argument-package"; This could very conveniently desugar into some top-level await form, such as: import plugin from "plugin-package";
let name = await plugin(argument-package, import.meta); |
Given the lack of movement here and in #139, I will close this. Remember that nothing prevents us from using syntax in the specifier (e.g. the AMD/SystemJS loader plugin syntax); we're just making a decision that import maps should still be able to remap strings using that syntax. That said, most people seem un-enthused about syntax in the specifier strings regardless. Personally, this together with #139 made me think maybe we should reserve something. (I.e., we had two weak reasons, plus a general caution toward choosing more restrictive defaults we can loosen later.) But there hasn't been a lot of movement in either, so I'll close. Let me know if I'm misreading. |
IIUC current reference implementation allow any string as bare specifier (except for the empty string) and thus uses up the entire space of reserved module specifiers.
Can/should we leave a chance to extend the specifier semantics again after import maps is introduced, by reserving some patterns of bare specifiers?
The text was updated successfully, but these errors were encountered: