@@ -6,8 +6,8 @@ import type { Code, Sfc, VueCodeInformation, VueCompilerOptions } from '../../ty
6
6
import { endOfLine , generateSfcBlockSection , newLine } from '../common' ;
7
7
import { generateGlobalTypes } from '../globalTypes' ;
8
8
import type { TemplateCodegenContext } from '../template/context' ;
9
- import { createScriptCodegenContext , ScriptCodegenContext } from './context' ;
10
9
import { generateComponentSelf } from './componentSelf' ;
10
+ import { createScriptCodegenContext , ScriptCodegenContext } from './context' ;
11
11
import { generateScriptSetup , generateScriptSetupImports } from './scriptSetup' ;
12
12
import { generateSrc } from './src' ;
13
13
import { generateStyleModulesType } from './styleModulesType' ;
@@ -56,7 +56,13 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code,
56
56
const ctx = createScriptCodegenContext ( options ) ;
57
57
58
58
if ( options . vueCompilerOptions . __setupedGlobalTypes ) {
59
- yield `/// <reference types=".vue-global-types/${ options . vueCompilerOptions . lib } _${ options . vueCompilerOptions . target } _${ options . vueCompilerOptions . strictTemplates } .d.ts" />${ newLine } ` ;
59
+ const globalTypes = options . vueCompilerOptions . __setupedGlobalTypes ;
60
+ if ( typeof globalTypes === 'object' ) {
61
+ yield `/// <reference types="${ globalTypes . absolutePath } " />${ newLine } ` ;
62
+ }
63
+ else {
64
+ yield `/// <reference types=".vue-global-types/${ options . vueCompilerOptions . lib } _${ options . vueCompilerOptions . target } _${ options . vueCompilerOptions . strictTemplates } .d.ts" />${ newLine } ` ;
65
+ }
60
66
}
61
67
else {
62
68
yield `/* placeholder */` ;
@@ -79,6 +85,7 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code,
79
85
}
80
86
else {
81
87
yield generateSfcBlockSection ( options . sfc . script , 0 , options . sfc . script . content . length , codeFeatures . all ) ;
88
+ yield * generateScriptSectionPartiallyEnding ( options . sfc . script . name , options . sfc . script . content . length , '#3632/both.vue' ) ;
82
89
yield * generateScriptSetup ( options , ctx , options . sfc . scriptSetup , options . scriptSetupRanges ) ;
83
90
}
84
91
}
@@ -117,7 +124,7 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code,
117
124
yield `__VLS_template = () => {${ newLine } ` ;
118
125
const templateCodegenCtx = yield * generateTemplate ( options , ctx ) ;
119
126
yield * generateComponentSelf ( options , ctx , templateCodegenCtx ) ;
120
- yield `}, ${ newLine } ` ;
127
+ yield `}${ endOfLine } ` ;
121
128
yield generateSfcBlockSection ( options . sfc . script , classBlockEnd , options . sfc . script . content . length , codeFeatures . all ) ;
122
129
}
123
130
}
@@ -131,12 +138,12 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code,
131
138
yield * generateScriptSetup ( options , ctx , options . sfc . scriptSetup , options . scriptSetupRanges ) ;
132
139
}
133
140
134
- yield `;` ;
141
+ if ( options . sfc . script ) {
142
+ yield * generateScriptSectionPartiallyEnding ( options . sfc . script . name , options . sfc . script . content . length , '#3632/script.vue' ) ;
143
+ }
135
144
if ( options . sfc . scriptSetup ) {
136
- // #4569
137
- yield [ '' , 'scriptSetup' , options . sfc . scriptSetup . content . length , codeFeatures . verification ] ;
145
+ yield * generateScriptSectionPartiallyEnding ( options . sfc . scriptSetup . name , options . sfc . scriptSetup . content . length , '#4569/main.vue' ) ;
138
146
}
139
- yield newLine ;
140
147
141
148
if ( ! ctx . generatedTemplate ) {
142
149
yield `function __VLS_template() {${ newLine } ` ;
@@ -163,6 +170,12 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code,
163
170
return ctx ;
164
171
}
165
172
173
+ export function * generateScriptSectionPartiallyEnding ( source : string , end : number , mark : string ) : Generator < Code > {
174
+ yield `;` ;
175
+ yield [ '' , source , end , codeFeatures . verification ] ;
176
+ yield `/* PartiallyEnd: ${ mark } */${ newLine } ` ;
177
+ }
178
+
166
179
function * generateDefineProp (
167
180
options : ScriptCodegenOptions ,
168
181
scriptSetup : NonNullable < Sfc [ 'scriptSetup' ] >
0 commit comments