Skip to content

Commit

Permalink
fix(compiler-sfc): allow <script> with lang='js'
Browse files Browse the repository at this point in the history
closes #7388
  • Loading branch information
sxzz committed Jan 26, 2023
1 parent 0fbc19f commit e30b4cf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ export function compileScript(
const cssVars = sfc.cssVars
const scriptLang = script && script.lang
const scriptSetupLang = scriptSetup && scriptSetup.lang
const isJS =
scriptLang === 'js' ||
scriptLang === 'jsx' ||
scriptSetupLang === 'js' ||
scriptSetupLang === 'jsx'
const isTS =
scriptLang === 'ts' ||
scriptLang === 'tsx' ||
Expand Down Expand Up @@ -199,7 +204,7 @@ export function compileScript(
if (!script) {
throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`)
}
if (scriptLang && !isTS && scriptLang !== 'jsx') {
if (scriptLang && !isJS && !isTS) {
// do not process non js/ts script blocks
return script
}
Expand Down Expand Up @@ -265,7 +270,7 @@ export function compileScript(
)
}

if (scriptSetupLang && !isTS && scriptSetupLang !== 'jsx') {
if (scriptSetupLang && !isJS && !isTS) {
// do not process non js/ts script blocks
return scriptSetup
}
Expand Down

0 comments on commit e30b4cf

Please sign in to comment.