[ci] format

This commit is contained in:
natemoo-re 2022-06-20 19:06:53 +00:00 committed by github-actions[bot]
parent 8e3e4894c9
commit 509b4f122f
5 changed files with 35 additions and 14 deletions

View file

@ -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

View file

@ -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 (

View file

@ -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);
}

View file

@ -165,7 +165,11 @@ export function createRouteManifest(
): ManifestData {
const components: string[] = [];
const routes: RouteData[] = [];
const validPageExtensions: Set<string> = new Set(['.astro', '.md', ...config._ctx.pageExtensions]);
const validPageExtensions: Set<string> = new Set([
'.astro',
'.md',
...config._ctx.pageExtensions,
]);
const validEndpointExtensions: Set<string> = new Set(['.js', '.ts']);
function walk(dir: string, parentSegments: RoutePart[][], parentParams: string[]) {

View file

@ -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<Hook extends keyof AstroIntegration['hooks'], Fn = AstroIntegration['hooks'][Hook]> = Fn extends (...args: any) => any ? Parameters<Fn>[0] : never;
type Hooks<
Hook extends keyof AstroIntegration['hooks'],
Fn = AstroIntegration['hooks'][Hook]
> = Fn extends (...args: any) => any ? Parameters<Fn>[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);
}
}