@@ -57,6 +57,8 @@ interface AnnotationPluginPass extends PluginPass {
5757
5858type AnnotationPlugin = PluginObj < AnnotationPluginPass > ;
5959
60+ const DEFAULT_IGNORED_REACT_COMPONENTS = [ "Fragment" ] ;
61+
6062// We must export the plugin as default, otherwise the Babel loader will not be able to resolve it when configured using its string identifier
6163export default function componentNameAnnotatePlugin ( { types : t } : typeof Babel ) : AnnotationPlugin {
6264 return {
@@ -69,14 +71,21 @@ export default function componentNameAnnotatePlugin({ types: t }: typeof Babel):
6971 return ;
7072 }
7173
74+ const ignoredComponents = [
75+ ...new Set ( [
76+ ...( state . opts . ignoredComponents ?? [ ] ) ,
77+ ...DEFAULT_IGNORED_REACT_COMPONENTS ,
78+ ] ) ,
79+ ] ;
80+
7281 functionBodyPushAttributes (
7382 state . opts [ "annotate-fragments" ] === true ,
7483 t ,
7584 path ,
7685 path . node . id . name ,
7786 sourceFileNameFromState ( state ) ,
7887 attributeNamesFromState ( state ) ,
79- state . opts . ignoredComponents ?? [ ]
88+ ignoredComponents
8089 ) ;
8190 } ,
8291 ArrowFunctionExpression ( path , state ) {
@@ -97,14 +106,21 @@ export default function componentNameAnnotatePlugin({ types: t }: typeof Babel):
97106 return ;
98107 }
99108
109+ const ignoredComponents = [
110+ ...new Set ( [
111+ ...( state . opts . ignoredComponents ?? [ ] ) ,
112+ ...DEFAULT_IGNORED_REACT_COMPONENTS ,
113+ ] ) ,
114+ ] ;
115+
100116 functionBodyPushAttributes (
101117 state . opts [ "annotate-fragments" ] === true ,
102118 t ,
103119 path ,
104120 parent . id . name ,
105121 sourceFileNameFromState ( state ) ,
106122 attributeNamesFromState ( state ) ,
107- state . opts . ignoredComponents ?? [ ]
123+ ignoredComponents
108124 ) ;
109125 } ,
110126 ClassDeclaration ( path , state ) {
@@ -118,7 +134,12 @@ export default function componentNameAnnotatePlugin({ types: t }: typeof Babel):
118134 return ;
119135 }
120136
121- const ignoredComponents = state . opts . ignoredComponents ?? [ ] ;
137+ const ignoredComponents = [
138+ ...new Set ( [
139+ ...( state . opts . ignoredComponents ?? [ ] ) ,
140+ ...DEFAULT_IGNORED_REACT_COMPONENTS ,
141+ ] ) ,
142+ ] ;
122143
123144 render . traverse ( {
124145 ReturnStatement ( returnStatement ) {
0 commit comments