Skip to content

Commit

Permalink
Use default import in astro add (#11872)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Aug 29, 2024
1 parent d1bd1a1 commit 9327d56
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-swans-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes `astro add` importing adapters and integrations
12 changes: 10 additions & 2 deletions packages/astro/src/cli/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,11 @@ function addIntegration(mod: ProxifiedModule<any>, integration: IntegrationInfo)
const integrationId = toIdent(integration.id);

if (!mod.imports.$items.some((imp) => imp.local === integrationId)) {
mod.imports.$append({ imported: integrationId, from: integration.packageName });
mod.imports.$append({
imported: 'default',
local: integrationId,
from: integration.packageName,
});
}

config.integrations ??= [];
Expand All @@ -448,7 +452,11 @@ export function setAdapter(mod: ProxifiedModule<any>, adapter: IntegrationInfo)
const adapterId = toIdent(adapter.id);

if (!mod.imports.$items.some((imp) => imp.local === adapterId)) {
mod.imports.$append({ imported: adapterId, from: adapter.packageName });
mod.imports.$append({
imported: 'default',
local: adapterId,
from: adapter.packageName,
});
}

if (!config.output) {
Expand Down

0 comments on commit 9327d56

Please sign in to comment.