@@ -19,6 +19,9 @@ const config = ['tsconfig.json', 'package.json'];
1919
2020const packageJsonPath = 'typescript.contentMapper' ;
2121
22+ const mdxContentMappers = [ 'mdx-content-mapper' , '@mdx-js/content-mapper' ] ;
23+ const mdxTransformerPlugins = [ 'remark-mdx-frontmatter' ] ;
24+
2225const resolveContentMapper = ( { exec } : ContentMapperManifest , options : PluginOptions ) => {
2326 if ( ! Array . isArray ( exec ) || exec . some ( arg => typeof arg !== 'string' ) ) return [ ] ;
2427 return options
@@ -42,7 +45,17 @@ const resolveTsConfig = (localConfig: TsConfigJson, options: PluginOptions) => {
4245 ?. filter ( reference => reference . path . endsWith ( '.json' ) )
4346 . map ( reference => toConfig ( 'typescript' , reference . path , { containingFilePath : options . configFilePath } ) ) ?? [ ] ;
4447
45- const contentMappers = localConfig . contentMappers ?. map ( contentMapper => toDependency ( contentMapper . package ) ) ?? [ ] ;
48+ const contentMappers = [ ] ;
49+ for ( const { package : name , options : mapperOptions } of localConfig . contentMappers ?? [ ] ) {
50+ contentMappers . push ( toDependency ( name ) ) ;
51+ if ( ! mdxContentMappers . includes ( name ) ) continue ;
52+ const remarkPlugins = mapperOptions ?. remarkPlugins ;
53+ if ( ! Array . isArray ( remarkPlugins ) ) continue ;
54+ for ( const plugin of remarkPlugins ) {
55+ const id = typeof plugin === 'string' ? plugin : plugin [ 0 ] ;
56+ if ( typeof id === 'string' && ! mdxTransformerPlugins . includes ( id ) ) contentMappers . push ( toDependency ( id ) ) ;
57+ }
58+ }
4659
4760 if ( ! ( compilerOptions && localConfig ) ) return compact ( [ ...contentMappers , ...extend , ...references ] ) ;
4861
0 commit comments