@@ -53,10 +53,9 @@ export function compileScript(
5353
5454 const hasCssVars = styles . some ( s => typeof s . attrs . vars === 'string' )
5555
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'
6059 const plugins : ParserPlugin [ ] = [
6160 ...( options . babelParserPlugins || [ ] ) ,
6261 ...babelParserDefautPlugins ,
@@ -67,19 +66,28 @@ export function compileScript(
6766 if ( ! script ) {
6867 throw new Error ( `SFC contains no <script> tags.` )
6968 }
69+ if ( scriptLang && scriptLang !== 'ts' ) {
70+ // do not process non js/ts script blocks
71+ return script
72+ }
7073 return {
7174 ...script ,
7275 content : hasCssVars ? injectCssVarsCalls ( sfc , plugins ) : script . content ,
7376 bindings : analyzeScriptBindings ( script )
7477 }
7578 }
7679
77- if ( script && script . lang !== scriptSetup . lang ) {
80+ if ( script && scriptLang !== scriptSetupLang ) {
7881 throw new Error (
7982 `<script> and <script setup> must have the same language type.`
8083 )
8184 }
8285
86+ if ( scriptSetupLang && scriptSetupLang !== 'ts' ) {
87+ // do not process non js/ts script blocks
88+ return scriptSetup
89+ }
90+
8391 const defaultTempVar = `__default__`
8492 const bindings : BindingMetadata = { }
8593 const imports : Record < string , string > = { }
0 commit comments