diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index 2fe43e6c8..ed855e254 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -75,10 +75,10 @@ export async function staticBuild(opts: StaticBuildOptions) { // Track client:only usage so we can map their CSS back to the Page they are used in. const clientOnlys = Array.from(metadata.clientOnlyComponentPaths()); trackClientOnlyPageDatas(internals, pageData, clientOnlys); - + // Client-only components for (const clientOnly of clientOnlys) { - topLevelImports.add(clientOnly) + topLevelImports.add(clientOnly); } // Add hoisted scripts diff --git a/packages/astro/src/core/config.ts b/packages/astro/src/core/config.ts index 8388cbf0b..44ec20912 100644 --- a/packages/astro/src/core/config.ts +++ b/packages/astro/src/core/config.ts @@ -338,7 +338,13 @@ export async function validateConfig( // First-Pass Validation const result = { ...(await AstroConfigRelativeSchema.parseAsync(userConfig)), - _ctx: { pageExtensions: [], scripts: [], renderers: [], injectedRoutes: [], adapter: undefined }, + _ctx: { + pageExtensions: [], + scripts: [], + renderers: [], + injectedRoutes: [], + adapter: undefined, + }, }; // Final-Pass Validation (perform checks that require the full config object) if ( diff --git a/packages/astro/src/core/render/core.ts b/packages/astro/src/core/render/core.ts index 6332fbc09..48d362924 100644 --- a/packages/astro/src/core/render/core.ts +++ b/packages/astro/src/core/render/core.ts @@ -9,7 +9,7 @@ import type { } from '../../@types/astro'; import type { LogOptions } from '../logger/core.js'; -import { renderHead, renderPage, renderComponent } from '../../runtime/server/index.js'; +import { renderComponent, renderHead, renderPage } from '../../runtime/server/index.js'; import { getParams } from '../routing/params.js'; import { createResult } from './result.js'; import { callGetStaticPaths, findPathItemByKey, RouteCache } from './route-cache.js'; @@ -150,8 +150,8 @@ export async function render( const html = await renderComponent(result, Component.name, Component, props, null); page = { type: 'html', - html: html.toString() - } + html: html.toString(), + }; } else { page = await renderPage(result, Component, pageProps, null); } diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index b2ce27062..053624961 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -165,7 +165,11 @@ export function createRouteManifest( ): ManifestData { const components: string[] = []; const routes: RouteData[] = []; - const validPageExtensions: Set = new Set(['.astro', '.md', ...config._ctx.pageExtensions]); + const validPageExtensions: Set = new Set([ + '.astro', + '.md', + ...config._ctx.pageExtensions, + ]); const validEndpointExtensions: Set = new Set(['.js', '.ts']); function walk(dir: string, parentSegments: RoutePart[][], parentParams: string[]) { diff --git a/packages/astro/src/integrations/index.ts b/packages/astro/src/integrations/index.ts index a519b0516..88c6a6f5e 100644 --- a/packages/astro/src/integrations/index.ts +++ b/packages/astro/src/integrations/index.ts @@ -1,6 +1,12 @@ import type { AddressInfo } from 'net'; import type { ViteDevServer } from 'vite'; -import { AstroConfig, AstroIntegration, AstroRenderer, BuildConfig, RouteData } from '../@types/astro.js'; +import { + AstroConfig, + AstroIntegration, + AstroRenderer, + BuildConfig, + RouteData, +} from '../@types/astro.js'; import ssgAdapter from '../adapter-ssg/index.js'; import type { SerializedSSRManifest } from '../core/app/types'; import type { PageBuildData } from '../core/build/types'; @@ -8,7 +14,10 @@ import { mergeConfig } from '../core/config.js'; import type { ViteConfigWithSSR } from '../core/create-vite.js'; import { isBuildingToSSR } from '../core/util.js'; -type Hooks = Fn extends (...args: any) => any ? Parameters[0] : never; +type Hooks< + Hook extends keyof AstroIntegration['hooks'], + Fn = AstroIntegration['hooks'][Hook] +> = Fn extends (...args: any) => any ? Parameters[0] : never; export async function runHookConfigSetup({ config: _config, @@ -51,16 +60,18 @@ export async function runHookConfigSetup({ injectRoute: (injectRoute) => { updatedConfig._ctx.injectedRoutes.push(injectRoute); }, - } + }; // Semi-private `addPageExtension` hook Object.defineProperty(hooks, 'addPageExtension', { - value: (...input: (string|string[])[]) => { - const exts = (input.flat(Infinity) as string[]).map(ext => `.${ext.replace(/^\./, '')}`); + value: (...input: (string | string[])[]) => { + const exts = (input.flat(Infinity) as string[]).map( + (ext) => `.${ext.replace(/^\./, '')}` + ); updatedConfig._ctx.pageExtensions.push(...exts); }, writable: false, - enumerable: false - }) + enumerable: false, + }); await integration.hooks['astro:config:setup'](hooks); } }