@@ -392,22 +392,29 @@ const resolveTypeFromStrictFolder =
392
392
393
393
/** the type has children and the file suffix (in source format) matches a child type suffix of the type we think it is */
394
394
const childSuffixMatches = ( type : MetadataType , fsPath : string ) : boolean =>
395
- Object . values ( type . children ?. types ?? { } )
396
- . flatMap ( getSuffixes )
397
- . map ( appendMetaXmlSuffix )
398
- . some ( ( s ) => fsPath . endsWith ( s ) ) ;
395
+ Object . values ( type . children ?. types ?? { } ) . some (
396
+ ( childType ) => suffixMatches ( childType , fsPath ) || legacySuffixMatches ( childType , fsPath )
397
+ ) ;
399
398
400
399
/** the file suffix (in source or mdapi format) matches the type suffix we think it is */
401
400
const suffixMatches = ( type : MetadataType , fsPath : string ) : boolean =>
402
- [ ...getSuffixes ( type ) , ...getSuffixes ( type ) . map ( appendMetaXmlSuffix ) ] . some ( ( s ) => fsPath . endsWith ( s ) ) ;
401
+ typeof type . suffix === 'string' &&
402
+ ( fsPath . endsWith ( type . suffix ) || fsPath . endsWith ( appendMetaXmlSuffix ( type . suffix ) ) ) ;
403
403
404
+ const legacySuffixMatches = ( type : MetadataType , fsPath : string ) : boolean => {
405
+ if (
406
+ typeof type . legacySuffix === 'string' &&
407
+ ( fsPath . endsWith ( type . legacySuffix ) || fsPath . endsWith ( appendMetaXmlSuffix ( type . legacySuffix ) ) )
408
+ ) {
409
+ void Lifecycle . getInstance ( ) . emitWarning (
410
+ `The ${ type . name } component at ${ fsPath } uses the legacy suffix ${ type . legacySuffix } . This suffix is deprecated and will be removed in a future release.`
411
+ ) ;
412
+ return true ;
413
+ }
414
+ return false ;
415
+ } ;
404
416
const appendMetaXmlSuffix = ( suffix : string ) : string => `${ suffix } ${ META_XML_SUFFIX } ` ;
405
417
406
- const getSuffixes = ( type : MetadataType ) : string [ ] => [
407
- ...( type . suffix ? [ type . suffix ] : [ ] ) ,
408
- ...( type . legacySuffix ? [ type . legacySuffix ] : [ ] ) ,
409
- ] ;
410
-
411
418
const isMixedContentOrBundle = ( type : MetadataType ) : boolean =>
412
419
typeof type . strategies ?. adapter === 'string' && [ 'mixedContent' , 'bundle' ] . includes ( type . strategies . adapter ) ;
413
420
0 commit comments