@@ -358,23 +358,25 @@ export function recmaJsxRewrite(options = {}) {
358358 componentsInit = { type : 'Identifier' , name : '_components' }
359359 }
360360
361- for ( const [ id , componentName ] of idToInvalidComponentName ) {
362- // For JSX IDs that can’t be represented as JavaScript IDs (as in,
363- // those with dashes, such as `custom-element`), generate a
364- // separate variable that is a valid JS ID (such as `_component0`),
365- // and takes it from components:
366- // `const _component0 = _components['custom-element']`
367- declarations . push ( {
368- type : 'VariableDeclarator' ,
369- id : { type : 'Identifier' , name : componentName } ,
370- init : {
371- type : 'MemberExpression' ,
372- object : { type : 'Identifier' , name : '_components' } ,
373- property : { type : 'Literal' , value : id } ,
374- computed : true ,
375- optional : false
376- }
377- } )
361+ if ( isNamedFunction ( scope . node , '_createMdxContent' ) ) {
362+ for ( const [ id , componentName ] of idToInvalidComponentName ) {
363+ // For JSX IDs that can’t be represented as JavaScript IDs (as in,
364+ // those with dashes, such as `custom-element`), generate a
365+ // separate variable that is a valid JS ID (such as `_component0`),
366+ // and takes it from components:
367+ // `const _component0 = _components['custom-element']`
368+ declarations . push ( {
369+ type : 'VariableDeclarator' ,
370+ id : { type : 'Identifier' , name : componentName } ,
371+ init : {
372+ type : 'MemberExpression' ,
373+ object : { type : 'Identifier' , name : '_components' } ,
374+ property : { type : 'Literal' , value : id } ,
375+ computed : true ,
376+ optional : false
377+ }
378+ } )
379+ }
378380 }
379381
380382 if ( componentsPattern ) {
0 commit comments