-
Notifications
You must be signed in to change notification settings - Fork 14
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
The Great Sigil Lottery #41
Comments
|
I'd prefer option 1, and force internals to be imported with relative paths (as opposed to with
do you mean to include the # here? |
Yes, I think using a separate sigil for "internal alias" and "this package's public interface" makes sense. But I could also see myself interpreting |
I prefer to limit ourselves to as little magic as possible :-) |
I've found myself thinking perhaps we shouldn't restrict private names to include a special symbol prefix. The reason for this is that there may be cases where a user wishes to be able to use existing code that has a bare specifier import, and they want full control over its resolution locally. For example, I might have a lot of legacy code that references Since import maps provide the flexibility to do this, it feels to me like allowing the flexibility for users to do this as well may be very beneficial, and the restriction to a special character prefix would feel unnecessarily constraining. |
Along those lines, I’d like to consider how we could align with the import maps proposal more generally. Like, is there any version of Node’s import maps implementation where Node can support a Web-style import map as is? Maybe if all paths are relative? It would be nice to say that Node simply supports import maps, or a subset of import maps that are compatible between Node and browsers, rather than Node supporting a separate thing that’s a lot like browser import maps but not interchangeable. |
Considering browser import maps are far from finalized, that may not be too useful at this stage. |
@GeoffreyBooth I think supporting import maps natively is absolutely worth doing. But we do try to make node work with minimal tooling. Only supporting import maps would make it effectively impossible to use dependencies in ESM without a tool writing an import map. For me @guybedford I agree. It may be worth calling out the pro/cons for having a sigil for
Let me know if I forgot arguments either way. And of course, quantity of bullet points in either direction isn't the thing that counts. |
Forked from #40 (comment).
We have three kinds of specifiers that people have asked for (implied: that we may or may not want to support):
exports
do not apply to relative specifiers). Examples:✩
(the main/default export),✩/subpath
✩data/emoji.json
,✩fetch
.✩/src/model.mjs
.Of these, only (1) and (3) actually conflict. (2) could share a symbol with either one of them. A concern raised by @guybedford was that if (1) and (2) share a symbol, it may be confusing.
So to me the options are:
~
and~/
to mean "this package as if it was imported by name".~<name>
to be used for custom aliases within the package.~
and ~/` to mean "this package as if it was imported by name".#<name>
for "private names", aliases only visible inside of the package.#/
for "paths relative to the package boundary".For packages that don't use
exports
,~/
and#/
are effectively the same but that would change once they choose to remap subpaths and/or lock themselves down.My preference right now would be ~ + # without support for importing non-public paths relative to the project root. There would still be design space for adding #/ in the future if it becomes truly necessary. Both
~
and#
can be used as specifier prefixes since ESM only recognizes./
,../
, and/
as valid relative URLs.The text was updated successfully, but these errors were encountered: