-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
doc: add spec for contains module syntax #52059
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1086,8 +1086,8 @@ _isImports_, _conditions_) | |||||||||||||||||||||||||||||
> 10. If _url_ ends in _".js"_, then | ||||||||||||||||||||||||||||||
> 1. If _packageType_ is not **null**, then | ||||||||||||||||||||||||||||||
> 1. Return _packageType_. | ||||||||||||||||||||||||||||||
> 2. If `--experimental-detect-module` is enabled and the source of | ||||||||||||||||||||||||||||||
> module contains static import or export syntax, then | ||||||||||||||||||||||||||||||
> 2. If `--experimental-detect-module` is enabled and the result of | ||||||||||||||||||||||||||||||
> **CONTAINS\_MODULE\_SYNTAX**(_source_) is true, then | ||||||||||||||||||||||||||||||
> 1. Return _"module"_. | ||||||||||||||||||||||||||||||
> 3. Return _"commonjs"_. | ||||||||||||||||||||||||||||||
> 11. If _url_ does not have any extension, then | ||||||||||||||||||||||||||||||
|
@@ -1124,6 +1124,21 @@ _isImports_, _conditions_) | |||||||||||||||||||||||||||||
> 1. Throw an _Invalid Package Configuration_ error. | ||||||||||||||||||||||||||||||
> 4. Return the parsed JSON source of the file at _pjsonURL_. | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
**CONTAINS\_MODULE\_SYNTAX**(_source_) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
> 1. Parse _source_ as a CommonJS module. | ||||||||||||||||||||||||||||||
> 2. If the parse is successful, return **false**. | ||||||||||||||||||||||||||||||
> 3. Else inspect the error message thrown. Return **true** if it is a syntax | ||||||||||||||||||||||||||||||
> error thrown by any of the following: | ||||||||||||||||||||||||||||||
> * `import` statement (static only, _not_ dynamic `import()`) | ||||||||||||||||||||||||||||||
> * `export` statement | ||||||||||||||||||||||||||||||
> * `import.meta` | ||||||||||||||||||||||||||||||
> * `await` at the top level | ||||||||||||||||||||||||||||||
> * A lexical redeclaration of any of the CommonJS wrapper variables | ||||||||||||||||||||||||||||||
> (`require`, `exports`, `module`, `__filename`, `__dirname`) at the top | ||||||||||||||||||||||||||||||
> level | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's important to clarify that this is only for import statements and not expressions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that |
||||||||||||||||||||||||||||||
> 4. Else return **false**. | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
### Customizing ESM specifier resolution algorithm | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
[Module customization hooks][] provide a mechanism for customizing the ESM | ||||||||||||||||||||||||||||||
|
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.
Perhaps
DETECT_MODULE_SYNTAX
to capture that this is the "detection path".