Skip to content

Commit 8d129b5

Browse files
committed
fix(compiler-sfc): allow <script> with lang='js'
closes #7388
1 parent ea5bf12 commit 8d129b5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/compiler-sfc/src/compileScript.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ export function compileScript(
176176
const cssVars = sfc.cssVars
177177
const scriptLang = script && script.lang
178178
const scriptSetupLang = scriptSetup && scriptSetup.lang
179+
const isJS =
180+
scriptLang === 'js' ||
181+
scriptLang === 'jsx' ||
182+
scriptSetupLang === 'js' ||
183+
scriptSetupLang === 'jsx'
179184
const isTS =
180185
scriptLang === 'ts' ||
181186
scriptLang === 'tsx' ||
@@ -205,7 +210,7 @@ export function compileScript(
205210
if (!script) {
206211
throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`)
207212
}
208-
if (scriptLang && !isTS && scriptLang !== 'jsx') {
213+
if (scriptLang && !isJS && !isTS) {
209214
// do not process non js/ts script blocks
210215
return script
211216
}
@@ -271,7 +276,7 @@ export function compileScript(
271276
)
272277
}
273278

274-
if (scriptSetupLang && !isTS && scriptSetupLang !== 'jsx') {
279+
if (scriptSetupLang && !isJS && !isTS) {
275280
// do not process non js/ts script blocks
276281
return scriptSetup
277282
}

0 commit comments

Comments
 (0)