Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored and github-actions[bot] committed Jun 20, 2022
1 parent 273f765 commit 991373f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/core/build/static-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 3 additions & 3 deletions src/core/render/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 5 additions & 1 deletion src/core/routing/manifest/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) {
Expand Down
25 changes: 18 additions & 7 deletions src/integrations/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
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';
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,
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 991373f

Please sign in to comment.