Skip to content

Commit

Permalink
fix: handle <script> tags with no default export
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 21, 2020
1 parent a7e7677 commit 59938bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node/server/serverPluginVue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ async function compileSFCMain(
}
}

if (content) {
if (content && defaultExportRE.test(content)) {
// rewrite export default.
// fast path: simple regex replacement to avoid full-blown babel parse.
let replaced = content.replace(defaultExportRE, '$1const __script =')
Expand All @@ -470,7 +470,7 @@ async function compileSFCMain(
}
code += replaced
} else {
code += `const __script = {}`
code += content + `\nconst __script = {}`
}

let hasScoped = false
Expand Down

0 comments on commit 59938bc

Please sign in to comment.