From aaab38662e1369e7ddf0931b58c40887b41f1790 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Wed, 22 Feb 2023 18:36:44 +0000 Subject: [PATCH] fix(astro): correctly change configuration when node adapter is added --- .changeset/swift-islands-promise.md | 5 +++++ packages/astro/src/core/add/index.ts | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .changeset/swift-islands-promise.md diff --git a/.changeset/swift-islands-promise.md b/.changeset/swift-islands-promise.md new file mode 100644 index 000000000000..0f2924287847 --- /dev/null +++ b/.changeset/swift-islands-promise.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Correctly emit mode when passing `node` to the command `astro add` diff --git a/packages/astro/src/core/add/index.ts b/packages/astro/src/core/add/index.ts index 02e49b7545c6..d90075ce78a5 100644 --- a/packages/astro/src/core/add/index.ts +++ b/packages/astro/src/core/add/index.ts @@ -457,7 +457,21 @@ async function setAdapter(ast: t.File, adapter: IntegrationInfo, exportName: str return false; }) as t.ObjectProperty | undefined; - const adapterCall = t.callExpression(adapterId, []); + let adapterCall; + switch (adapter.id) { + // the node adapter requires a mode + case 'node': { + adapterCall = t.callExpression(adapterId, [ + t.objectExpression([ + t.objectProperty(t.identifier('mode'), t.stringLiteral('standalone')), + ]), + ]); + break; + } + default: { + adapterCall = t.callExpression(adapterId, []); + } + } if (!adapterProp) { configObject.properties.push(t.objectProperty(t.identifier('adapter'), adapterCall));