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 Feb 4, 2023
1 parent dbe7109 commit b2c3b6d
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 @@ -176,6 +176,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 @@ -205,7 +210,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 @@ -271,7 +276,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 b2c3b6d

Please sign in to comment.