Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
feat: <script setup> support
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 15, 2020
1 parent 1f71e17 commit 8298f71
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
compileStyleAsync,
compileTemplate,
parse,
compileScript,
SFCBlock,
SFCDescriptor,
SFCTemplateCompileOptions,
Expand Down Expand Up @@ -152,6 +153,9 @@ export default function PluginVue(userOptions: Partial<Options> = {}): Plugin {
compilerOptions: {
...options.compilerOptions,
scopeId: hasScoped ? `data-v-${query.id}` : undefined,
bindingMetadata: descriptor.script
? descriptor.script.bindings
: undefined,
},
transformAssetUrls: options.transformAssetUrls,
})
Expand Down Expand Up @@ -351,7 +355,6 @@ function parseSFC(
sourceMap: true,
filename: id,
sourceRoot: sourceRoot,
pad: 'line',
})

cache.set(id, descriptor)
Expand Down Expand Up @@ -447,7 +450,8 @@ function getTemplateCode(

function getScriptCode(descriptor: SFCDescriptor, resourcePath: string) {
let scriptImport = `const script = {}`
if (descriptor.script) {
if (descriptor.script || descriptor.scriptSetup) {
descriptor.script = compileScript(descriptor)
const src = descriptor.script.src || resourcePath
const attrsQuery = attrsToQuery(descriptor.script.attrs, 'js')
const srcQuery = descriptor.script.src ? `&src` : ``
Expand Down

0 comments on commit 8298f71

Please sign in to comment.