mirror of
https://github.com/withastro/astro.git
synced 2025-02-03 22:29:08 -05:00
fix(add): Use proper export names when adding adapters (#11935)
* fix(add): Use proper export names when adding adapters * chore: changeset
This commit is contained in:
parent
65bfefb96b
commit
c58193a691
2 changed files with 12 additions and 3 deletions
5
.changeset/green-bulldogs-shout.md
Normal file
5
.changeset/green-bulldogs-shout.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes `astro add` not using the proper export point when adding certain adapters
|
|
@ -279,7 +279,7 @@ export async function add(names: string[], { flags }: AddOptions) {
|
||||||
if (isAdapter(integration)) {
|
if (isAdapter(integration)) {
|
||||||
const officialExportName = OFFICIAL_ADAPTER_TO_IMPORT_MAP[integration.id];
|
const officialExportName = OFFICIAL_ADAPTER_TO_IMPORT_MAP[integration.id];
|
||||||
if (officialExportName) {
|
if (officialExportName) {
|
||||||
setAdapter(mod, integration);
|
setAdapter(mod, integration, officialExportName);
|
||||||
} else {
|
} else {
|
||||||
logger.info(
|
logger.info(
|
||||||
'SKIP_FORMAT',
|
'SKIP_FORMAT',
|
||||||
|
@ -447,7 +447,11 @@ function addIntegration(mod: ProxifiedModule<any>, integration: IntegrationInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setAdapter(mod: ProxifiedModule<any>, adapter: IntegrationInfo) {
|
export function setAdapter(
|
||||||
|
mod: ProxifiedModule<any>,
|
||||||
|
adapter: IntegrationInfo,
|
||||||
|
exportName: string,
|
||||||
|
) {
|
||||||
const config = getDefaultExportOptions(mod);
|
const config = getDefaultExportOptions(mod);
|
||||||
const adapterId = toIdent(adapter.id);
|
const adapterId = toIdent(adapter.id);
|
||||||
|
|
||||||
|
@ -455,7 +459,7 @@ export function setAdapter(mod: ProxifiedModule<any>, adapter: IntegrationInfo)
|
||||||
mod.imports.$append({
|
mod.imports.$append({
|
||||||
imported: 'default',
|
imported: 'default',
|
||||||
local: adapterId,
|
local: adapterId,
|
||||||
from: adapter.packageName,
|
from: exportName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue