Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support imported types in SFC macros #8083

Merged
merged 9 commits into from Apr 15, 2023
16 changes: 1 addition & 15 deletions packages/compiler-core/src/babelUtils.ts
Expand Up @@ -6,10 +6,7 @@ import type {
Function,
ObjectProperty,
BlockStatement,
Program,
ImportDefaultSpecifier,
ImportNamespaceSpecifier,
ImportSpecifier
Program
} from '@babel/types'
import { walk } from 'estree-walker'

Expand Down Expand Up @@ -246,17 +243,6 @@ export const isStaticProperty = (node: Node): node is ObjectProperty =>
export const isStaticPropertyKey = (node: Node, parent: Node) =>
isStaticProperty(parent) && parent.key === node

export function getImportedName(
specifier: ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier
) {
if (specifier.type === 'ImportSpecifier')
return specifier.imported.type === 'Identifier'
? specifier.imported.name
: specifier.imported.value
else if (specifier.type === 'ImportNamespaceSpecifier') return '*'
return 'default'
}

/**
* Copied from https://github.com/babel/babel/blob/main/packages/babel-types/src/validators/isReferenced.ts
* To avoid runtime dependency on @babel/types (which includes process references)
Expand Down