fix(compiler-sfc): named imports from .vue file should not be treated as constant

fix #2699
This commit is contained in:
Evan You
2020-12-01 11:52:29 -05:00
parent f2b0a8e81d
commit 085bbd5fe0
3 changed files with 19 additions and 10 deletions

View File

@@ -168,7 +168,7 @@ export function compileScript(
string,
{
isType: boolean
imported: string | null
imported: string
source: string
}
> = Object.create(null)
@@ -246,7 +246,7 @@ export function compileScript(
}
userImports[local] = {
isType,
imported: imported || null,
imported: imported || 'default',
source
}
}
@@ -807,10 +807,12 @@ export function compileScript(
for (const key in typeDeclaredProps) {
bindingMetadata[key] = BindingTypes.PROPS
}
for (const [key, { isType, source }] of Object.entries(userImports)) {
for (const [key, { isType, imported, source }] of Object.entries(
userImports
)) {
if (isType) continue
bindingMetadata[key] =
source.endsWith('.vue') || source === 'vue'
(imported === 'default' && source.endsWith('.vue')) || source === 'vue'
? BindingTypes.SETUP_CONST
: BindingTypes.SETUP_MAYBE_REF
}