Skip to content

Commit 3385107

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

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
@@ -166,6 +166,11 @@ export function compileScript(
166166
const cssVars = sfc.cssVars
167167
const scriptLang = script && script.lang
168168
const scriptSetupLang = scriptSetup && scriptSetup.lang
169+
const isJS =
170+
scriptLang === 'js' ||
171+
scriptLang === 'jsx' ||
172+
scriptSetupLang === 'js' ||
173+
scriptSetupLang === 'jsx'
169174
const isTS =
170175
scriptLang === 'ts' ||
171176
scriptLang === 'tsx' ||
@@ -195,7 +200,7 @@ export function compileScript(
195200
if (!script) {
196201
throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`)
197202
}
198-
if (scriptLang && !isTS && scriptLang !== 'jsx') {
203+
if (scriptLang && !isJS && !isTS) {
199204
// do not process non js/ts script blocks
200205
return script
201206
}
@@ -263,7 +268,7 @@ export function compileScript(
263268
)
264269
}
265270

266-
if (scriptSetupLang && !isTS && scriptSetupLang !== 'jsx') {
271+
if (scriptSetupLang && !isJS && !isTS) {
267272
// do not process non js/ts script blocks
268273
return scriptSetup
269274
}

0 commit comments

Comments
 (0)