@@ -9,9 +9,17 @@ import { replaceComponentLinks } from './utils/replaceUrl';
9
9
import findPagesMarkdownNew from './utils/findPagesMarkdown' ;
10
10
import { TypeScriptProject } from './utils/createTypeScriptProject' ;
11
11
12
- const systemComponents = fs
13
- . readdirSync ( path . resolve ( 'packages' , 'mui-system' , 'src' ) )
14
- . filter ( ( pathname ) => pathname . match ( / ^ [ A - Z ] [ a - z A - Z ] + $ / ) ) ;
12
+ let systemComponents : string [ ] | undefined ;
13
+ // making the resolution lazy to avoid issues when importing something irrelevant from this file (i.e. `getSymbolDescription`)
14
+ // the eager resolution results in errors when consuming externally (i.e. `mui-x`)
15
+ function getSystemComponents ( ) {
16
+ if ( ! systemComponents ) {
17
+ systemComponents = fs
18
+ . readdirSync ( path . resolve ( 'packages' , 'mui-system' , 'src' ) )
19
+ . filter ( ( pathname ) => pathname . match ( / ^ [ A - Z ] [ a - z A - Z ] + $ / ) ) ;
20
+ }
21
+ return systemComponents ;
22
+ }
15
23
16
24
function getMuiName ( name : string ) {
17
25
return `Mui${ name . replace ( 'Unstyled' , '' ) . replace ( 'Styled' , '' ) } ` ;
@@ -171,7 +179,7 @@ export const getMaterialComponentInfo = (filename: string): ComponentInfo => {
171
179
muiName : getMuiName ( name ) ,
172
180
apiPathname : `/material-ui/api/${ kebabCase ( name ) } /` ,
173
181
apiPagesDirectory : path . join ( process . cwd ( ) , `docs/pages/material-ui/api` ) ,
174
- isSystemComponent : systemComponents . includes ( name ) ,
182
+ isSystemComponent : getSystemComponents ( ) . includes ( name ) ,
175
183
readFile ( ) {
176
184
srcInfo = parseFile ( filename ) ;
177
185
return srcInfo ;
@@ -282,7 +290,7 @@ export const getBaseComponentInfo = (filename: string): ComponentInfo => {
282
290
muiName : getMuiName ( name ) ,
283
291
apiPathname : `/base/api/${ kebabCase ( name ) } /` ,
284
292
apiPagesDirectory : path . join ( process . cwd ( ) , `docs/pages/base/api` ) ,
285
- isSystemComponent : systemComponents . includes ( name ) ,
293
+ isSystemComponent : getSystemComponents ( ) . includes ( name ) ,
286
294
readFile ( ) {
287
295
srcInfo = parseFile ( filename ) ;
288
296
return srcInfo ;
@@ -390,7 +398,7 @@ export const getJoyComponentInfo = (filename: string): ComponentInfo => {
390
398
muiName : getMuiName ( name ) ,
391
399
apiPathname : `/joy-ui/api/${ kebabCase ( name ) } /` ,
392
400
apiPagesDirectory : path . join ( process . cwd ( ) , `docs/pages/joy-ui/api` ) ,
393
- isSystemComponent : systemComponents . includes ( name ) ,
401
+ isSystemComponent : getSystemComponents ( ) . includes ( name ) ,
394
402
readFile ( ) {
395
403
srcInfo = parseFile ( filename ) ;
396
404
return srcInfo ;
0 commit comments