소스 검색

feat(compiler-core/internal): add `onContextCreated` option to `generate` (#1672)

Rahul Kadyan 5 년 전
부모
커밋
615dccd00e
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      packages/compiler-core/src/codegen.ts

+ 4 - 1
packages/compiler-core/src/codegen.ts

@@ -180,9 +180,12 @@ function createCodegenContext(
 
 export function generate(
   ast: RootNode,
-  options: CodegenOptions = {}
+  options: CodegenOptions & {
+    onContextCreated?: (context: CodegenContext) => void
+  } = {}
 ): CodegenResult {
   const context = createCodegenContext(ast, options)
+  if (options.onContextCreated) options.onContextCreated(context)
   const {
     mode,
     push,