@@ -44,12 +44,9 @@ export default class ExportMap {
4444 this . imports = new Map ( ) ;
4545 this . errors = [ ] ;
4646 /**
47- * true when we are still unsure if
48- * the module is ESM, happens when the module
49- * contains dynamic `import()` but no other
50- * ESM import/export
47+ * type {'ambiguous' | 'Module' | 'Script'}
5148 */
52- this . maybeNotEsm = false ;
49+ this . parseGoal = 'ambiguous' ;
5350 }
5451
5552 get hasDefault ( ) { return this . get ( 'default' ) != null ; } // stronger than this.has
@@ -413,8 +410,8 @@ ExportMap.parse = function (path, content, context) {
413410 } ,
414411 } ) ;
415412
416- const maybeNotEsm = ! unambiguous . isModule ( ast ) ;
417- if ( maybeNotEsm && ! hasDynamicImports ) return null ;
413+ const unambiguouslyEsm = unambiguous . isModule ( ast ) ;
414+ if ( ! unambiguouslyEsm && ! hasDynamicImports ) return null ;
418415
419416 const docstyle = ( context . settings && context . settings [ 'import/docstyle' ] ) || [ 'jsdoc' ] ;
420417 const docStyleParsers = { } ;
@@ -718,7 +715,9 @@ ExportMap.parse = function (path, content, context) {
718715 m . namespace . set ( 'default' , { } ) ; // add default export
719716 }
720717
721- m . maybeNotEsm = maybeNotEsm ;
718+ if ( unambiguouslyEsm ) {
719+ m . parseGoal = 'Module' ;
720+ }
722721 return m ;
723722} ;
724723
0 commit comments