Skip to content

Commit c58193a

Browse files
authoredSep 6, 2024··
fix(add): Use proper export names when adding adapters (#11935)
* fix(add): Use proper export names when adding adapters * chore: changeset
1 parent 65bfefb commit c58193a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed
 

‎.changeset/green-bulldogs-shout.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes `astro add` not using the proper export point when adding certain adapters

‎packages/astro/src/cli/add/index.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ export async function add(names: string[], { flags }: AddOptions) {
279279
if (isAdapter(integration)) {
280280
const officialExportName = OFFICIAL_ADAPTER_TO_IMPORT_MAP[integration.id];
281281
if (officialExportName) {
282-
setAdapter(mod, integration);
282+
setAdapter(mod, integration, officialExportName);
283283
} else {
284284
logger.info(
285285
'SKIP_FORMAT',
@@ -447,15 +447,19 @@ function addIntegration(mod: ProxifiedModule<any>, integration: IntegrationInfo)
447447
}
448448
}
449449

450-
export function setAdapter(mod: ProxifiedModule<any>, adapter: IntegrationInfo) {
450+
export function setAdapter(
451+
mod: ProxifiedModule<any>,
452+
adapter: IntegrationInfo,
453+
exportName: string,
454+
) {
451455
const config = getDefaultExportOptions(mod);
452456
const adapterId = toIdent(adapter.id);
453457

454458
if (!mod.imports.$items.some((imp) => imp.local === adapterId)) {
455459
mod.imports.$append({
456460
imported: 'default',
457461
local: adapterId,
458-
from: adapter.packageName,
462+
from: exportName,
459463
});
460464
}
461465

0 commit comments

Comments
 (0)
Please sign in to comment.