From eb650ca301b2e27f47ad53aa5ff8f16b3161b3f9 Mon Sep 17 00:00:00 2001 From: gcclll Date: Fri, 25 Dec 2020 17:41:47 +0800 Subject: [PATCH] feat(add): sfc->script, export default handle --- packages/compiler-sfc/src/compileScript.ts | 143 ++++++++++++++++++++- 1 file changed, 139 insertions(+), 4 deletions(-) diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 591246c..87593e6 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -8,7 +8,9 @@ import { TSTypeLiteral, TSUnionType, Node, - ArrayExpression + ArrayExpression, + ExportSpecifier, + bindExpression } from '@babel/types' import { BindingMetadata, BindingTypes, UNREF } from '@vue/compiler-core' import { babelParserDefaultPlugins, generateCodeFrame } from '@vue/shared' @@ -120,7 +122,6 @@ export function compileScript( scriptAst } } catch (e) { - console.log(e) // silently fallback if parse fails since user may be using custom // babel syntax return script @@ -139,8 +140,137 @@ export function compileScript( return scriptSetup } - // TODO 1. 先处理存在的