-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Ambiguous steps in PACKAGE_IMPORTS_EXPORTS_RESOLVE
reference documentation
#53206
Comments
@nodejs/loaders (BTW 1 & 2 return the same result) |
I figured that as well after writing it. 😅 Still, there is some ambiguity here, since it could also be interpreted as (3). |
I personally don’t find it confusing (we’re talking about the key, that would make little sense to involve the value at this point), and even if you misinterpret it, it wouldn’t be too bad because the value would also typically contain a single |
Fair enough. But if it's the case that the key always contains a single "*", the reference of |
Let me rephrase that: value associated with keys that contains a single Example of a valid {
"exports": {
"./someKey/noStar": "./someFile.mjs",
"./somePatternKey/*": "./someDir/*.mjs"
}
} |
I understand that some keys don't have a "*", but the reference for
So I assume an implementation for this in JS could be: const expansionKeys = Object.keys(matchObj).filter(key => count(key, "*") === 1); After which Object.keys(matchObj)
.filter(key => count(key, "*") === 1)
.sort(PATTERN_KEY_COMPARE); // The keys here always contain a "*" |
Ah I see, sorry for the misunderstanding! I think that's a relic from a time where there was another another way to define subpath patterns which was removed in #40121, and I guess |
Opened a PR here: #53215. |
PR-URL: nodejs#53215 Fixes: nodejs#53206 Refs: nodejs#40121 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
PR-URL: nodejs#53215 Fixes: nodejs#53206 Refs: nodejs#40121 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
Affected URL(s)
https://nodejs.org/api/esm.html#resolution-algorithm-specification
Description of the problem
I was looking at the ESM resolution algorithm documentation, and stumbled upon this:
PACKAGE_IMPORTS_EXPORTS_RESOLVE:
(2) could be interpreted in several ways, including:
Assuming (1) or (2) here is correct, the implementation of PATTERN_KEY_COMPARE seems odd:
From my understanding, neither keyA nor keyB can not contain a "*" at this point since it's filtered out. I looked at implementations of the module resolution, like Webpack's
enhanced-resolve
, and it seems like previously these imports or exports could end with a/
instead of containing a*
:https://github.com/webpack/enhanced-resolve/blob/e38970852a7f89b694f1053e285195511764a900/lib/util/entrypoints.js#L314-L322
However, this does not seem to work in the current Node.js version (tested on v20.12.2 at least), and is not described in the reference of PACKAGE_IMPORTS_EXPORTS_RESOLVE. Are the docs outdated? Is there some ambiguity here? Or am I simply misunderstanding the docs?
The text was updated successfully, but these errors were encountered: