Skip to content

Commit

Permalink
fix(build): avoid importing @babel/parser in esm-bundler build
Browse files Browse the repository at this point in the history
fix #4665
  • Loading branch information
yyx990803 committed Sep 24, 2021
1 parent 87c86e4 commit fc85ad2
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions packages/compiler-core/src/utils.ts
Expand Up @@ -47,7 +47,8 @@ import {
isObject,
hyphenate,
extend,
babelParserDefaultPlugins
babelParserDefaultPlugins,
NOOP
} from '@vue/shared'
import { PropsExpression } from './transforms/transformElement'
import { parseExpression } from '@babel/parser'
Expand Down Expand Up @@ -161,26 +162,25 @@ export const isMemberExpressionBrowser = (path: string): boolean => {
return !currentOpenBracketCount && !currentOpenParensCount
}

export const isMemberExpressionNode = (
path: string,
context: TransformContext
): boolean => {
try {
let ret: Expression = parseExpression(path, {
plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
})
if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
ret = ret.expression
export const isMemberExpressionNode = __BROWSER__
? NOOP
: (path: string, context: TransformContext): boolean => {
try {
let ret: Expression = parseExpression(path, {
plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
})
if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
ret = ret.expression
}
return (
ret.type === 'MemberExpression' ||
ret.type === 'OptionalMemberExpression' ||
ret.type === 'Identifier'
)
} catch (e) {
return false
}
}
return (
ret.type === 'MemberExpression' ||
ret.type === 'OptionalMemberExpression' ||
ret.type === 'Identifier'
)
} catch (e) {
return false
}
}

export const isMemberExpression = __BROWSER__
? isMemberExpressionBrowser
Expand Down

0 comments on commit fc85ad2

Please sign in to comment.