Skip to content

Commit

Permalink
feat: add finalize hook
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed May 3, 2024
1 parent 7c7a90e commit d787e5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,9 @@ export async function transform(
}
}

for (const { transformer } of transformers) {
await transformer.finalize?.(s)
}

return generateTransform(s, id)
}
2 changes: 2 additions & 0 deletions src/core/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { MagicStringAST } from 'magic-string-ast'
import type { Awaitable } from '@antfu/utils'
import type { Node } from '@babel/types'

Expand Down Expand Up @@ -33,4 +34,5 @@ export interface Transformer<T extends Node = Node> {
id: string
},
) => Awaitable<string | Node | false | undefined | null>
finalize?: (s: MagicStringAST) => Awaitable<void>
}

0 comments on commit d787e5f

Please sign in to comment.