1- import { extname } from 'path'
2-
31import type { Plugin , TransformResult } from 'vite'
42import type { createFormatAwareProcessors } from '@mdx-js/mdx/internal-create-format-aware-processors'
53import hash from 'hash-sum'
@@ -13,10 +11,6 @@ export default function IlesMdx (options: MarkdownOptions = {}): Plugin[] {
1311 let markdownProcessor : ReturnType < typeof createFormatAwareProcessors >
1412 let isDevelopment : boolean
1513
16- function shouldTransform ( path : string ) {
17- return markdownProcessor . extnames . includes ( extname ( path ) )
18- }
19-
2014 async function createMdxProcessor ( sourcemap : string | boolean ) {
2115 const { createFormatAwareProcessors } = await import ( '@mdx-js/mdx/internal-create-format-aware-processors' )
2216 markdownProcessor = createFormatAwareProcessors ( {
@@ -42,8 +36,6 @@ export default function IlesMdx (options: MarkdownOptions = {}): Plugin[] {
4236 transform : {
4337 filter : { id : markdownIdFilter } ,
4438 async handler ( value , path ) {
45- if ( ! shouldTransform ( path ) ) return
46-
4739 const compiled = await markdownProcessor . process ( { value, path } )
4840 return { code : String ( compiled . value ) , map : compiled . map } as TransformResult
4941 } ,
@@ -55,8 +47,6 @@ export default function IlesMdx (options: MarkdownOptions = {}): Plugin[] {
5547 transform : {
5648 filter : { id : markdownIdFilter } ,
5749 async handler ( code , path ) {
58- if ( ! shouldTransform ( path ) ) return
59-
6050 return code . replace ( 'export default function MDXContent' , ( ) => `
6151import { defineComponent as $defineComponent } from 'iles/jsx-runtime'
6252
@@ -75,8 +65,6 @@ function MDXContent`)
7565 transform : {
7666 filter : { id : markdownIdFilter } ,
7767 handler ( code : string , path : string ) {
78- if ( ! shouldTransform ( path ) ) return
79-
8068 const hmrId = hash ( `${ path . split ( '?' , 2 ) [ 0 ] } default` )
8169
8270 return `${ code }
0 commit comments