Skip to content

Commit 1289cb3

Browse files
committed
fix(macros/volar): add semicolon for defineComponent
1 parent 4a05c9e commit 1289cb3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/macros/src/volar/define-component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import type { TransformOptions } from '.'
33

44
export function transformDefineComponent(
55
node: import('typescript').CallExpression,
6+
parent: import('typescript').Node,
67
options: TransformOptions,
78
): void {
8-
const { codes, source, ast } = options
9+
const { codes, source, ast, ts } = options
910

1011
replaceRange(codes, node.arguments[0].end, node.end - 1)
1112

@@ -14,6 +15,7 @@ export function transformDefineComponent(
1415
codes,
1516
node.getStart(ast),
1617
node.expression.end + 1,
18+
ts.isExpressionStatement(parent) ? ';' : '',
1719
'(',
1820
[node.expression.getText(ast), source, node.getStart(ast), allCodeFeatures],
1921
'(() => ({}) as any, ',

packages/macros/src/volar/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export function getRootMap(options: TransformOptions): RootMap {
149149
if (!rootMap.has(root)) rootMap.set(root, {})
150150
if (!rootMap.get(root)!.defineComponent) {
151151
rootMap.get(root)!.defineComponent = true
152-
transformDefineComponent(parents[2], options)
152+
transformDefineComponent(parents[2], parents[3], options)
153153
}
154154
}
155155

0 commit comments

Comments
 (0)