]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat(compiler-core/internal): add `onContextCreated` option to `generate` (#1672)
authorRahul Kadyan <hi@znck.me>
Tue, 21 Jul 2020 19:16:20 +0000 (00:46 +0530)
committerGitHub <noreply@github.com>
Tue, 21 Jul 2020 19:16:20 +0000 (15:16 -0400)
packages/compiler-core/src/codegen.ts

index fab88a2ff4cf79dab7a11b99d30fdbce803f83ca..31fe534ca78270f5d589856c7ad7a163f14aa654 100644 (file)
@@ -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,