Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
fix: use esbuild for ts lang block script
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin committed Jul 5, 2020
1 parent ca8d975 commit ee09922
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/serverPlugin.ts
Expand Up @@ -127,9 +127,15 @@ async function parseSFC(
// script
let scriptImport = `var script = {}`
if (descriptor.script) {
const { code } = await transform(descriptor.script.content, publicPath, {
loader: 'ts',
})
let code = descriptor.script.content
if (descriptor.script.lang === 'ts') {
code = (
await transform(descriptor.script.content, publicPath, {
loader: 'ts',
})
).code
}

// rewrite export default.
// fast path: simple regex replacement to avoid full-blown babel parse.
let replaced = code.replace(defaultExportRE, '$1var script =')
Expand Down

0 comments on commit ee09922

Please sign in to comment.