chore: fix typo for babelParserDefautPlugins
(#1897)
This commit is contained in:
parent
7dd067206c
commit
075d769e0b
@ -20,7 +20,7 @@ import { advancePositionWithClone, isSimpleIdentifier } from '../utils'
|
|||||||
import {
|
import {
|
||||||
isGloballyWhitelisted,
|
isGloballyWhitelisted,
|
||||||
makeMap,
|
makeMap,
|
||||||
babelParserDefautPlugins,
|
babelParserDefaultPlugins,
|
||||||
hasOwn
|
hasOwn
|
||||||
} from '@vue/shared'
|
} from '@vue/shared'
|
||||||
import { createCompilerError, ErrorCodes } from '../errors'
|
import { createCompilerError, ErrorCodes } from '../errors'
|
||||||
@ -135,7 +135,7 @@ export function processExpression(
|
|||||||
: `(${rawExp})${asParams ? `=>{}` : ``}`
|
: `(${rawExp})${asParams ? `=>{}` : ``}`
|
||||||
try {
|
try {
|
||||||
ast = parse(source, {
|
ast = parse(source, {
|
||||||
plugins: [...context.expressionPlugins, ...babelParserDefautPlugins]
|
plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
|
||||||
}).program
|
}).program
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
context.onError(
|
context.onError(
|
||||||
|
@ -113,15 +113,13 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
|
|||||||
|
|
||||||
// native vmodel doesn't need the `modelValue` props since they are also
|
// native vmodel doesn't need the `modelValue` props since they are also
|
||||||
// passed to the runtime as `binding.value`. removing it reduces code size.
|
// passed to the runtime as `binding.value`. removing it reduces code size.
|
||||||
baseResult.props = baseResult.props.filter(p => {
|
baseResult.props = baseResult.props.filter(
|
||||||
if (
|
p =>
|
||||||
|
!(
|
||||||
p.key.type === NodeTypes.SIMPLE_EXPRESSION &&
|
p.key.type === NodeTypes.SIMPLE_EXPRESSION &&
|
||||||
p.key.content === 'modelValue'
|
p.key.content === 'modelValue'
|
||||||
) {
|
)
|
||||||
return false
|
)
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
return baseResult
|
return baseResult
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { parse, SFCScriptCompileOptions, compileScript } from '../src'
|
import { parse, SFCScriptCompileOptions, compileScript } from '../src'
|
||||||
import { parse as babelParse } from '@babel/parser'
|
import { parse as babelParse } from '@babel/parser'
|
||||||
import { babelParserDefautPlugins } from '@vue/shared'
|
import { babelParserDefaultPlugins } from '@vue/shared'
|
||||||
|
|
||||||
function compile(src: string, options?: SFCScriptCompileOptions) {
|
function compile(src: string, options?: SFCScriptCompileOptions) {
|
||||||
const { descriptor } = parse(src)
|
const { descriptor } = parse(src)
|
||||||
@ -12,7 +12,7 @@ function assertCode(code: string) {
|
|||||||
try {
|
try {
|
||||||
babelParse(code, {
|
babelParse(code, {
|
||||||
sourceType: 'module',
|
sourceType: 'module',
|
||||||
plugins: [...babelParserDefautPlugins, 'typescript']
|
plugins: [...babelParserDefaultPlugins, 'typescript']
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(code)
|
console.log(code)
|
||||||
|
@ -2,7 +2,7 @@ import MagicString from 'magic-string'
|
|||||||
import { BindingMetadata } from '@vue/compiler-core'
|
import { BindingMetadata } from '@vue/compiler-core'
|
||||||
import { SFCDescriptor, SFCScriptBlock } from './parse'
|
import { SFCDescriptor, SFCScriptBlock } from './parse'
|
||||||
import { parse, ParserPlugin } from '@babel/parser'
|
import { parse, ParserPlugin } from '@babel/parser'
|
||||||
import { babelParserDefautPlugins, generateCodeFrame } from '@vue/shared'
|
import { babelParserDefaultPlugins, generateCodeFrame } from '@vue/shared'
|
||||||
import {
|
import {
|
||||||
Node,
|
Node,
|
||||||
Declaration,
|
Declaration,
|
||||||
@ -58,7 +58,7 @@ export function compileScript(
|
|||||||
const isTS = scriptLang === 'ts' || scriptSetupLang === 'ts'
|
const isTS = scriptLang === 'ts' || scriptSetupLang === 'ts'
|
||||||
const plugins: ParserPlugin[] = [
|
const plugins: ParserPlugin[] = [
|
||||||
...(options.babelParserPlugins || []),
|
...(options.babelParserPlugins || []),
|
||||||
...babelParserDefautPlugins,
|
...babelParserDefaultPlugins,
|
||||||
...(isTS ? (['typescript'] as const) : [])
|
...(isTS ? (['typescript'] as const) : [])
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ export * from './toDisplayString'
|
|||||||
* for ES2020. This will need to be updated as the spec moves forward.
|
* 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
|
* Full list at https://babeljs.io/docs/en/next/babel-parser#plugins
|
||||||
*/
|
*/
|
||||||
export const babelParserDefautPlugins = [
|
export const babelParserDefaultPlugins = [
|
||||||
'bigInt',
|
'bigInt',
|
||||||
'optionalChaining',
|
'optionalChaining',
|
||||||
'nullishCoalescingOperator'
|
'nullishCoalescingOperator'
|
||||||
|
Loading…
Reference in New Issue
Block a user