[ci] format
This commit is contained in:
parent
8e3e4894c9
commit
509b4f122f
5 changed files with 35 additions and 14 deletions
|
@ -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.
|
// Track client:only usage so we can map their CSS back to the Page they are used in.
|
||||||
const clientOnlys = Array.from(metadata.clientOnlyComponentPaths());
|
const clientOnlys = Array.from(metadata.clientOnlyComponentPaths());
|
||||||
trackClientOnlyPageDatas(internals, pageData, clientOnlys);
|
trackClientOnlyPageDatas(internals, pageData, clientOnlys);
|
||||||
|
|
||||||
// Client-only components
|
// Client-only components
|
||||||
for (const clientOnly of clientOnlys) {
|
for (const clientOnly of clientOnlys) {
|
||||||
topLevelImports.add(clientOnly)
|
topLevelImports.add(clientOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add hoisted scripts
|
// Add hoisted scripts
|
||||||
|
|
|
@ -338,7 +338,13 @@ export async function validateConfig(
|
||||||
// First-Pass Validation
|
// First-Pass Validation
|
||||||
const result = {
|
const result = {
|
||||||
...(await AstroConfigRelativeSchema.parseAsync(userConfig)),
|
...(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)
|
// Final-Pass Validation (perform checks that require the full config object)
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -9,7 +9,7 @@ import type {
|
||||||
} from '../../@types/astro';
|
} from '../../@types/astro';
|
||||||
import type { LogOptions } from '../logger/core.js';
|
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 { getParams } from '../routing/params.js';
|
||||||
import { createResult } from './result.js';
|
import { createResult } from './result.js';
|
||||||
import { callGetStaticPaths, findPathItemByKey, RouteCache } from './route-cache.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);
|
const html = await renderComponent(result, Component.name, Component, props, null);
|
||||||
page = {
|
page = {
|
||||||
type: 'html',
|
type: 'html',
|
||||||
html: html.toString()
|
html: html.toString(),
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
page = await renderPage(result, Component, pageProps, null);
|
page = await renderPage(result, Component, pageProps, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,11 @@ export function createRouteManifest(
|
||||||
): ManifestData {
|
): ManifestData {
|
||||||
const components: string[] = [];
|
const components: string[] = [];
|
||||||
const routes: RouteData[] = [];
|
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']);
|
const validEndpointExtensions: Set<string> = new Set(['.js', '.ts']);
|
||||||
|
|
||||||
function walk(dir: string, parentSegments: RoutePart[][], parentParams: string[]) {
|
function walk(dir: string, parentSegments: RoutePart[][], parentParams: string[]) {
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import type { AddressInfo } from 'net';
|
import type { AddressInfo } from 'net';
|
||||||
import type { ViteDevServer } from 'vite';
|
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 ssgAdapter from '../adapter-ssg/index.js';
|
||||||
import type { SerializedSSRManifest } from '../core/app/types';
|
import type { SerializedSSRManifest } from '../core/app/types';
|
||||||
import type { PageBuildData } from '../core/build/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 type { ViteConfigWithSSR } from '../core/create-vite.js';
|
||||||
import { isBuildingToSSR } from '../core/util.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({
|
export async function runHookConfigSetup({
|
||||||
config: _config,
|
config: _config,
|
||||||
|
@ -51,16 +60,18 @@ export async function runHookConfigSetup({
|
||||||
injectRoute: (injectRoute) => {
|
injectRoute: (injectRoute) => {
|
||||||
updatedConfig._ctx.injectedRoutes.push(injectRoute);
|
updatedConfig._ctx.injectedRoutes.push(injectRoute);
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
// Semi-private `addPageExtension` hook
|
// Semi-private `addPageExtension` hook
|
||||||
Object.defineProperty(hooks, 'addPageExtension', {
|
Object.defineProperty(hooks, 'addPageExtension', {
|
||||||
value: (...input: (string|string[])[]) => {
|
value: (...input: (string | string[])[]) => {
|
||||||
const exts = (input.flat(Infinity) as string[]).map(ext => `.${ext.replace(/^\./, '')}`);
|
const exts = (input.flat(Infinity) as string[]).map(
|
||||||
|
(ext) => `.${ext.replace(/^\./, '')}`
|
||||||
|
);
|
||||||
updatedConfig._ctx.pageExtensions.push(...exts);
|
updatedConfig._ctx.pageExtensions.push(...exts);
|
||||||
},
|
},
|
||||||
writable: false,
|
writable: false,
|
||||||
enumerable: false
|
enumerable: false,
|
||||||
})
|
});
|
||||||
await integration.hooks['astro:config:setup'](hooks);
|
await integration.hooks['astro:config:setup'](hooks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue