-
Notifications
You must be signed in to change notification settings - Fork 31.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
test: update ESM loader hooks to allow ambiguous format #52990
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But is there a purpose behind Node’s internal resolve
hook sometimes returning format: null
as opposed to the key being missing? If not, maybe our internal hooks should always either set format
if it has a truthy value, or don’t define it at all (or set format: undefined
) and leave null
out of it.
@nodejs/loaders |
I don't think there is a purpose of setting it to That being said, in this case, the |
Unless there’s a good reason we need
I’m not sure that this is a good reason. If this is data that we want to preserve, it could be its own property on |
IIR, the historical reason (advocated by Antoine) was that Splitting hairs: |
In this case, the different is very material—some tests fail with |
Just for sake of discussion, what value would be put in place for an unknown format module? (But maybe this is a discussion for another time) |
Without custom hooks registered, Node throws on unknown formats. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the test should happen in the same commit that changes the code
You can use this PR to land the variable renaming if you want |
Unlike the other test changes for WDYT @GeoffreyBooth |
@redyetidev I think reopen #52988 and have it undo the part of #50314 that returned |
Sure, it'll take some work because it seems that certain infrastructure rely on that behavior, but I'll work on it |
Pull request #50314 added support for a
null
format value in addition to the existingcommonjs
ormodule
. However, the test for ESM hooks relied on the default value ofcommonjs
, causing it to fail when run with the--experimental-detect-module
flag. This PR enables the test to detectnull
formats, ensuring it runs successfully with experimental detection enabled.Sidenote: While @GeoffreyBooth and I were debugging this behavior, the single-character function arguments made it very difficult to understand, so this PR also expands them into the full names.