chore: fix typo for babelParserDefautPlugins (#1897)

This commit is contained in:
edison 2020-08-19 21:53:09 +08:00 committed by GitHub
parent 7dd067206c
commit 075d769e0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 16 deletions

View File

@ -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(

View File

@ -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 (
baseResult.props = baseResult.props.filter(
p =>
!(
p.key.type === NodeTypes.SIMPLE_EXPRESSION &&
p.key.content === 'modelValue'
) {
return false
}
return true
})
)
)
return baseResult
}

View File

@ -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)

View File

@ -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) : [])
]

View File

@ -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'