0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

Use default import in astro add (#11872)

This commit is contained in:
Bjorn Lu 2024-08-29 23:05:16 +08:00 committed by GitHub
parent d1bd1a11f7
commit 9327d56755
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes `astro add` importing adapters and integrations

View file

@ -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 ??= [];
@ -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) {