@@ -53,10 +53,9 @@ export function compileScript(
53
53
54
54
const hasCssVars = styles . some ( s => typeof s . attrs . vars === 'string' )
55
55
56
- const isTS =
57
- ( script && script . lang === 'ts' ) ||
58
- ( scriptSetup && scriptSetup . lang === 'ts' )
59
-
56
+ const scriptLang = script && script . lang
57
+ const scriptSetupLang = scriptSetup && scriptSetup . lang
58
+ const isTS = scriptLang === 'ts' || scriptSetupLang === 'ts'
60
59
const plugins : ParserPlugin [ ] = [
61
60
...( options . babelParserPlugins || [ ] ) ,
62
61
...babelParserDefautPlugins ,
@@ -67,19 +66,28 @@ export function compileScript(
67
66
if ( ! script ) {
68
67
throw new Error ( `SFC contains no <script> tags.` )
69
68
}
69
+ if ( scriptLang && scriptLang !== 'ts' ) {
70
+ // do not process non js/ts script blocks
71
+ return script
72
+ }
70
73
return {
71
74
...script ,
72
75
content : hasCssVars ? injectCssVarsCalls ( sfc , plugins ) : script . content ,
73
76
bindings : analyzeScriptBindings ( script )
74
77
}
75
78
}
76
79
77
- if ( script && script . lang !== scriptSetup . lang ) {
80
+ if ( script && scriptLang !== scriptSetupLang ) {
78
81
throw new Error (
79
82
`<script> and <script setup> must have the same language type.`
80
83
)
81
84
}
82
85
86
+ if ( scriptSetupLang && scriptSetupLang !== 'ts' ) {
87
+ // do not process non js/ts script blocks
88
+ return scriptSetup
89
+ }
90
+
83
91
const defaultTempVar = `__default__`
84
92
const bindings : BindingMetadata = { }
85
93
const imports : Record < string , string > = { }
0 commit comments