-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
module: ensure format
is never null
with experimental-detect-module
#53012
Conversation
Review requested:
|
aa0355a
to
5b52e25
Compare
78444fd
to
4437ac7
Compare
format
is never null
format
is never null
with experimental-detect-module
4437ac7
to
0e9ca39
Compare
lib/internal/modules/esm/load.js
Outdated
@@ -141,7 +141,9 @@ async function defaultLoad(url, context = kEmptyObject) { | |||
} | |||
|
|||
validateAttributes(url, format, importAttributes); | |||
|
|||
if (format == null && getOptionValue('--experimental-detect-module')) { |
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.
And what if we detected that the module is ESM? Then format
would be 'module'
already?
We should probably add a comment listing the conditions when format == null
might happen.
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.
Yes
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.
Essentially, if we don't know the format and we should autodetect it, assume it is commonjs
I'd like to apologize for the confusion around these changes, I've tried several attempts, which made this really confusing. Essentially, when the The symbol name |
@@ -224,4 +226,5 @@ module.exports = { | |||
defaultGetFormatWithoutErrors, | |||
extensionFormatMap, | |||
extname, | |||
kFormatHasNoSource, |
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.
Did you forget to commit something? I don’t see when you’re ever setting format
to be this symbol.
We don’t want this symbol leaking into user hooks. There shouldn’t be a user load
hook that ever sees format
set to this symbol.
Co-authored-by: Geoffrey Booth <webadmin@geoffreybooth.com>
Everything was working, but now something went wrong, strange, I need to debug |
This change ensures that the format is consistently defined when
experimental-detect-module
is enabled, allowing tests to pass in both experimental detection and standard Node environments.(Fourth PR is the charm)