From d60e58c9f62ae7bd1f9c888cd2e55982a64d9e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Tue, 28 Mar 2023 16:27:34 +0800 Subject: [PATCH] fix(compiler-sfc): fix edge case of default export call with no args (#7536) closes #7534 --- .../__snapshots__/compileScript.spec.ts.snap | 18 ++++++++++++++++++ .../__tests__/compileScript.spec.ts | 16 ++++++++++++++++ packages/compiler-sfc/src/compileScript.ts | 1 + 3 files changed, 35 insertions(+) diff --git a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap index 99f33959159..6220f860f16 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap @@ -59,6 +59,24 @@ return { n, get x() { return x } } }" `; +exports[`SFC compile + + + `) + assertCode(content) + }) }) describe('imports', () => { diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index f05926df922..c9fe242b25f 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -1116,6 +1116,7 @@ export function compileScript( optionProperties = defaultExport.declaration.properties } else if ( defaultExport.declaration.type === 'CallExpression' && + defaultExport.declaration.arguments[0] && defaultExport.declaration.arguments[0].type === 'ObjectExpression' ) { optionProperties = defaultExport.declaration.arguments[0].properties