Skip to content

Commit e30b4cf

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

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
@@ -170,6 +170,11 @@ export function compileScript(
170170
const cssVars = sfc.cssVars
171171
const scriptLang = script && script.lang
172172
const scriptSetupLang = scriptSetup && scriptSetup.lang
173+
const isJS =
174+
scriptLang === 'js' ||
175+
scriptLang === 'jsx' ||
176+
scriptSetupLang === 'js' ||
177+
scriptSetupLang === 'jsx'
173178
const isTS =
174179
scriptLang === 'ts' ||
175180
scriptLang === 'tsx' ||
@@ -199,7 +204,7 @@ export function compileScript(
199204
if (!script) {
200205
throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`)
201206
}
202-
if (scriptLang && !isTS && scriptLang !== 'jsx') {
207+
if (scriptLang && !isJS && !isTS) {
203208
// do not process non js/ts script blocks
204209
return script
205210
}
@@ -265,7 +270,7 @@ export function compileScript(
265270
)
266271
}
267272

268-
if (scriptSetupLang && !isTS && scriptSetupLang !== 'jsx') {
273+
if (scriptSetupLang && !isJS && !isTS) {
269274
// do not process non js/ts script blocks
270275
return scriptSetup
271276
}

0 commit comments

Comments
 (0)