#integration says no adapter installed when an adapter is selected

12 messages · Page 1 of 1 (latest)

gilded tree
#

here is the integration

/**
 * @param {Object} options
 * @param {string} options.aggregator
 * @returns {import("astro").AstroIntegration}.
 */
export function integration({ aggregator }) {
  return {
    name: "globals",
    hooks: {
      "astro:config:setup": ({ updateConfig }) => {
        const adapter = process.env.IS_CI
          ? sst({ deploymentStrategy: "edge" })
          : node({ mode: "standalone" });

        console.log({ isCI: !!process.env.IS_CI });
        console.log({ adapter });
        updateConfig({
          adapter,
          output: "server",
          build: {
            assets: aggregator,
          },
          integrations: [tailwind(), svelte()],
          vite: {
            define,
            build: {
              rollupOptions: !!process.env.IS_CI ? rollupOptions : {},
            },
          },
        });
      },
    },
  };
}

the logs clearly show an adapter is selected but its still erroring

> go4mobility@0.0.1 build
> astro build

{ isCI: false }
{
  adapter: {
    name: '@astrojs/node',
    hooks: {
      'astro:config:setup': [AsyncFunction: astro:config:setup],
      'astro:config:done': [Function: astro:config:done]
    }
  }
}
11:37:14 [types] Added src/env.d.ts type declarations.
11:37:14 [vite] Forced re-optimization of dependencies
11:37:14 [build] output: "server"
11:37:14 [build] directory: /home/al/code/sdk/apps/go4mobility/dist/
11:37:14 [build] Collecting build info...
11:37:14 [build] ✓ Completed in 159ms.
[NoAdapterInstalled] Cannot use `output: 'server'` or `output: 'hybrid'` without an adapter. Please install and configure the appropriate server adapter for your final deployment.
hot flint
#

you can't set the adapter through updateConfig iirc

#

you'll have to move the condition adapter thingy to your astro config instead

#

OR if you want to share this between several projects, you'll have to make a wrapper around defineConfig

#

For example

/** @param {Omit<import("astro").AstroUserConfig, "adapter">} config */
export const defineConfig = (config) => ({
  adapter: process.env.IS_CI
          ? sst({ deploymentStrategy: "edge" })
          : node({ mode: "standalone" }),
  ...config
})
gilded tree
#

thank you

hot flint
#

(updated the type)

gilded tree
#

getting quite the type issue btw

Type 'AstroIntegration | AstroIntegration' is not assignable to type 'AstroIntegration | undefined'.
  Type 'import("/home/al/code/sdk/node_modules/.pnpm/astro@4.9.0_@types+node@20.12.8_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").AstroIntegration' is not assignable to type 
#
* @param {Object} options
 * @param {string} options.aggregator
 * @returns {import("astro").AstroUserConfig}.
 */
export function defineConfig({ aggregator }) {
    /** @type {import("astro").AstroUserConfig} */
    const config = {
        adapter: process.env.IS_CI ? sst({ deploymentStrategy: "edge" }) : node({ mode: "standalone" }),
        output: "server",
        build: {
            assets: aggregator,
        },
        integrations: [tailwind(), svelte()],
        vite: {
            ssr: { noExternal: true },
            define,
            build: {
                rollupOptions,
            },
        },
    };
    return config;
}
#

works fine tho but its weird that the union isnt being combined into one

hot flint
#

that's probably because sst and node don't have the same astro peer dep or something like this

#

feel free to put a ts-expect-error