11import { camelize , capitalize } from '@vue/shared' ;
22import { computed } from 'alien-signals' ;
33import * as path from 'path-browserify' ;
4- import { createScriptCodegenContext , generateScript , type ScriptCodegenOptions } from '../codegen/script' ;
5- import { createTemplateCodegenContext , generateTemplate , type TemplateCodegenOptions } from '../codegen/template' ;
4+ import { generateScript } from '../codegen/script' ;
5+ import { generateTemplate } from '../codegen/template' ;
66import { parseScriptRanges } from '../parsers/scriptRanges' ;
77import { parseScriptSetupRanges } from '../parsers/scriptSetupRanges' ;
88import { parseVueCompilerOptions } from '../parsers/vueCompilerOptions' ;
9- import type { Code , Sfc , VueLanguagePlugin } from '../types' ;
9+ import type { Sfc , VueLanguagePlugin } from '../types' ;
1010import { computedSet } from '../utils/signals' ;
1111import { CompilerOptionsResolver } from '../utils/ts' ;
1212
@@ -178,8 +178,7 @@ function createTsx(
178178 if ( getResolvedOptions ( ) . skipTemplateCodegen || ! sfc . template ) {
179179 return ;
180180 }
181-
182- const options : TemplateCodegenOptions = {
181+ return generateTemplate ( {
183182 ts,
184183 compilerOptions : ctx . compilerOptions ,
185184 vueCompilerOptions : getResolvedOptions ( ) ,
@@ -193,26 +192,11 @@ function createTsx(
193192 propsAssignName : getSetupPropsAssignName ( ) ,
194193 inheritAttrs : getSetupInheritAttrs ( ) ,
195194 selfComponentName : getComponentSelfName ( ) ,
196- } ;
197- const context = createTemplateCodegenContext ( options , sfc . template . ast ) ;
198- const codegen = generateTemplate ( options , context ) ;
199-
200- const codes : Code [ ] = [ ] ;
201- for ( const code of codegen ) {
202- if ( typeof code === 'object' ) {
203- code [ 3 ] = context . resolveCodeFeatures ( code [ 3 ] ) ;
204- }
205- codes . push ( code ) ;
206- }
207-
208- return {
209- ...context ,
210- codes,
211- } ;
195+ } ) ;
212196 } ) ;
213197
214198 const getGeneratedScript = computed ( ( ) => {
215- const options : ScriptCodegenOptions = {
199+ return generateScript ( {
216200 ts,
217201 compilerOptions : ctx . compilerOptions ,
218202 vueCompilerOptions : getResolvedOptions ( ) ,
@@ -224,14 +208,7 @@ function createTsx(
224208 templateCodegen : getGeneratedTemplate ( ) ,
225209 destructuredPropNames : getSetupDestructuredPropNames ( ) ,
226210 templateRefNames : getSetupTemplateRefNames ( ) ,
227- } ;
228- const context = createScriptCodegenContext ( options ) ;
229- const codegen = generateScript ( options , context ) ;
230-
231- return {
232- ...context ,
233- codes : [ ...codegen ] ,
234- } ;
211+ } ) ;
235212 } ) ;
236213
237214 return {
0 commit comments