From 8099b9cdede40cd37d06b00b4fa707e5049ff44c Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Fri, 13 May 2022 16:27:00 +0800 Subject: [PATCH] chore: format --- packages/compiler-sfc/src/compileScript.ts | 38 ++++++++++++++++------ 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 22e1bb701..dbd0eea43 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -18,7 +18,13 @@ import { ParserOptions, ParserPlugin } from '@babel/parser' -import { camelize, capitalize, generateCodeFrame, isObject,makeMap } from '@vue/shared' +import { + camelize, + capitalize, + generateCodeFrame, + isObject, + makeMap +} from '@vue/shared' import { Node, Declaration, @@ -213,11 +219,18 @@ export function compileScript( sourceType: 'module' }).program const bindings = analyzeScriptBindings(scriptAst.body) - if (enableReactivityTransform && reactivityTransformer!.shouldTransform(content)) { + if ( + enableReactivityTransform && + reactivityTransformer!.shouldTransform(content) + ) { const s = new MagicString(source) const startOffset = script.loc.start.offset const endOffset = script.loc.end.offset - const { importedHelpers } = reactivityTransformer!.transformAST(scriptAst, s, startOffset) + const { importedHelpers } = reactivityTransformer!.transformAST( + scriptAst, + s, + startOffset + ) if (importedHelpers.length) { s.prepend( `import { ${importedHelpers @@ -441,11 +454,12 @@ export function compileScript( prop.key ) } - - const propKey = prop.key.type === 'StringLiteral' - ? prop.key.value - : (prop.key as Identifier).name - + + const propKey = + prop.key.type === 'StringLiteral' + ? prop.key.value + : (prop.key as Identifier).name + if (prop.value.type === 'AssignmentPattern') { // default value { foo = 123 } const { left, right } = prop.value @@ -936,7 +950,10 @@ export function compileScript( } // apply reactivity transform - if (enableReactivityTransform && reactivityTransformer!.shouldTransform(script.content)) { + if ( + enableReactivityTransform && + reactivityTransformer!.shouldTransform(script.content) + ) { const { rootRefs, importedHelpers } = reactivityTransformer!.transformAST( scriptAst, s, @@ -1212,7 +1229,8 @@ export function compileScript( if ( (enableReactivityTransform && // normal