@@ -395,7 +395,12 @@ impl JavascriptParserPlugin for InnerGraphPlugin {
395395 }
396396
397397 if let Some ( class_decl) = stmt. as_class_decl ( )
398- && is_pure_class ( class_decl. class ( ) , self . unresolved_context , parser. comments )
398+ && is_pure_class (
399+ parser,
400+ class_decl. class ( ) ,
401+ self . unresolved_context ,
402+ parser. comments ,
403+ )
399404 {
400405 let name = & class_decl
401406 . ident ( )
@@ -425,15 +430,25 @@ impl JavascriptParserPlugin for InnerGraphPlugin {
425430 let decl = & export_default_decl. decl ;
426431
427432 if let DefaultDecl :: Class ( class_expr) = decl
428- && is_pure_class ( & class_expr. class , self . unresolved_context , parser. comments )
433+ && is_pure_class (
434+ parser,
435+ & class_expr. class ,
436+ self . unresolved_context ,
437+ parser. comments ,
438+ )
429439 {
430440 let variable = Self :: tag_top_level_symbol ( parser, & DEFAULT_STAR_JS_WORD ) ;
431441 parser
432442 . inner_graph
433443 . class_with_top_level_symbol
434444 . insert ( decl. span ( ) , variable) ;
435445 } else if let DefaultDecl :: Fn ( fn_expr) = decl
436- && is_pure_function ( & fn_expr. function , self . unresolved_context , parser. comments )
446+ && is_pure_function (
447+ parser,
448+ & fn_expr. function ,
449+ self . unresolved_context ,
450+ parser. comments ,
451+ )
437452 {
438453 let variable = Self :: tag_top_level_symbol ( parser, & DEFAULT_STAR_JS_WORD ) ;
439454 parser
@@ -447,7 +462,7 @@ impl JavascriptParserPlugin for InnerGraphPlugin {
447462 // https://github.com/estree/estree/blob/master/es2015.md#exportdefaultdeclaration
448463 // but SWC using ExportDefaultExpr to represent `export default 1`
449464 if let ModuleDecl :: ExportDefaultExpr ( ExportDefaultExpr { expr, .. } ) = export_decl
450- && is_pure_expression ( expr, self . unresolved_context , parser. comments )
465+ && is_pure_expression ( parser , expr, self . unresolved_context , parser. comments )
451466 {
452467 let export_part = & * * expr;
453468 let variable = Self :: tag_top_level_symbol ( parser, & DEFAULT_STAR_JS_WORD ) ;
@@ -485,6 +500,7 @@ impl JavascriptParserPlugin for InnerGraphPlugin {
485500
486501 if init. is_class ( )
487502 && is_pure_class (
503+ parser,
488504 & init. as_class ( ) . expect ( "should be class" ) . class ,
489505 self . unresolved_context ,
490506 parser. comments ,
@@ -496,7 +512,7 @@ impl JavascriptParserPlugin for InnerGraphPlugin {
496512 . inner_graph
497513 . class_with_top_level_symbol
498514 . insert ( init. span ( ) , v) ;
499- } else if is_pure_expression ( init, self . unresolved_context , parser. comments ) {
515+ } else if is_pure_expression ( parser , init, self . unresolved_context , parser. comments ) {
500516 let v = Self :: tag_top_level_symbol ( parser, name) ;
501517 parser
502518 . inner_graph
@@ -587,11 +603,18 @@ impl JavascriptParserPlugin for InnerGraphPlugin {
587603 return None ;
588604 }
589605
606+ let is_pure_super_class = is_pure_expression (
607+ parser,
608+ super_class,
609+ self . unresolved_context ,
610+ parser. comments ,
611+ ) ;
612+
590613 if let Some ( v) = parser
591614 . inner_graph
592615 . class_with_top_level_symbol
593616 . get ( & class_decl_or_expr. span ( ) )
594- && is_pure_expression ( super_class , self . unresolved_context , parser . comments )
617+ && is_pure_super_class
595618 {
596619 parser. inner_graph . set_top_level_symbol ( Some ( v. clone ( ) ) ) ;
597620
@@ -644,14 +667,14 @@ impl JavascriptParserPlugin for InnerGraphPlugin {
644667 if !parser. inner_graph . is_enabled ( ) || !parser. is_top_level_scope ( ) {
645668 return None ;
646669 }
670+ let pure_member =
671+ is_pure_class_member ( parser, element, self . unresolved_context , parser. comments ) ;
647672 if let Some ( v) = parser
648673 . inner_graph
649674 . class_with_top_level_symbol
650675 . get ( & class_decl_or_expr. span ( ) )
651676 {
652- if !element. is_static ( )
653- || is_pure_class_member ( element, self . unresolved_context , parser. comments )
654- {
677+ if !element. is_static ( ) || pure_member {
655678 parser. inner_graph . set_top_level_symbol ( Some ( v. clone ( ) ) ) ;
656679 if !matches ! ( element, ClassMember :: Method ( _) ) && element. is_static ( ) {
657680 Self :: on_usage (
0 commit comments