Skip to content

Commit 16d38df

Browse files
committed
fix: review comment
1 parent 38e483e commit 16d38df

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

packages/compiler-sfc/__tests__/rewriteDefault.spec.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ describe('compiler sfc: rewriteDefault', () => {
2626
test('rewrite variable value default', () => {
2727
expect(compileRewriteDefault(`export const foo = 'default'`, 'script'))
2828
.toMatchInlineSnapshot(`
29-
"export const foo = 'default'
30-
const script = {}"
29+
"export const foo = 'default'
30+
const script = {}"
3131
`)
3232
})
3333

@@ -53,6 +53,18 @@ describe('compiler sfc: rewriteDefault', () => {
5353
export { a as b, a as c}
5454
const script = a"
5555
`)
56+
57+
expect(
58+
compileRewriteDefault(
59+
`const a = 1 \n export { a as b } \n export { a as default, a as c }`,
60+
'script'
61+
)
62+
).toMatchInlineSnapshot(`
63+
"const a = 1
64+
export { a as b }
65+
export { a as c }
66+
const script = a"
67+
`)
5668
})
5769

5870
test('w/ comments', async () => {

packages/compiler-sfc/src/rewriteDefault.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ export function hasDefaultExport(ast: Statement[]): boolean {
7171
return true
7272
} else if (
7373
stmt.type === 'ExportNamedDeclaration' &&
74-
stmt.specifiers.length > 0
75-
) {
76-
return stmt.specifiers.some(
74+
stmt.specifiers.some(
7775
spec => (spec.exported as Identifier).name === 'default'
7876
)
77+
) {
78+
return true
7979
}
8080
}
8181
return false

0 commit comments

Comments
 (0)