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

Commit 8298f71

Browse files
committed
feat: <script setup> support
1 parent 1f71e17 commit 8298f71

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: src/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
compileStyleAsync,
1313
compileTemplate,
1414
parse,
15+
compileScript,
1516
SFCBlock,
1617
SFCDescriptor,
1718
SFCTemplateCompileOptions,
@@ -152,6 +153,9 @@ export default function PluginVue(userOptions: Partial<Options> = {}): Plugin {
152153
compilerOptions: {
153154
...options.compilerOptions,
154155
scopeId: hasScoped ? `data-v-${query.id}` : undefined,
156+
bindingMetadata: descriptor.script
157+
? descriptor.script.bindings
158+
: undefined,
155159
},
156160
transformAssetUrls: options.transformAssetUrls,
157161
})
@@ -351,7 +355,6 @@ function parseSFC(
351355
sourceMap: true,
352356
filename: id,
353357
sourceRoot: sourceRoot,
354-
pad: 'line',
355358
})
356359

357360
cache.set(id, descriptor)
@@ -447,7 +450,8 @@ function getTemplateCode(
447450

448451
function getScriptCode(descriptor: SFCDescriptor, resourcePath: string) {
449452
let scriptImport = `const script = {}`
450-
if (descriptor.script) {
453+
if (descriptor.script || descriptor.scriptSetup) {
454+
descriptor.script = compileScript(descriptor)
451455
const src = descriptor.script.src || resourcePath
452456
const attrsQuery = attrsToQuery(descriptor.script.attrs, 'js')
453457
const srcQuery = descriptor.script.src ? `&src` : ``

0 commit comments

Comments
 (0)