@@ -1087,7 +1087,7 @@ _isImports_, _conditions_)
10871087> 1. If _packageType_ is not **null**, then
10881088> 1. Return _packageType_.
10891089> 2. If ` -- experimental- detect- module ` is enabled and the result of
1090- > **CONTAINS \_ MODULE\_ SYNTAX**(_source_) is true, then
1090+ > **DETECT \_ MODULE\_ SYNTAX**(_source_) is true, then
10911091> 1. Return _"module"_.
10921092> 3. Return _"commonjs"_.
10931093> 11. If _url_ does not have any extension, then
@@ -1124,20 +1124,16 @@ _isImports_, _conditions_)
11241124> 1. Throw an _Invalid Package Configuration_ error.
11251125> 4. Return the parsed JSON source of the file at _pjsonURL_.
11261126
1127- **CONTAINS\_ MODULE\_ SYNTAX**(_source_)
1128-
1129- > 1. Parse _source_ as a CommonJS module.
1130- > 2. If the parse is successful, return **false**.
1131- > 3. Else inspect the error message thrown. Return **true** if it is a syntax
1132- > error thrown by any of the following:
1133- > * ` import ` statement (static only, _not_ dynamic ` import()` )
1134- > * ` export` statement
1135- > * ` import.meta`
1136- > * ` await` at the top level
1137- > * A lexical redeclaration of any of the CommonJS wrapper variables
1138- > (` require` , ` exports` , ` module` , ` __filename` , ` __dirname` ) at the top
1139- > level
1140- > 4. Else return **false**.
1127+ **DETECT\_ MODULE\_ SYNTAX**(_source_)
1128+
1129+ > 1. Parse _source_ as an ECMAScript module.
1130+ > 2. If the parse is successful, then
1131+ > 1. If _source_ contains top-level ` await ` , static ` import ` or ` export`
1132+ statements, or ` import.meta` , return *true*.
1133+ > 2. If _source_ contains a top-level lexical declaration (` const` , ` let` ,
1134+ or ` class` ) of any of the CommonJS wrapper variables (` require` ,
1135+ ` exports` , ` module` , ` __filename` , or ` __dirname` ) then return *true*.
1136+ > 3. Else return *false*.
11411137
11421138### Customizing ESM specifier resolution algorithm
11431139
0 commit comments