@@ -22,6 +22,12 @@ function isCustomElementDeclaration(
2222 return ! ! ( declaration as CEM . CustomElementDeclaration ) . customElement ;
2323}
2424
25+ function isExported ( exports : CEM . Export [ ] | undefined ) {
26+ return function ( declaration : CEM . Declaration ) : boolean {
27+ return ! ! exports ?. some ( exp => exp . kind === 'js' && exp . declaration . name === declaration . name ) ;
28+ } ;
29+ }
30+
2531/** Remove a prefix from a class name */
2632function getDeprefixedClassName ( className : string , prefix : string ) {
2733 const [ fst , ...tail ] = className . replace ( prefix , '' ) ;
@@ -80,10 +86,10 @@ function genJavascriptModule(module: CEM.Module, pkgName: string, data: ReactWra
8086 return javascript `// ${ module . path }
8187import { createComponent } from '@lit/react';
8288import react from 'react';${ data . map ( x => javascript `
83- import { ${ x . Class } as elementClass } from '${ pkgName } /${ module . path } ';` ) . join ( '' ) } ${ data . map ( x => javascript `
89+ import { ${ x . Class } } from '${ pkgName } /${ module . path } ';` ) . join ( '' ) } ${ data . map ( x => javascript `
8490export const ${ x . reactComponentName } = createComponent({
8591 tagName: '${ x . tagName } ',
86- elementClass,
92+ elementClass: ${ x . Class } ,
8793 react,
8894 events: ${ x . eventsMap } ,
8995});` ) . join ( '\n' ) }
@@ -106,6 +112,7 @@ function genWrapperModules(
106112) {
107113 const data : ReactWrapperData [ ] = ( module . declarations ?? [ ] )
108114 . filter ( isCustomElementDeclaration )
115+ . filter ( isExported ( module . exports ) )
109116 . map ( getReactWrapperData ( module , classPrefix , elPrefix ) ) ;
110117 const js = genJavascriptModule ( module , pkgName , data ) ;
111118 const ts = genTypescriptModule ( module , pkgName , data ) ;
0 commit comments