From 56cb78bd40a0e0ebe2d22685d5783d0b8de83b97 Mon Sep 17 00:00:00 2001 From: JuanM04 Date: Thu, 31 Mar 2022 15:31:56 -0300 Subject: [PATCH] Reverted config hook changes --- packages/astro/src/@types/astro.ts | 12 ++++++------ packages/astro/src/integrations/index.ts | 12 ++++++------ packages/integrations/vercel/src/index.ts | 12 +++++++----- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index e2de159f23..0f1e48e13b 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -678,12 +678,12 @@ export interface AstroIntegration { // injectElement: (stage: vite.HtmlTagDescriptor, element: string) => void; }) => void; 'astro:config:done'?: (options: { config: AstroConfig; setAdapter: (adapter: AstroAdapter) => void }) => void | Promise; - 'astro:server:setup'?: (options: { config: Readonly; server: vite.ViteDevServer }) => void | Promise; - 'astro:server:start'?: (options: { config: Readonly; address: AddressInfo }) => void | Promise; - 'astro:server:done'?: (options: { config: Readonly }) => void | Promise; - 'astro:build:start'?: (options: { config: Readonly; buildConfig: BuildConfig }) => void | Promise; - 'astro:build:setup'?: (options: { config: Readonly; vite: ViteConfigWithSSR; target: 'client' | 'server' }) => void; - 'astro:build:done'?: (options: { config: Readonly; pages: { pathname: string }[]; dir: URL; routes: RouteData[] }) => void | Promise; + 'astro:server:setup'?: (options: { server: vite.ViteDevServer }) => void | Promise; + 'astro:server:start'?: (options: { address: AddressInfo }) => void | Promise; + 'astro:server:done'?: () => void | Promise; + 'astro:build:start'?: (options: { buildConfig: BuildConfig }) => void | Promise; + 'astro:build:setup'?: (options: { vite: ViteConfigWithSSR; target: 'client' | 'server' }) => void; + 'astro:build:done'?: (options: { pages: { pathname: string }[]; dir: URL; routes: RouteData[] }) => void | Promise; }; } diff --git a/packages/astro/src/integrations/index.ts b/packages/astro/src/integrations/index.ts index 51a3e517f4..93176a6bfb 100644 --- a/packages/astro/src/integrations/index.ts +++ b/packages/astro/src/integrations/index.ts @@ -63,7 +63,7 @@ export async function runHookConfigDone({ config }: { config: AstroConfig }) { export async function runHookServerSetup({ config, server }: { config: AstroConfig; server: ViteDevServer }) { for (const integration of config.integrations) { if (integration.hooks['astro:server:setup']) { - await integration.hooks['astro:server:setup']({ config, server }); + await integration.hooks['astro:server:setup']({ server }); } } } @@ -71,7 +71,7 @@ export async function runHookServerSetup({ config, server }: { config: AstroConf export async function runHookServerStart({ config, address }: { config: AstroConfig; address: AddressInfo }) { for (const integration of config.integrations) { if (integration.hooks['astro:server:start']) { - await integration.hooks['astro:server:start']({ config, address }); + await integration.hooks['astro:server:start']({ address }); } } } @@ -79,7 +79,7 @@ export async function runHookServerStart({ config, address }: { config: AstroCon export async function runHookServerDone({ config }: { config: AstroConfig }) { for (const integration of config.integrations) { if (integration.hooks['astro:server:done']) { - await integration.hooks['astro:server:done']({ config }); + await integration.hooks['astro:server:done'](); } } } @@ -87,7 +87,7 @@ export async function runHookServerDone({ config }: { config: AstroConfig }) { export async function runHookBuildStart({ config, buildConfig }: { config: AstroConfig; buildConfig: BuildConfig }) { for (const integration of config.integrations) { if (integration.hooks['astro:build:start']) { - await integration.hooks['astro:build:start']({ config, buildConfig }); + await integration.hooks['astro:build:start']({ buildConfig }); } } } @@ -95,7 +95,7 @@ export async function runHookBuildStart({ config, buildConfig }: { config: Astro export async function runHookBuildSetup({ config, vite, target }: { config: AstroConfig; vite: ViteConfigWithSSR; target: 'server' | 'client' }) { for (const integration of config.integrations) { if (integration.hooks['astro:build:setup']) { - await integration.hooks['astro:build:setup']({ config, vite, target }); + await integration.hooks['astro:build:setup']({ vite, target }); } } } @@ -103,7 +103,7 @@ export async function runHookBuildSetup({ config, vite, target }: { config: Astr export async function runHookBuildDone({ config, pages, routes }: { config: AstroConfig; pages: string[]; routes: RouteData[] }) { for (const integration of config.integrations) { if (integration.hooks['astro:build:done']) { - await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.dist, routes, config }); + await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.dist, routes }); } } } diff --git a/packages/integrations/vercel/src/index.ts b/packages/integrations/vercel/src/index.ts index e1433bb9d5..ac3a4f9f05 100644 --- a/packages/integrations/vercel/src/index.ts +++ b/packages/integrations/vercel/src/index.ts @@ -1,4 +1,4 @@ -import type { AstroAdapter, AstroIntegration } from 'astro'; +import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro'; import type { PathLike } from 'fs'; import fs from 'fs/promises'; import esbuild from 'esbuild'; @@ -17,6 +17,7 @@ export function getAdapter(): AstroAdapter { } export default function vercel(): AstroIntegration { + let _config: AstroConfig; return { name: '@astrojs/vercel', hooks: { @@ -24,13 +25,14 @@ export default function vercel(): AstroIntegration { config.dist = new URL('./.output/', config.projectRoot); config.buildOptions.pageUrlFormat = 'directory'; }, - 'astro:config:done': ({ setAdapter }) => { + 'astro:config:done': ({ setAdapter, config }) => { setAdapter(getAdapter()); + _config = config; }, - 'astro:build:start': async ({ buildConfig, config }) => { + 'astro:build:start': async ({ buildConfig }) => { buildConfig.serverEntry = `${ENTRYFILE}.mjs`; - buildConfig.client = new URL('./static/', config.dist); - buildConfig.server = new URL('./server/pages/', config.dist); + buildConfig.client = new URL('./static/', _config.dist); + buildConfig.server = new URL('./server/pages/', _config.dist); }, 'astro:build:done': async ({ dir, routes }) => { const pagesDir = new URL('./server/pages/', dir);