refactor: move @babel/types to dev deps, reduce install size

This commit is contained in:
Evan You
2020-07-20 22:14:05 -04:00
parent 54727f9874
commit be4df124e6
4 changed files with 12 additions and 45 deletions

View File

@@ -32,9 +32,6 @@ import {
BASE_TRANSITION
} from './runtimeHelpers'
import { isString, isObject, hyphenate, extend } from '@vue/shared'
import { parse } from '@babel/parser'
import { walk } from 'estree-walker'
import { Node } from '@babel/types'
export const isStaticExp = (p: JSChildNode): p is SimpleExpressionNode =>
p.type === NodeTypes.SIMPLE_EXPRESSION && p.isStatic
@@ -54,35 +51,6 @@ export function isCoreComponent(tag: string): symbol | void {
}
}
export const parseJS: typeof parse = (code, options) => {
if (__BROWSER__) {
assert(
!__BROWSER__,
`Expression AST analysis can only be performed in non-browser builds.`
)
return null as any
} else {
return parse(code, options)
}
}
interface Walker {
enter?(node: Node, parent: Node): void
leave?(node: Node): void
}
export const walkJS = (ast: Node, walker: Walker) => {
if (__BROWSER__) {
assert(
!__BROWSER__,
`Expression AST analysis can only be performed in non-browser builds.`
)
return null as any
} else {
return (walk as any)(ast, walker)
}
}
const nonIdentifierRE = /^\d|[^\$\w]/
export const isSimpleIdentifier = (name: string): boolean =>
!nonIdentifierRE.test(name)