File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
packages/compiler-sfc/src/script Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -101,11 +101,12 @@ export class ScriptCompileContext {
101
101
options . babelParserPlugins
102
102
)
103
103
104
- function parse ( input : string , offset : number ) : Program {
104
+ function parse ( input : string , offset : number , setup ?: boolean ) : Program {
105
105
try {
106
106
return babelParse ( input , {
107
107
plugins,
108
- sourceType : 'module'
108
+ sourceType : 'module' ,
109
+ allowReturnOutsideFunction : setup
109
110
} ) . program
110
111
} catch ( e : any ) {
111
112
e . message = `[vue/compiler-sfc] ${ e . message } \n\n${
@@ -125,7 +126,7 @@ export class ScriptCompileContext {
125
126
126
127
this . scriptSetupAst =
127
128
descriptor . scriptSetup &&
128
- parse ( descriptor . scriptSetup ! . content , this . startOffset ! )
129
+ parse ( descriptor . scriptSetup ! . content , this . startOffset ! , true )
129
130
}
130
131
131
132
getString ( node : Node , scriptSetup = true ) : string {
You can’t perform that action at this time.
0 commit comments