summaryrefslogtreecommitdiff
path: root/src/compiler/codegen.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/codegen.ts')
-rw-r--r--src/compiler/codegen.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/compiler/codegen.ts b/src/compiler/codegen.ts
index 020d55376..031cc8ee2 100644
--- a/src/compiler/codegen.ts
+++ b/src/compiler/codegen.ts
@@ -368,7 +368,10 @@ function compileModule(module: Script, state: CodegenState, compileOptions: Comp
for (const componentImport of componentImports) {
const importUrl = componentImport.source.value;
const componentType = path.posix.extname(importUrl);
- const componentName = path.posix.basename(importUrl, componentType);
+ const specifier = componentImport.specifiers[0];
+ if (!specifier) continue; // this is unused
+ // set componentName to default import if used (user), or use filename if no default import (mostly internal use)
+ const componentName = specifier.type === 'ImportDefaultSpecifier' ? specifier.local.name : path.posix.basename(importUrl, componentType);
const plugin = extensions[componentType] || defaultExtensions[componentType];
state.components[componentName] = {
type: componentType,