]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: remove babelParserDefaultPlugins
authorEvan You <yyx990803@gmail.com>
Thu, 7 Oct 2021 23:32:59 +0000 (19:32 -0400)
committerEvan You <yyx990803@gmail.com>
Thu, 7 Oct 2021 23:33:06 +0000 (19:33 -0400)
The version of @babel/parser we are using now has these plugins enabled by default.

packages/compiler-core/src/transforms/transformExpression.ts
packages/compiler-core/src/utils.ts
packages/compiler-sfc/__tests__/utils.ts
packages/compiler-sfc/src/compileScript.ts
packages/ref-transform/__tests__/refTransform.spec.ts
packages/ref-transform/src/refTransform.ts
packages/shared/src/index.ts

index bf4d568e51037a00d3541769c4c1bf14e1bc1a20..7a5e699efb4f36ba085fece5b302732392b4ca18 100644 (file)
@@ -24,13 +24,7 @@ import {
   walkIdentifiers
 } from '../babelUtils'
 import { advancePositionWithClone, isSimpleIdentifier } from '../utils'
-import {
-  isGloballyWhitelisted,
-  makeMap,
-  babelParserDefaultPlugins,
-  hasOwn,
-  isString
-} from '@vue/shared'
+import { isGloballyWhitelisted, makeMap, hasOwn, isString } from '@vue/shared'
 import { createCompilerError, ErrorCodes } from '../errors'
 import {
   Node,
@@ -244,7 +238,7 @@ export function processExpression(
     : `(${rawExp})${asParams ? `=>{}` : ``}`
   try {
     ast = parse(source, {
-      plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
+      plugins: context.expressionPlugins
     }).program
   } catch (e: any) {
     context.onError(
index 374f0a87145579f711d1897a246e958fe076e6ee..ab5dd80ba8e0e453bd51cebd2ef22493b44b6aab 100644 (file)
@@ -42,14 +42,7 @@ import {
   WITH_MEMO,
   OPEN_BLOCK
 } from './runtimeHelpers'
-import {
-  isString,
-  isObject,
-  hyphenate,
-  extend,
-  babelParserDefaultPlugins,
-  NOOP
-} from '@vue/shared'
+import { isString, isObject, hyphenate, extend, NOOP } from '@vue/shared'
 import { PropsExpression } from './transforms/transformElement'
 import { parseExpression } from '@babel/parser'
 import { Expression } from '@babel/types'
@@ -167,7 +160,7 @@ export const isMemberExpressionNode = __BROWSER__
   : (path: string, context: TransformContext): boolean => {
       try {
         let ret: Expression = parseExpression(path, {
-          plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
+          plugins: context.expressionPlugins
         })
         if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
           ret = ret.expression
index 1ae9ee15876c4dc345ed73b0847d579b3a1329e4..206ff3681dd60e31fbf364b250fd8c09137e00f8 100644 (file)
@@ -1,6 +1,5 @@
 import { parse, SFCScriptCompileOptions, compileScript } from '../src'
 import { parse as babelParse } from '@babel/parser'
-import { babelParserDefaultPlugins } from '@vue/shared'
 
 export const mockId = 'xxxxxxxx'
 
@@ -20,7 +19,7 @@ export function assertCode(code: string) {
   try {
     babelParse(code, {
       sourceType: 'module',
-      plugins: [...babelParserDefaultPlugins, 'typescript']
+      plugins: ['typescript']
     })
   } catch (e: any) {
     console.log(code)
index 94d13f6471a14ae6e1aa1a02c3fdacd8b2f0af43..1f1336fd1071160dc18ebbb012d48d99632108bb 100644 (file)
@@ -13,13 +13,7 @@ import {
 } from '@vue/compiler-dom'
 import { SFCDescriptor, SFCScriptBlock } from './parse'
 import { parse as _parse, ParserOptions, ParserPlugin } from '@babel/parser'
-import {
-  babelParserDefaultPlugins,
-  camelize,
-  capitalize,
-  generateCodeFrame,
-  makeMap
-} from '@vue/shared'
+import { camelize, capitalize, generateCodeFrame, makeMap } from '@vue/shared'
 import {
   Node,
   Declaration,
@@ -161,7 +155,7 @@ export function compileScript(
     scriptLang === 'tsx' ||
     scriptSetupLang === 'ts' ||
     scriptSetupLang === 'tsx'
-  const plugins: ParserPlugin[] = [...babelParserDefaultPlugins]
+  const plugins: ParserPlugin[] = []
   if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') {
     plugins.push('jsx')
   }
index 37f55bb6ee99aae91ec925de55a3ba87e2060028..ec8e841dc1c080f69d13d35de0bde48dfa3d7879 100644 (file)
@@ -1,5 +1,4 @@
 import { parse } from '@babel/parser'
-import { babelParserDefaultPlugins } from '@vue/shared'
 import { transform } from '../src'
 
 function assertCode(code: string) {
@@ -7,7 +6,7 @@ function assertCode(code: string) {
   try {
     parse(code, {
       sourceType: 'module',
-      plugins: [...babelParserDefaultPlugins, 'typescript']
+      plugins: ['typescript']
     })
   } catch (e: any) {
     console.log(code)
index 4822a4e064c8d393c31bd81efd067bceb9f2c21e..8dcf14e9b08facd0e3dd6d869bd8ed466c977890 100644 (file)
@@ -20,7 +20,7 @@ import {
   walkFunctionParams
 } from '@vue/compiler-core'
 import { parse, ParserPlugin } from '@babel/parser'
-import { babelParserDefaultPlugins, hasOwn } from '@vue/shared'
+import { hasOwn } from '@vue/shared'
 
 const TO_VAR_SYMBOL = '$'
 const TO_REF_SYMBOL = '$$'
@@ -68,7 +68,7 @@ export function transform(
 
   const ast = parse(src, {
     sourceType: 'module',
-    plugins: [...new Set([...babelParserDefaultPlugins, ...plugins])]
+    plugins
   })
   const s = new MagicString(src)
   const res = transformAST(ast.program, s)
index 8c98b3b6cc4f255ef451b2098640b01a5c69c80b..97750a81cd99b0c6f051e14b5e534769a42e1700 100644 (file)
@@ -13,18 +13,6 @@ export * from './escapeHtml'
 export * from './looseEqual'
 export * from './toDisplayString'
 
-/**
- * List of @babel/parser plugins that are used for template expression
- * transforms and SFC script transforms. By default we enable proposals slated
- * 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 babelParserDefaultPlugins = [
-  'bigInt',
-  'optionalChaining',
-  'nullishCoalescingOperator'
-] as const
-
 export const EMPTY_OBJ: { readonly [key: string]: any } = __DEV__
   ? Object.freeze({})
   : {}