fix(build): avoid importing @babel/parser in esm-bundler build

fix #4665
This commit is contained in:
Evan You 2021-09-23 23:20:53 -04:00
parent 87c86e4cc2
commit fc85ad28ae

View File

@ -47,7 +47,8 @@ import {
isObject,
hyphenate,
extend,
babelParserDefaultPlugins
babelParserDefaultPlugins,
NOOP
} from '@vue/shared'
import { PropsExpression } from './transforms/transformElement'
import { parseExpression } from '@babel/parser'
@ -161,10 +162,9 @@ export const isMemberExpressionBrowser = (path: string): boolean => {
return !currentOpenBracketCount && !currentOpenParensCount
}
export const isMemberExpressionNode = (
path: string,
context: TransformContext
): boolean => {
export const isMemberExpressionNode = __BROWSER__
? NOOP
: (path: string, context: TransformContext): boolean => {
try {
let ret: Expression = parseExpression(path, {
plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
@ -180,7 +180,7 @@ export const isMemberExpressionNode = (
} catch (e) {
return false
}
}
}
export const isMemberExpression = __BROWSER__
? isMemberExpressionBrowser