diff options
author | 2021-04-09 14:23:25 -0600 | |
---|---|---|
committer | 2021-04-09 14:23:25 -0600 | |
commit | e3ca67d6dc13e686889a771e0c710963bd5ec5fa (patch) | |
tree | fbb168dd33e34426151f9bb7d56a3659b3a021f3 /src | |
parent | 62924b31628a40adf0efd52c53086362070c4d8b (diff) | |
download | astro-e3ca67d6dc13e686889a771e0c710963bd5ec5fa.tar.gz astro-e3ca67d6dc13e686889a771e0c710963bd5ec5fa.tar.zst astro-e3ca67d6dc13e686889a771e0c710963bd5ec5fa.zip |
Use import specifier rather than filename (#71)
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/codegen.ts | 5 |
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, |