From 075d769e0b0755fa3d526935a687849bfae076ca Mon Sep 17 00:00:00 2001 From: edison Date: Wed, 19 Aug 2020 21:53:09 +0800 Subject: [PATCH] chore: fix typo for `babelParserDefautPlugins` (#1897) --- .../src/transforms/transformExpression.ts | 4 ++-- packages/compiler-dom/src/transforms/vModel.ts | 16 +++++++--------- .../compiler-sfc/__tests__/compileScript.spec.ts | 4 ++-- packages/compiler-sfc/src/compileScript.ts | 4 ++-- packages/shared/src/index.ts | 2 +- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/packages/compiler-core/src/transforms/transformExpression.ts b/packages/compiler-core/src/transforms/transformExpression.ts index a4dd94d0..a671c563 100644 --- a/packages/compiler-core/src/transforms/transformExpression.ts +++ b/packages/compiler-core/src/transforms/transformExpression.ts @@ -20,7 +20,7 @@ import { advancePositionWithClone, isSimpleIdentifier } from '../utils' import { isGloballyWhitelisted, makeMap, - babelParserDefautPlugins, + babelParserDefaultPlugins, hasOwn } from '@vue/shared' import { createCompilerError, ErrorCodes } from '../errors' @@ -135,7 +135,7 @@ export function processExpression( : `(${rawExp})${asParams ? `=>{}` : ``}` try { ast = parse(source, { - plugins: [...context.expressionPlugins, ...babelParserDefautPlugins] + plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins] }).program } catch (e) { context.onError( diff --git a/packages/compiler-dom/src/transforms/vModel.ts b/packages/compiler-dom/src/transforms/vModel.ts index 0aa9dca1..5dff390d 100644 --- a/packages/compiler-dom/src/transforms/vModel.ts +++ b/packages/compiler-dom/src/transforms/vModel.ts @@ -113,15 +113,13 @@ export const transformModel: DirectiveTransform = (dir, node, context) => { // native vmodel doesn't need the `modelValue` props since they are also // passed to the runtime as `binding.value`. removing it reduces code size. - baseResult.props = baseResult.props.filter(p => { - if ( - p.key.type === NodeTypes.SIMPLE_EXPRESSION && - p.key.content === 'modelValue' - ) { - return false - } - return true - }) + baseResult.props = baseResult.props.filter( + p => + !( + p.key.type === NodeTypes.SIMPLE_EXPRESSION && + p.key.content === 'modelValue' + ) + ) return baseResult } diff --git a/packages/compiler-sfc/__tests__/compileScript.spec.ts b/packages/compiler-sfc/__tests__/compileScript.spec.ts index bdaef024..01f0d328 100644 --- a/packages/compiler-sfc/__tests__/compileScript.spec.ts +++ b/packages/compiler-sfc/__tests__/compileScript.spec.ts @@ -1,6 +1,6 @@ import { parse, SFCScriptCompileOptions, compileScript } from '../src' import { parse as babelParse } from '@babel/parser' -import { babelParserDefautPlugins } from '@vue/shared' +import { babelParserDefaultPlugins } from '@vue/shared' function compile(src: string, options?: SFCScriptCompileOptions) { const { descriptor } = parse(src) @@ -12,7 +12,7 @@ function assertCode(code: string) { try { babelParse(code, { sourceType: 'module', - plugins: [...babelParserDefautPlugins, 'typescript'] + plugins: [...babelParserDefaultPlugins, 'typescript'] }) } catch (e) { console.log(code) diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 05c8de4f..a8e378d0 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -2,7 +2,7 @@ import MagicString from 'magic-string' import { BindingMetadata } from '@vue/compiler-core' import { SFCDescriptor, SFCScriptBlock } from './parse' import { parse, ParserPlugin } from '@babel/parser' -import { babelParserDefautPlugins, generateCodeFrame } from '@vue/shared' +import { babelParserDefaultPlugins, generateCodeFrame } from '@vue/shared' import { Node, Declaration, @@ -58,7 +58,7 @@ export function compileScript( const isTS = scriptLang === 'ts' || scriptSetupLang === 'ts' const plugins: ParserPlugin[] = [ ...(options.babelParserPlugins || []), - ...babelParserDefautPlugins, + ...babelParserDefaultPlugins, ...(isTS ? (['typescript'] as const) : []) ] diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index bd7abd12..8f8bd9df 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -19,7 +19,7 @@ export * from './toDisplayString' * for ES2020. This will need to be updated as the spec moves forward. * Full list at https://babeljs.io/docs/en/next/babel-parser#plugins */ -export const babelParserDefautPlugins = [ +export const babelParserDefaultPlugins = [ 'bigInt', 'optionalChaining', 'nullishCoalescingOperator'